RDA5807M FM RDS radio using the Gecko Segment LCD display. PC serial is used to display the RDS text on a pc terminal program if required (115200 baud). The two press buttons to tune up or down, touch slider to change volume. Top numeric displays frequency, bottom alpha displays station name. Ring segment displays signal level, antenna segment indicates stereo received.
Dependencies: EFM32_CapSenseSlider EFM32_SegmentLCD RDA5807M mbed-src
Revision 3:1220287bcbd7, committed 2015-06-19
- Comitter:
- star297
- Date:
- Fri Jun 19 16:38:34 2015 +0000
- Parent:
- 2:893e9004c547
- Child:
- 4:3bf9d70a48c8
- Commit message:
- Added CT time.
Changed in this revision
--- a/RDA5807M.lib Sat May 23 14:48:15 2015 +0000 +++ b/RDA5807M.lib Fri Jun 19 16:38:34 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/star297/code/RDA5807M/#cf256181972f +http://developer.mbed.org/users/star297/code/RDA5807M/#3e7968bd455d
--- a/main.cpp Sat May 23 14:48:15 2015 +0000 +++ b/main.cpp Fri Jun 19 16:38:34 2015 +0000 @@ -32,10 +32,10 @@ Timer t1; -int n,i,l,signal,lastsignal,volume,lastrds,laststereo,rdstextgood; +int x,n,i,l,signal,lastsignal,volume,laststereo; float lastfreq; -char Station[10],lastStationName[10],vol[4]; -char RDStxt[70],RDStxt1[70],RDStxt2[70],text1[50],lasttext1[50],text2[50],lasttext2[50]; +char Station[10],lastStationName[10],vol[4],lastCT[12]; +char RDStxt[70],RDStxt1[70],RDStxt2[70],text1[70],lasttext1[70],text2[70],lasttext2[70]; void displayrefresh(),getrds(); @@ -72,7 +72,7 @@ wait(1); while(1){ - radio.processData(); + radio.ProcessData(); displayrefresh(); getrds(); wait_ms(50); @@ -91,6 +91,7 @@ } } segmentDisplay.Write(Station); + pc.printf("Station:\n%s\n\n",Station); strcpy(lastStationName,radio.StationName); } } @@ -99,7 +100,7 @@ segmentDisplay.Number(radio.freq/10);segmentDisplay.Symbol(LCD_SYMBOL_DP10,1); } else {segmentDisplay.Number(radio.freq/100);segmentDisplay.Symbol(LCD_SYMBOL_DP10,0);} - rdstextgood=0;lastrds=!lastrds; + led0=0; } if(laststereo != radio.stereo){ if(radio.stereo){segmentDisplay.Symbol(LCD_SYMBOL_ANT,1);} @@ -120,54 +121,53 @@ if(signal>40){segmentDisplay.ARing(7, 1);} lastsignal=radio.signal; } - if(lastrds != radio.rds){ - if(radio.rds){ - if(rdstextgood){led0=1;} - else{led0=0;} - } - else{led0=0;rdstextgood=0;} - lastrds=radio.rds; - } - if (strcmp(text1, lasttext1) != 0){ - pc.printf(Station); - pc.printf("\n %s\n",text1); - memset(lasttext1, '\0', sizeof(lasttext1));strcpy(lasttext1, text1);} - if (strcmp(text2, lasttext2) != 0){ - pc.printf(" %s\n\n",text2); - memset(lasttext2, '\0', sizeof(lasttext2));strcpy(lasttext2, text2);} + if(strcmp(RDStxt1, lasttext1) != 0 || strcmp(RDStxt2, lasttext2) != 0){ + pc.printf("\n-------------------------------------------\n"); + pc.printf("Station:\n%s\n\n",Station); + pc.printf("RT:\n%s\n",RDStxt1); + pc.printf("%s\n\n",RDStxt2); + pc.printf("Time: %s\n",radio.CTtime); + memset(lasttext1, '\0', sizeof(lasttext1));strcpy(lasttext1, RDStxt1); + memset(lasttext2, '\0', sizeof(lasttext2));strcpy(lasttext2, RDStxt2); + led0=1; + } + if(strcmp(lastCT, radio.CTtime) !=0){ + pc.printf("Time: %s\n",radio.CTtime); + strcpy(lastCT,radio.CTtime); + } } void getrds() { - if(strlen(radio.RDSText)==64 && signal>23){ - memset(text1, '\0', sizeof(text1)); - memset(text2, '\0', sizeof(text2)); - if(!rdstextgood){rdstextgood=1;lastrds=!lastrds;} - // remove non-printable ASCCi error characters - n=0; - for(i=0;i<(64);i++){ - if(radio.RDSText[i] > 31){ - RDStxt[n] = radio.RDSText[i]; - n++; - } - } - // slit into 2 lines of text seperated by 'space' - strcpy(RDStxt1,RDStxt); + if(strlen(radio.RDSText)>3){ + memset(RDStxt1, '\0', sizeof(RDStxt1)); + memset(RDStxt2, '\0', sizeof(RDStxt2)); + + // format into 2 lines of text seperated by first 'space' after 30 characters + strcpy(RDStxt1,radio.RDSText); + n=strlen(RDStxt1); for ( i = 0; i < (n); i++ ){ if (i>30 && (RDStxt1[i] == ' ') ){ RDStxt1 [strlen(RDStxt1) - (n-i)] = '\0'; l=strlen(RDStxt1); - i=n; - } } - strcpy (RDStxt2, RDStxt + l); - while(RDStxt2[0]==' '){ - strcpy (RDStxt2, (RDStxt2 + 1)); + x=1; + break; // break if more than 30 characters with space + } + if(i>39){ + RDStxt1 [strlen(RDStxt1) - (n-i)] = '\0'; + l=strlen(RDStxt1); + x=1; + break; //break if more than 39 characters with no spaces + } } - if(strlen(RDStxt1)<40){strcpy (text1, RDStxt1);} - if(strlen(RDStxt2)<40){strcpy (text2, RDStxt2);} - - memset(radio.RDSText, '\0', sizeof(radio.RDSText)); - } + if(x==1){ + strcpy (RDStxt2, radio.RDSText + l); + while(RDStxt2[0]==' '){ + strcpy (RDStxt2, (RDStxt2 + 1)); + } + x=0; + } + } }
--- a/mbed-src.lib Sat May 23 14:48:15 2015 +0000 +++ b/mbed-src.lib Fri Jun 19 16:38:34 2015 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/mbed_official/code/mbed-src/#7f313a59e20c +http://developer.mbed.org/users/mbed_official/code/mbed-src/#8e5b2476066a