Skip to content

Commit 535d96b

Browse files
committed
remove callback dependency for send_rds
1 parent 2aaa031 commit 535d96b

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

examples/rda5807m_simpletest.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,9 @@
1919

2020
# Receiver i2c communication
2121
address = 0x11
22-
radio_i2c = I2CDevice(i2c, address)
23-
2422
vol = 3 # Default volume
2523
band = "FM"
2624

27-
radio = tinkeringtech_rda5807m.Radio(radio_i2c, presets[i_sidx], vol)
28-
radio.set_band(band) # Minimum frequency - 87 Mhz, max - 108 Mhz
2925
rds = tinkeringtech_rda5807m.RDSParser()
3026

3127
# Display initialization
@@ -45,6 +41,11 @@ def textHandle(rdsText):
4541

4642
rds.attach_text_callback(textHandle)
4743

44+
# Initialize the radio classes for use.
45+
radio_i2c = I2CDevice(i2c, address)
46+
radio = tinkeringtech_rda5807m.Radio(radio_i2c, rds, presets[i_sidx], vol)
47+
radio.set_band(band) # Minimum frequency - 87 Mhz, max - 108 Mhz
48+
4849
# Read input from serial
4950
def serial_read():
5051
if supervisor.runtime.serial_bytes_available:
@@ -151,7 +152,6 @@ def runSerialCommand(cmd, value=0):
151152

152153

153154
print_rds = False
154-
radio.attach_send_rds_callback(rds.process_data)
155155
runSerialCommand("?", 0)
156156

157157
print("-> ", end="")

tinkeringtech_rda5807m.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ class Radio:
144144
rssi = 0
145145

146146
# Set default frequency and volume
147-
def __init__(self, board, frequency=10000, volume=1):
147+
def __init__(self, board, rds_parser, frequency=10000, volume=1):
148148
self.board = board
149149
self.frequency = frequency
150150

@@ -158,7 +158,8 @@ def __init__(self, board, frequency=10000, volume=1):
158158
self.mono = False
159159
self.rds = False
160160
self.tuned = False
161-
self.send_rds = False
161+
self.rds_parser = rds_parser
162+
self.send_rds = rds_parser.process_data
162163

163164
# Is the signal strong enough to get rds?
164165
self.rds_ready = False
@@ -523,10 +524,6 @@ def read_registers(self):
523524
for i in range(6):
524525
self.registers[0xA + i] = self.read16()
525526

526-
def attach_send_rds_callback(self, new_function):
527-
"""docstring."""
528-
self.send_rds = new_function
529-
530527

531528
def replace_element(index, text, newchar):
532529
"""docstring."""

0 commit comments

Comments
 (0)