'# Browser Radio
memclear
time.setup(2,1) 'CEST
' on error global reboot after 60s, kill by watchdog 0
'watchdog 60
f = 95.1
rx f
tft.cls()
gosub setfreq
freq f
pwmfreq 32000
pwmout 38,50 'BACKLIGHT 50
name = "Station"
txt = "RDS Radio Text"
volume 50
VOL= 50
textbox zeit
cssID htmlID(),"border:none;width:60px"
textbox txt
cssid htmlid(),"width: 400px;border:none;color:navy;font-style: italic;font-weight: bold;"
'textbox mem
html |
|
textbox f
'onchange setfreq
cssID htmlID(),"width:96px;font-weight:bold;text-align:center;"
Button "f",jump
textbox name
cssID htmlID(),"border:none;width:80px;text-align:center;font-weight:bold;"
html |
|
button "-",minus
button "SCAN up",scan
button "+",plus
slider VOL,0,62
button "Set Volume",setvol
html |
|
meter rssi,0,75,10,20,32
html | RSSI
|
meter snr,0,75,10,20,32
html | SNR
|
meter audio,0,1000
html | Audio
|
meter wifi,0,100,20,70,100
html | WiFi
|
meter accu,26,42,29,37,42
html | Battery
|
radio ST
radio TP
radio TA
html |
|
button "5955 kHz",f5955
button "13635 kHz",f13635
button "15340 kHz",f15340
button "17650 kHz",f17650
button "WDR 2",wdr2
button "WDR 3",wdr3
button "WDR 4",wdr4
button "WDR 5",wdr5
button "DLF",dlf
button "DLF K",dlfk
button "Antenne",antenne
timer 500,tim
wait
setvol:
volume VOL
wait
f5955:
f = 5955
jump:
gosub setfreq
wait
f13635:
f = 13635
goto jump
f15340:
f = 15340
goto jump
f17650:
f = 17650
goto jump
wdr2:
f = 99.2
goto jump
wdr3:
f = 95.1
goto jump
wdr4:
f = 101.3
goto jump
wdr5:
f = 88.8
goto jump
dlf:
f = 102.8
goto jump
dlfk:
f = 96.5
goto jump
antenne:
f = 104.2
goto jump
tim:
'watchdog
if rx.fm()<>0 then
n = rx.station()
if n<>"" and f<109 then name = trim(n)
n = rx.text()
if n<>"" and f<109 then txt = trim(n)
endif
zeit = time("time")
rssi = rx.rssi()
snr = rx.snr()
wifi = map(wifi.rssi(), -90, -30, 0, 100)
audio = io(adc,11)
accu = io(adc,4)/1023*66
'gosub wifistatus
ST = rx.stereo()
TP = rx.tp()
TA = TP and rx.TA()
'mem = ramfree()
wait
'#define AMP_EN 10
setfreq:
'watchdog
' no klick in speaker: hard mute
if (rx.am()==1 and f<109) or (rx.fm()==1 and f>109) then
pinout 10,0
endif
freq f
pinout 10,1 'unmute
gosub drawfreq
name=""
txt=""
return
[drawfreq]
sf = format("%5.0f ",rx.freq())
if f<109 then sf = format("%5.1f ",rx.freq())
tft.text.datum(4)
tft.text.color(65535,0)
tft.text.draw(sf,160,60,7)
return
scan:
if f>109 then start = f+5 else start = f + 0.1
if f>109 then stp = 5 else stp = 0.1
for f = start to 30000 step stp
if f>108 and f<150 then
f = 150.000
stp = 5
endif
gosub setfreq
snr = rx.snr()
rssi = rx.rssi()
if snr>0 then
gosub setfreq
wait
endif
next f
wait
plus:
if f>109 then f = f+5 else f = f + 0.1
gosub setfreq
wait
minus:
if f>109 then f = f-5 else f = f - 0.1
gosub setfreq
wait
wifistatus:
'REBOOT ON DISCONNECT for debugging
if status()<>3 then reboot
tft.text.cursor(4,4)
tft.print(str(status()))
return