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
Revision 1:365082270f1a, committed 2015-04-11
- Comitter:
- star297
- Date:
- Sat Apr 11 22:53:48 2015 +0000
- Parent:
- 0:879245ce9cdb
- Child:
- 2:c2472db29970
- Commit message:
- Version 1.0
Changed in this revision
--- a/4Dsystems_uOLED-32028-P1T.lib Tue Mar 31 22:27:49 2015 +0000 +++ b/4Dsystems_uOLED-32028-P1T.lib Sat Apr 11 22:53:48 2015 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/star297/code/4Dsystems_uOLED-32028-P1T_LPC1768_KL25Z/#8ea60129317b +4Dsystems_uOLED-32028-P1T#0e93e95bab96
--- a/RDA5807M.lib Tue Mar 31 22:27:49 2015 +0000 +++ b/RDA5807M.lib Sat Apr 11 22:53:48 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/star297/code/RDA5807M/#527aa96336ac +RDA5807M#2c8a64e71afd
--- a/main.cpp Tue Mar 31 22:27:49 2015 +0000 +++ b/main.cpp Sat Apr 11 22:53:48 2015 +0000 @@ -1,59 +1,373 @@ #include "mbed.h" #include "RDA5807M.h" #include "OLED32028P1T.h" - -RDA5807M radio(p9, p10, 0x22); // sda - scl + +RDA5807M radio(p9, p10); // sda - scl + +OLED32028P1T oled(p28, p27, p26); // Oled Display tx, rx, rs + +DigitalOut led(LED1); -OLED32028P1T oled(p28, p27, p29); // Oled Display tx, rx, rs -I2C i2c(p9, p10); +Timer t1; + +int f,v,n,i,l,r,g,b,Fl,IRQ,xbuf,ybuf,pr,prgroup; +int signal,lastsignal,volume,lastvol,lastmute,lastmono,lastbass,lastrds,laststereo,rdstextgood; -DigitalOut myled(LED1); +float lastfreq,pointer,lastpointer,Freq; -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] ); - } -} +char k; +char sig[4]; +char tFQ[20],freq[8],vol[4]; +char station[10],lastStationName[10]; +char text1[50],lasttext1[50]; +char text2[50],lasttext2[50]; +char PresetName[10][12] = {"Empty A ", "Empty A ", "Empty A ", "Empty A ", "Empty A ", "Empty B ", "Empty B ", "Empty B ", "Empty B ", "Empty B "}; -int main() { - +float PresetFreq[10]; + +void radiomain(),initdisplay(),displayrefresh(),getrds(); +void getkey(),flushbuffer(),Volume(),setfreq(),Power(),Preset(),Drawpresets(); + +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.setFontSize(FONT5X7);oled.locate(2,20); 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 + oled.enableTouch();oled.resetTouchArea(); + + radio.Reset(); // reset and power up radio chip - while(1) { // Continuous tune test. - myled = !myled; + while(1){ + initdisplay(); + radiomain(); + } +} + + +void radiomain() +{ + while(IRQ==0){ + + getkey(); - 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.setFontSize(FONT5X7);oled.locate(20,0); + //oled.printf("X %03d Y %03d ",xbuf,ybuf); - 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); + if(radio.power){ + if(f){setfreq();f=0;} + radio.processData(); + getrds(); + displayrefresh(); + wait_ms(10); + led=!led; + } + } +} + +void displayrefresh() +{ + if (strcmp(lastStationName, radio.StationName) != 0){ + oled.drawTextGraphic(26,16,(FONT12X16),radio.StationName, 1, 1, oled.toRGB(0,200,200)); + strcpy(lastStationName,radio.StationName); + } + if(lastfreq != radio.freq/1000){lastfreq = radio.freq/1000; + sprintf(tFQ, "%3.2f ",radio.freq/1000); + oled.drawTextGraphic(176,16,(FONT12X16),tFQ, 1, 1, oled.toRGB(0,200,200)); + pointer = (lastfreq-87) *12; + oled.setPenSize(0); + oled.drawRectangle(lastpointer+29,66,10,8,oled.toRGB(0,0,0)); + oled.drawRectangle(lastpointer+33,56,2,18,oled.toRGB(0,0,0)); + oled.drawRectangle(pointer+29,66,10,8,oled.toRGB(255,255,255)); + oled.drawRectangle(pointer+33,56,2,18,oled.toRGB(255,0,0)); + lastpointer = pointer; + rdstextgood=0;lastrds=!lastrds; + oled.setPenSize(1); + } + if(laststereo != radio.stereo){ + if(radio.stereo){oled.drawTextGraphic(32,79,(FONT5X7),"Stereo", 1, 1, oled.toRGB(0,255,0));} + else{oled.drawTextGraphic(32,79,(FONT5X7)," Mono ", 1, 1, oled.toRGB(255,0,0));} + laststereo = radio.stereo; + } + if(lastsignal != radio.signal){ + signal=radio.signal; + if(radio.mute){signal=0;} + sprintf(sig, "%d ",signal); + oled.drawTextGraphic(124,79,(FONT5X7),sig, 1, 1, oled.toRGB(255,255,255)); + if(signal<20){r=255;g=0;b=0;} + if(signal>19 && signal<24){r=255;g=255;b=0;} + if(signal>23){r=0;g=255;b=0;} + oled.setPenSize(0); + oled.drawRectangle(140,79,(lastsignal*2.4),6,oled.toRGB(0,0,0)); + oled.drawRectangle(140,79,(signal*2.4),6,oled.toRGB(r,g,b)); + oled.setPenSize(1); + lastsignal=radio.signal; + } + if(lastvol != radio.volume){ + volume=radio.volume; + sprintf(vol," %d ", volume); + if(radio.volume<10){oled.drawTextGraphic(94,196,(FONT12X16),vol, 1, 1, oled.toRGB(255,255,255));} + else{oled.drawTextGraphic(88,196,(FONT12X16),vol, 1, 1, oled.toRGB(255,255,255));} + lastvol = volume; + } + if(lastmute != radio.mute){ + oled.setTextBackgroundType (TEXT_TRANSPARENT); + if(radio.mute){oled.drawTextButton(1, 260, 197,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(128,128,128)), 1, 1, " Mute ");} + else{oled.drawTextButton(1, 260, 197,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(255,255,255)), 1, 1, " Mute ");} + oled.setTextBackgroundType (TEXT_OPAQUE); + lastmute=radio.mute; + } + if(lastmono != radio.mono){ + oled.setTextBackgroundType (TEXT_TRANSPARENT); + if(radio.mono){oled.drawTextButton(1, 260, 155,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(255,0,0)), 1, 1, " Mono ");} + else{oled.drawTextButton(1, 260, 155,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(0,255,0)), 1, 1, "Stereo");} + oled.setTextBackgroundType (TEXT_OPAQUE); + lastmono=radio.mono; + } + if(lastbass != radio.bass){ + oled.setTextBackgroundType (TEXT_TRANSPARENT); + if(radio.bass){oled.drawTextButton(1, 260, 176,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(255,255,255)), 1, 1, " Bass ");} + else{oled.drawTextButton(1, 260, 176,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(128,128,128)), 1, 1, " Bass ");} + oled.setTextBackgroundType (TEXT_OPAQUE); + lastbass=radio.bass; + } + if(lastrds != radio.rds){ + oled.setTextBackgroundType (TEXT_TRANSPARENT); + oled.setPenSize(0);oled.drawRectangle(30,96,280,18,oled.toRGB(0,0,0));oled.setPenSize(1); + if(radio.rds){ + if(rdstextgood){oled.drawTextButton(1, 260, 134,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(0,255,0)), 1, 1, "RDS RT");} + else{oled.drawTextButton(1, 260, 134,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(255,255,255)), 1, 1, " RDS ");} + } + else{oled.drawTextButton(1, 260, 134,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(128,128,128)), 1, 1, " RDS ");rdstextgood=0;} + oled.setTextBackgroundType (TEXT_OPAQUE); + lastrds=radio.rds; + } + if (strcmp(text1, lasttext1) != 0){ + oled.setPenSize(0);oled.drawRectangle(30,96,280,8,oled.toRGB(0,0,0));oled.setPenSize(1); + oled.drawTextGraphic(30,96,(FONT5X7),text1, 1, 1, oled.toRGB(255,255,255)); + strcpy(lasttext1, text1);} + if (strcmp(text2, lasttext2) != 0){ + oled.setPenSize(0);oled.drawRectangle(30,106,280,8,oled.toRGB(0,0,0));oled.setPenSize(1); + oled.drawTextGraphic(30,106,(FONT5X7),text2, 1, 1, oled.toRGB(255,255,255)); + strcpy(lasttext2, text2);} +} + +void getrds() +{ + if(strlen(radio.RDSText)==64 && signal>23){ + //oled.drawTextGraphic(10,200,(FONT5X7),radio._RDSText, 1, 1, oled.toRGB(255,255,255)); + memset(text1, '\0', sizeof(text1)); + memset(text2, '\0', sizeof(text2)); + memset(lasttext1, '\0', sizeof(lasttext1)); + memset(lasttext2, '\0', sizeof(lasttext2)); + if(!rdstextgood){rdstextgood=1;lastrds=!lastrds;} + strcpy (text1, radio.RDSText); + + for ( i = 0; i < (64); i++ ) + if (i>30 && (text1[i] == ' ') ){ + text1 [strlen(text1) - (64-i)] = '\0'; + l=strlen(text1); + i=64; + } + strcpy (text2, radio.RDSText + l); + while(text2[0]==' '){ + strcpy (text2, (text2 + 1)); + } + strcat (text1,"\0"); + strcat (text2,"\0"); + memset(radio.RDSText, '\0', sizeof(radio.RDSText)); } } +void initdisplay() +{ + oled.setPenSize(1); + oled.drawTextGraphic(50,6,(FONT5X7),"Station Frequency", 1, 1, oled.toRGB(0,200,200)); + oled.drawTextGraphic(260,16,(FONT12X16),"MHz", 1, 1, oled.toRGB(0,200,200)); + oled.drawTextGraphic(42,35,(FONT5X7),"88 90 92 94 96 98 100 102 104 106 108", 1, 1, oled.toRGB(255,255,0)); + oled.drawTextGraphic(78,79,(FONT5X7),"Signal:", 1, 1, oled.toRGB(255,255,255)); + oled.drawRectangle(26,55,268,20,oled.toRGB(255,255,255)); + oled.drawRectangle(26,75,268,14,oled.toRGB(255,255,255)); + for (i = 46; i < (300); i=i+24 ) + {oled.drawLine(i,55,i,45,oled.toRGB(255,255,255)); + oled.drawLine(i-12,55,i-12,50,oled.toRGB(255,255,255)); + } + oled.drawTextGraphic(90,220,(FONT8X12),"Volume", 1, 1, oled.toRGB(255,255,255)); + oled.setTextBackgroundType (TEXT_TRANSPARENT); + oled.drawTextButton(1, 10, 210,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, " 0 "); + oled.drawTextButton(1, 56, 210,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "."); + oled.drawTextButton(1, 10, 184,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "1"); + oled.drawTextButton(1, 33, 184,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "2"); + oled.drawTextButton(1, 56, 184,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "3"); + oled.drawTextButton(1, 10, 158,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "4"); + oled.drawTextButton(1, 33, 158,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "5"); + oled.drawTextButton(1, 56, 158,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "6"); + oled.drawTextButton(1, 10, 132,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "7"); + oled.drawTextButton(1, 33, 132,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "8"); + oled.drawTextButton(1, 56, 132,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "9"); + oled.drawTextButton(1, 86, 132,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, " Up "); + oled.drawTextButton(1, 86, 158,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, " Down "); + oled.drawTextButton(1, 146, 184,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "+"); + oled.drawTextButton(1, 146, 210,(oled.toRGB(0,100,100)),(FONT12X16),(oled.toRGB(255,255,255)), 1, 1, "-"); + oled.drawTextButton(1, 260, 134,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(255,255,255)), 1, 1, " RDS "); + oled.drawTextButton(1, 260, 155,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(0,255,0)), 1, 1, "Stereo"); + oled.drawTextButton(1, 260, 176,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(128,128,128)), 1, 1, " Bass "); + oled.drawTextButton(1, 260, 197,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(255,255,255)), 1, 1, " Mute "); + oled.drawTextButton(1, 260, 218,(oled.toRGB(0,100,100)),(FONT8X12),(oled.toRGB(255,255,255)), 1, 1, "Power "); + + oled.drawTextButton(1, 190, 134,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(255,255,255)), 1, 1, "Presets A"); + oled.drawTextButton(1, 190, 154,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(128,128,128)), 1, 1, PresetName[0]); + oled.drawTextButton(1, 190, 171,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(128,128,128)), 1, 1, PresetName[1]); + oled.drawTextButton(1, 190, 188,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(128,128,128)), 1, 1, PresetName[2]); + oled.drawTextButton(1, 190, 205,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(128,128,128)), 1, 1, PresetName[3]); + oled.drawTextButton(1, 190, 222,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(128,128,128)), 1, 1, PresetName[4]); + oled.setTextBackgroundType (TEXT_OPAQUE); +} + +void getkey() +{ + flushbuffer(); + oled.getTouch(&xbuf,&ybuf); + if(radio.power){ + if((xbuf>16 && xbuf<34) && (ybuf>180 && ybuf<202)) {k='1';f=1;} + if((xbuf>38 && xbuf<54) && (ybuf>180 && ybuf<202)) {k='2';f=1;} + if((xbuf>58 && xbuf<78) && (ybuf>180 && ybuf<202)) {k='3';f=1;} + if((xbuf>16 && xbuf<34) && (ybuf>158 && ybuf<178)) {k='4';f=1;} + if((xbuf>38 && xbuf<54) && (ybuf>158 && ybuf<178)) {k='5';f=1;} + if((xbuf>58 && xbuf<78) && (ybuf>158 && ybuf<178)){k='6';f=1;} + if((xbuf>16 && xbuf<34) && (ybuf>135 && ybuf<154)) {k='7';f=1;} + if((xbuf>38 && xbuf<54) && (ybuf>135 && ybuf<154)){k='8';f=1;} + if((xbuf>58 && xbuf<78) && (ybuf>135 && ybuf<154)){k='9';f=1;} + if((xbuf>16 && xbuf<56) && (ybuf>205 && ybuf<225)) {k='0';f=1;} + if((xbuf>60 && xbuf<78) && (ybuf>205 && ybuf<225)) {k='.';f=1;} + if((xbuf>248 && xbuf<298) && (ybuf>194 && ybuf<210)){radio.Mute();} + if((xbuf>248 && xbuf<298) && (ybuf>176 && ybuf<192)){radio.BassBoost();} + if((xbuf>248 && xbuf<298) && (ybuf>158 && ybuf<174)){radio.Mono();} + if((xbuf>248 && xbuf<298) && (ybuf>138 && ybuf<156)){radio.RDS();} + if((xbuf>140 && xbuf<160) && (ybuf>180 && ybuf<202)){v=1;Volume();} + if((xbuf>140 && xbuf<160) && (ybuf>204 && ybuf<226)){v=0;Volume();} + if((xbuf>86 && xbuf<160) && (ybuf>135 && ybuf<155)){radio.SeekUp();} + if((xbuf>86 && xbuf<160) && (ybuf>157 && ybuf<179)){radio.SeekDown();} + + if((xbuf>182 && xbuf<244) && (ybuf>137 && ybuf<150)){ + oled.setTextBackgroundType (TEXT_TRANSPARENT); + if(prgroup==0){prgroup=5;oled.drawTextButton(1, 190, 134,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(255,255,255)), 1, 1, "Presets A");} + else{prgroup=0;oled.drawTextButton(1, 190, 134,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(255,255,255)), 1, 1, "Presets B");} + oled.setTextBackgroundType (TEXT_OPAQUE); + Drawpresets(); + } + if((xbuf>182 && xbuf<244) && (ybuf>154 && ybuf<166)){pr=0;Preset();} + if((xbuf>182 && xbuf<244) && (ybuf>170 && ybuf<180)){pr=1;Preset();} + if((xbuf>182 && xbuf<244) && (ybuf>184 && ybuf<196)){pr=2;Preset();} + if((xbuf>182 && xbuf<244) && (ybuf>198 && ybuf<210)){pr=3;Preset();} + if((xbuf>182 && xbuf<244) && (ybuf>212 && ybuf<225)){pr=4;Preset();} + } + if((xbuf>248 && xbuf<298) && (ybuf>212 && ybuf<228)){Power();} +} + +void Preset() +{ + + if(PresetFreq[pr+prgroup]!=0 && PresetFreq[pr+prgroup]==radio.freq/1000){ + strcpy(PresetName[pr+prgroup],"Empty "); + if(prgroup){strcat(PresetName[pr+prgroup],"B ");} + else{strcat(PresetName[pr+prgroup],"A ");} + PresetFreq[pr+prgroup]=0; + Drawpresets(); + return; + } + + if(PresetFreq[pr+prgroup]==0){ + if(radio.signal>25){ + strcpy(PresetName[pr+prgroup],radio.StationName);} + else{ + sprintf(tFQ, "%3.2f MHz",radio.freq/1000); + strcpy(PresetName[pr+prgroup],tFQ); + } + while(strlen(PresetName[pr+prgroup])<10){ + strcat(PresetName[pr+prgroup]," "); + } + PresetFreq[pr+prgroup]=radio.freq/1000; + Drawpresets(); + return; + } + + radio.Frequency(PresetFreq[pr+prgroup]); +} + +void Drawpresets() +{ + oled.setTextBackgroundType (TEXT_TRANSPARENT); + if(PresetFreq[0+prgroup]!=0){oled.drawTextButton(1, 190, 154,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(0,255,255)), 1, 1, PresetName[0+prgroup]);} + else{oled.drawTextButton(1, 190, 154,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(128,128,128)), 1, 1, PresetName[0+prgroup]);} + if(PresetFreq[1+prgroup]!=0){oled.drawTextButton(1, 190, 171,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(0,255,255)), 1, 1, PresetName[1+prgroup]);} + else{oled.drawTextButton(1, 190, 171,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(128,128,128)), 1, 1, PresetName[1+prgroup]);} + if(PresetFreq[2+prgroup]!=0){oled.drawTextButton(1, 190, 188,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(0,255,255)), 1, 1, PresetName[2+prgroup]);} + else{oled.drawTextButton(1, 190, 188,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(128,128,128)), 1, 1, PresetName[2+prgroup]);} + if(PresetFreq[3+prgroup]!=0){oled.drawTextButton(1, 190, 205,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(0,255,255)), 1, 1, PresetName[3+prgroup]);} + else{oled.drawTextButton(1, 190, 205,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(128,128,128)), 1, 1, PresetName[3+prgroup]);} + if(PresetFreq[4+prgroup]!=0){oled.drawTextButton(1, 190, 222,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(0,255,255)), 1, 1, PresetName[4+prgroup]);} + else{oled.drawTextButton(1, 190, 222,(oled.toRGB(0,100,100)),(FONT5X7),(oled.toRGB(128,128,128)), 1, 1, PresetName[4+prgroup]);} + oled.setTextBackgroundType (TEXT_OPAQUE); +} + +void setfreq() +{ + oled.setPenSize(0);oled.drawRectangle(176,16,80,14,oled.toRGB(0,0,0));oled.setPenSize(1); + Fl = strlen(freq); + if(Fl< 6){freq[Fl] = k;} + if (freq[0]!='1' && freq[0]!='8' && freq[0]!='9'){ + freq[0]='\0';} + oled.drawTextGraphic(176,16,(FONT12X16),freq, 1, 1, oled.toRGB(0,200,200)); + if (freq[0]=='8' || freq[0]=='9'){Fl=5;} + else{Fl=6;} + if(strlen(freq)==Fl){ + Freq = strtof (freq, NULL); + radio.Frequency(Freq); + memset(freq, '\0', sizeof(freq)); + } +} + +void Volume() +{ + if(v){volume++;} + if(!v){volume--;} + if(volume > 15){volume = 15;} + if(volume < 0){volume = 0;} + radio.Volume(volume); +} + +void Power() +{ + if(radio.power){ + radio.RDS(); + radio.processData(); + displayrefresh(); + rdstextgood=0; + radio.PowerOff(); + radio.processData(); + displayrefresh(); + led=0; + } + else{ + radio.PowerOn(); + radio.RDS(); + radio.Frequency(lastfreq); + radio.processData(); + } +} + +void flushbuffer() +{ + while (xbuf!=0 && ybuf!=0){oled.getTouch(&xbuf,&ybuf);} +} + + + + + + + + + +