RDA5807M FM RDS radio program using 4DSystems 32028 Oled touch screen display. Search and direct frequency selection, RDS text, 10 preset memories
Dependencies: 4Dsystems_uOLED-32028-P1T RDA5807M FreescaleIAP mbed-src
Diff: main.cpp
- Revision:
- 0:879245ce9cdb
- Child:
- 1:365082270f1a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Mar 31 22:27:49 2015 +0000 @@ -0,0 +1,59 @@ +#include "mbed.h" +#include "RDA5807M.h" +#include "OLED32028P1T.h" + +RDA5807M radio(p9, p10, 0x22); // sda - scl + +OLED32028P1T oled(p28, p27, p29); // Oled Display tx, rx, rs +I2C i2c(p9, p10); + +DigitalOut myled(LED1); + +void readdata() // Extra read and print data function for checking, not actually used for anything. +{ + oled.locate(0,6); + int i; + char rcv[12]; + i2c.read(0x20, rcv,12); // read 12 bytes for reg 0x0A .. reg 0x0F + for(i=0; i<6; i++){ + oled.printf(" register: %X = %0X \n", i + 0x0A, (rcv[i *2] << 8) | rcv [(i*2) +1] ); + } +} + +int main() { + + oled.init(); + oled.clear(); + oled.drawText(0,0,(FONT12X16)," -- RDA5807m FM Radio --",oled.toRGB(0,255,0)); + oled.setTextBackgroundType (TEXT_OPAQUE); + oled.setFontSize(FONT12X16);oled.locate(2,2); + oled.setFontColor(oled.toRGB(255,255,255)); + + i2c.frequency(400000); + + radio.Reset(); // reset and power up radio chip + + radio.RDS(); // switch on RDS + + radio.Volume(2); // set volume + + while(1) { // Continuous tune test. + myled = !myled; + + radio.SeekUp(); // start seek tuning and stop when signal found (loops at end of range, 108MHz) + + wait(1); // Allow station find. + + radio.Read(); // Read Registers for frequency, signal level and RDS data, etc + + oled.locate(2,2); + oled.printf("Frequency: %3.2f MHz \n",radio.freq/1000); + oled.printf(" Signal Level: %d \n",radio.signal); + if (radio.stereo == 1){oled.printf(" Stereo");} + else {oled.printf(" Mono ");} + + readdata(); // Read registers (for testing) + wait(3); + } +} +