BASCOM-Quellcode: Radio
- '*******************
- '* Udo Lorenz *
- '* 23.10.2017 *
- '* *
- '*******************
- 'Low Fuse (0xF1)
- 'High Fuse (0xDE)
- 'Lockbits (0xFF)
- 'VCC = 3,3V
- 'Puppenstubenradio mit ATtiny85; OLED-Display 128x64;
- 'RDA5807M - FM-RADIO-Modul; NF-Verstärkermodul;Taste Festsender waehlen;
- 'jeweils eine Taste Frequenz hoch bzw. runter.
- 'PS: Display zeigt nach Senderwahl animiertes Bild.
- 'I2c Slaves Alle Geraden Adressen Suchen...
- 'Slave DEC: 32 HEX: H20 BIN: B00100000 write RDA5807M
- 'Slave DEC: 34 HEX: H22 BIN: B00100010 read RDA5807M
- 'Slave DEC: 120 HEX: H78 BIN: B01111000 OLED
- 'Slave DEC: 192 HEX: HC0 BIN: B11000000 RDA5807M
- 'Ende Scan
- $regfile = "ATtiny85.DAT"
- $crystal = 16000000
- $hwstack = 80
- $swstack = 80
- $framesize = 100
- 'Config
- Dim Tastenwert As Word ,
- Dim Byte0 As Byte
- Dim Byte1 As Byte
- Dim Z As String * 5
- Dim Z1 As Byte
- Dim Freg As Integer
- Dim Pll As Single
- Dim Sender1 As String * 10
- Dim Zaehler As Dword
- Dim Z2 As Dword
- Config Pinb.4 = Input
- Config Portb.1 = Output
- Config Portb.3 = Output
- 'I2C Config
- Config Scl = Portb.2 ' Config i2c pins
- Config Sda = Portb.0
- Config I2cdelay = 1 'i2c speed 10 =100,5 = 200,2=500,1=1000
- I2cinit : Waitms 10
- 'Display Config
- $lib "glcdSSD1306-I2C.lib" ' SSD1306 LIB einbinden
- Config Graphlcd = Custom , Cols = 128 , Rows = 64 , Lcdname = "SSD1106" 'SSD1106 oder SSD1306
- 'Sub
- Declare Sub Ausgabe
- Declare Sub Radio
- 'Display init
- Wait 1
- Cls
- Setfont Font16x16
- Lcdat 1 , 1 , " Radio "
- Lcdat 3 , 1 , " " , 1
- Lcdat 5 , 1 , " " , 1
- Lcdat 7 , 1 , "Font 16x"
- 'Tasten ADC Config
- Config Adc = Single , Prescaler = Auto , Reference = Internal_1.1 ' Referenz 1,1V intern
- Start Adc
- 'Init Start
- Readeeprom Freg , &H20 'Sender im Eeprom als Startsender
- Readeeprom Sender1 , &H50
- Z = Str(freg)
- Call Radio
- Waitms 30
- If Freg > 999 Then Z = Format(z , "000.0") Else Z = Format(z , "00.0")
- Call Ausgabe
- Restore Dta1
- '===============================================================================
- 'Hauptprogramm
- Do
- For Zaehler = 0 To 2000
- Tastenwert = Getadc(2)
- If Tastenwert > 210 And Tastenwert < 250 And Freg > 875 Then 'Taste1 Frquenz Minus
- Freg = Freg - 1
- Z = Str(freg)
- If Freg > 999 Then Z = Format(z , "000.0") Else Z = Format(z , "00.0")
- Sender1 = " ???"
- Call Radio
- Call Ausgabe
- End If
- If Tastenwert > 440 And Tastenwert < 500 And Freg < 1080 Then 'Taste2 Frequenz Plus
- Freg = Freg + 1
- Z = Str(freg)
- If Freg > 999 Then Z = Format(z , "000.0") Else Z = Format(z , "00.0")
- Sender1 = " ???"
- Call Radio
- Call Ausgabe
- End If
- If Tastenwert > 650 And Tastenwert < 750 Then 'Taste3 Festsenderwahl
- Z1 = Z1 + 1
- If Z1 = 7 Then 'hier 6 Festsender
- Restore Dta1
- Z1 = 1
- End If
- Read Freg
- Read Sender1
- Z = Str(freg)
- If Freg > 999 Then Z = Format(z , "000.0") Else Z = Format(z , "00.0")
- Call Radio
- Call Ausgabe
- End If
- Waitms 10
- Next Zaehler
- Writeeeprom Freg , &H20 'Speichern des aktuellen Senders im Eeprom
- Writeeeprom Sender1 , &H50
- Gosub Bildausgabe
- Loop
- End
- '===============================================================================
- 'LCD-Font
- $include "font16x16.font"
- '===============================================================================
- Sub Ausgabe
- Lcdat 1 , 1 , " Radio "
- Lcdat 3 , 1 , " " , 1
- Lcdat 3 , 1 , " " ; Z , 1
- Lcdat 5 , 1 , " " , 1
- Lcdat 5 , 1 , " Mhz" , 1
- Lcdat 7 , 1 , " "
- Lcdat 7 , 1 , Sender1
- Waitms 10
- End Sub
- '===============================================================================
- Sub Radio
- I2cinit
- I2cstart
- I2cwbyte &B00100000 '20H write
- I2cwbyte &B11000010 '02H H-Bit
- I2cwbyte &B00000101 '02L L-Bit
- Pll = Freg - 870
- Byte0 = Pll / 4
- I2cwbyte Byte0
- Byte1 = Byte0 * 4 '03H
- Byte1 = Pll - Byte1
- Byte1 = Byte1 * 64
- Byte1.4 = 1
- I2cwbyte Byte1 '03L
- I2cwbyte &B00000010 '04H
- I2cwbyte &B00000000 '04L
- I2cwbyte &B10001000 '05H
- I2cwbyte &B10001111 '05L
- I2cwbyte &B00000000 '06H
- I2cstop
- End Sub
- '===============================================================================
- Bildausgabe:
- Showpic 0 , 0 , Bild1
- Do
- Z2 = Z2 + 1
- If Z2 = 3000 Then
- Showpic 0 , 0 , Bild1
- End If
- If Z2 = 18000 Then
- Showpic 0 , 0 , Bild2
- Z2 = 0
- End If
- Tastenwert = Getadc(2)
- If Tastenwert > 60 Then 'Bei Tastendruck Rücksprung ins HP
- Return
- End If
- Loop
- End
- 'Senderliste
- Dta1:
- Data 898% , " JUMP" , 923% , " RSA" , 970% , " DLF"
- Data 1000% , " PSR" , 1034% , "Zwickau" , 1054% , " RTL"
- Bild1:
- $bgf "8.bgf"
- Bild2:
- $bgf "7.bgf"
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von Udo01 ()