This program is the most basic to tune in and start a station with a known frequency and at a fixed volume (but programmable when configuring).
May the purists excuse me for my inelegant use of logical operators, but the truth is that I have not mastered them.
I think I'm going around too much: Can someone simplify my code?
Code: [Local Link Removed for Guests]
' RDA5807 FM Radio tuner
i2c.setup 4, 5
address = &H11 ' I2C device address
ioBuff.dim(0,4) = &HD0, &H01, &H08, &H86
' init RDA5807
i2c.write_ioBuff(0, 0, 2), address, &H02
i2c.write_ioBuff(0, 2, 2), address, &H05
' ************ DEMO ******************
while 1
tuneIn 93.00
wlog "RNE 2 Clasica"
pause 15000
tuneIn 102.90
wlog "RNE 3"
pause 15000
tuneIn 96.90
wlog "RNE 1"
pause 15000
tuneIn 105.00
wlog "Radio 5 Todo Noticias"
pause 15000
wend
END
' --------------------------------------------
SUB tuneIn(frequency)
LOCAL channel, hightByte, lowByte
channel = ((frequency * 100) - 8700) / 10
hightByte = channel >> 2
lowByte = (channel << 6) OR &H10
lowByte = lowByte AND &HFF
ioBuff.dim(1, 2) = hightByte, lowByte
i2c.write_ioBuff(1), address, &H03
END SUB
Documentation:
https://myrapidq.it/public/RDA5807 Register.pdf
https://myrapidq.it/public/RDA5807MP datasheet.pdf
I edit to tell you an anecdote: When I was recording the video, when I changed the station a song came on. Upon uploading it to YouTube, in a matter of seconds I received an email from them, informing me that due to copyright protection, my video has been blocked in Belarus and Russia.