backup python test scripts + rock4 docs from Obsidian

Wouter Groeneveld 1 month ago
parent 8d7ced37ab
commit 2a412f864b

@ -0,0 +1,15 @@
#import board
from adafruit_blinka.board.radxa.rockpi4cplus import *
import busio
import adafruit_si4713
import digitalio
#i2c = busio.I2C(board.SCL, board.SDA)
i2c = busio.I2C(SCL7, SDA7)
si_reset = digitalio.DigitalInOut(D29)
si4713 = adafruit_si4713.SI4713(i2c, reset=si_reset, timeout_s=0.5)
# Calling this short script also boots the FM transmitter chip
# That is, if the demo script was interrupted, it'll continue transmitting, until this one is called.

@ -0,0 +1,79 @@
# SPDX-FileCopyrightText: 2018 Tony DiCola for Adafruit Industries
# SPDX-License-Identifier: MIT
# Simple demo of using the SI4743 RDS FM transmitter.
import time
import board
import busio
import digitalio
import adafruit_si4713
# Specify the FM frequency to transmit on in kilohertz. As the datasheet
# mentions you can only specify 50khz steps!
FREQUENCY_KHZ = 96300 # 102.300mhz
# Initialize I2C bus.
#i2c = board.I2C() # uses board.SCL and board.SDA
i2c = busio.I2C(board.SCL7, board.SDA7)
# i2c = board.STEMMA_I2C() # For using the built-in STEMMA QT connector on a microcontroller
# Initialize SI4713.
si4713 = adafruit_si4713.SI4713(i2c)
# Alternatively you can specify the I2C address of the device if it changed:
#si4713 = adafruit_si4713.SI4713(i2c, address=0x36)
# If you hooked up the reset line you should specify that too. Make sure
# to pass in a DigitalInOut instance. You will need the reset pin with the
# Raspberry Pi, and probably other devices:
si_reset = digitalio.DigitalInOut(board.D29)
print("initializing si4713 instance")
#si4713 = adafruit_si4713.SI4713(i2c, reset=si_reset, timeout_s=0.5)
# Measure the noise level for the transmit frequency (this assumes automatic
# antenna capacitance setting, but see below to adjust to a specific value).
noise = si4713.received_noise_level(FREQUENCY_KHZ)
# Alternatively measure with a specific frequency and antenna capacitance.
# This is not common but you can specify antenna capacitance as a value in pF
# from 0.25 to 47.75 (will use 0.25 steps internally). If you aren't sure
# about this value, stick with the default automatic capacitance above!
# noise = si4713.received_noise_level(FREQUENCY_KHZ, 0.25)
print("Noise at {0:0.3f} mhz: {1} dBuV".format(FREQUENCY_KHZ / 1000.0, noise))
# Tune to transmit with 115 dBuV power (max) and automatic antenna tuning
# capacitance (default, what you probably want).
si4713.tx_frequency_khz = FREQUENCY_KHZ
si4713.tx_power = 115
# Configure RDS broadcast with program ID 0xADAF (a 16-bit value you specify).
# You can also set the broadcast station name (up to 96 bytes long) and
# broadcast buffer/song information (up to 106 bytes long). Setting these is
# optional and you can later update them by setting the rds_station and
# rds_buffer property respectively. Be sure to explicitly specify station
# and buffer as byte strings so the character encoding is clear.
si4713.configure_rds(0xADAF, station=b"AdaRadio", rds_buffer=b"Adafruit g0th Radio!")
# Print out some transmitter state:
print("Transmitting at {0:0.3f} mhz".format(si4713.tx_frequency_khz / 1000.0))
print("Transmitter power: {0} dBuV".format(si4713.tx_power))
"Transmitter antenna capacitance: {0:0.2} pF".format(si4713.tx_antenna_capacitance)
# Set GPIO1 and GPIO2 to actively driven outputs.
si4713.gpio_control(gpio1=True, gpio2=True)
# Main loop will print input audio level and state and blink the GPIOs.
while True:
# Print input audio level and state.
print("Input level: {0} dBfs".format(si4713.input_level))
print("ASQ status: 0x{0:02x}".format(si4713.audio_signal_status))
# 'Blink' GPIO1 and GPIO2 alternatively on and off.
si4713.gpio_set(gpio1=True, gpio2=False) # GPIO1 high, GPIO2 low
si4713.gpio_set(gpio1=False, gpio2=True) # GPIO1 low, GPIO2 high

@ -0,0 +1,88 @@
# Radxa Rock Pi 4 C+
Enige werkende build: Debian 10 desktop link waar zowel X als audio in werkt... zie
Login: rock/rock. SSH @ 22 enabled. Wifi zelf te doen met `nmcli r wifi on`
GPIO interface:
CPU/GPU temp check: `cat /sys/class/thermal/thermal_zone[0/1]/temp` (0 = CPU, 1 = GPU) => gaat al snel naar 73+ bij Chromium streaming!!
## Audio
Audio jack out no sound probleem: via alsamixer:
1. `F6` (change sound card), select Rockchip RK809 codec
2. Playback path: op `HP` zetten ipv `SPK` of `RCV`
Werkt niet voor Chromium-based geluid? => open Volume Control, selecteer "Built-in Audio Stereo" (2de optie! labels verkeerdelijk hetzelfde in officiële Debian build?)
## FM Transmitter
Met Official Pi:
Doorgemeten: pin 3v0 probleem? (ongebruikt). Oscilloscope: OK, 7 bits komen door?
### I2c detectie?
`mraa-i2c detect 0` (i2c7: pin 03/05; zie `mraa-gpio list`) (geeft geen output?) => ook nog aan zetten in `/boot/hw_initfc.conf`!!
Testen met `sudo mraa-i2c set 0 0x50 0x10 0x55` (bus 0, adres `0x50`, reg `0x10`, value `0x55`) - zelfde als iets wegschrijven naar `/dev/i2c-0`? Zie Go impl
**Detectie** met `detect 0` (bus 0) werkt soms (return `0x63`), soms niet? Waarom?
- Slecht gesoldeerd?
- Rock 3399 I2C chip niet stabiel?
- Kernel driver niet tegoei?
### CircuitPython probleem
- "Board not supported ROCK_PI_4C_" in site-packages/ toegevoegd
- Microcontroller not supported: "RK3399 T" in site-packages/microcontroller/
### Transmitter reset
fm transmitter adafruit: eerst reset high/low/high op pin zetten???
#define RSTPIN 12
const int8_t RESETPIN = 12;
const uint16_t FMSTATION = 10300;
const uint8_t FMPOWER = 115;
const uint8_t I2CADDRESS = 0x63; // if cs=0 address is 0x11
Adafruit_Si4713 radio;
boolean radioFound;
int capacitor;
uint8_t power;
void setup() {
digitalWrite(RSTPIN, HIGH);
void loop(){
void reset_tx(){
digitalWrite(RSTPIN, HIGH);
digitalWrite(RSTPIN, LOW);
digitalWrite(RSTPIN, HIGH);
Dit heeft het probleem opgelost!