Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EFM32_CapSenseSlider EFM32_SegmentLCD RDA5807M mbed-src
Revision 4:3bf9d70a48c8, committed 2015-06-19
- Comitter:
- star297
- Date:
- Fri Jun 19 19:24:01 2015 +0000
- Parent:
- 3:1220287bcbd7
- Commit message:
- RDS text update
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 1220287bcbd7 -r 3bf9d70a48c8 main.cpp
--- a/main.cpp Fri Jun 19 16:38:34 2015 +0000
+++ b/main.cpp Fri Jun 19 19:24:01 2015 +0000
@@ -1,7 +1,7 @@
/*
RDA5807M FM RDS Radio using the EFM32 Gecko Segment LCD
RDS information is displayed using a PC terminal
-
+
Use:
switches PB0 and PB1 for frequency search
Volume controlled by the Touch Slider
@@ -10,43 +10,48 @@
Stereo received - Antenna Segment Display
RDS available - LED0
*/
-
+
#include "mbed.h"
#include "RDA5807M.h"
#include "EFM32_SegmentLCD.h"
#include "EFM32_CapSenseSlider.h"
-
+
RDA5807M radio(PC4, PC5); // sda - scl
-
+
Serial pc(USBTX, USBRX);
-
+
InterruptIn scan_up(SW1);
InterruptIn scan_down(SW0);
-
+
DigitalOut led1(LED1);
DigitalOut led0(LED0);
-
+
silabs::EFM32_SegmentLCD segmentDisplay;
silabs::EFM32_CapSenseSlider capSlider;
-
+LowPowerTimeout wakeup;
+
Timer t1;
-int x,n,i,l,signal,lastsignal,volume,laststereo;
+int x,n,i,l,wake,signal,lastsignal,volume,laststereo;
float lastfreq;
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();
-
+
+void displayrefresh(),getrds(),RTrefresh();
+
void scan_upIRQ() {
radio.SeekUp();
}
-
+
void scan_downIRQ() {
radio.SeekDown();
}
+void callback(void) {
+ wake = 1;
+}
+
void slideCallback(void) {
volume = capSlider.get_position()/3;
if(volume > 15){volume = 15;}
@@ -58,7 +63,7 @@
}
int main() {
-
+
radio.Reset(); // reset and power up radio chip
segmentDisplay.Write("RdA5807");
wait(1);
@@ -74,12 +79,15 @@
while(1){
radio.ProcessData();
displayrefresh();
- getrds();
- wait_ms(50);
- if(t1.read()>3){strcpy(lastStationName," ");t1.stop();}
+ getrds();
+ if(t1.read()>3){strcpy(lastStationName," ");t1.stop();}
+ wait_ms(1);
+ wakeup.attach(callback, 0.05f); // MCU average power now 1mA
+ wake = 0;
+ while(!wake) sleep();
}
}
-
+
void displayrefresh()
{
if (strcmp(lastStationName, radio.StationName) != 0){
@@ -122,6 +130,17 @@
lastsignal=radio.signal;
}
if(strcmp(RDStxt1, lasttext1) != 0 || strcmp(RDStxt2, lasttext2) != 0){
+ RTrefresh();
+ }
+ if(strcmp(lastCT, radio.CTtime) !=0){
+ pc.printf("Time: %s\n",radio.CTtime);
+ strcpy(lastCT,radio.CTtime);
+ if(led0==1){RTrefresh();}
+ }
+}
+
+void RTrefresh()
+{
pc.printf("\n-------------------------------------------\n");
pc.printf("Station:\n%s\n\n",Station);
pc.printf("RT:\n%s\n",RDStxt1);
@@ -130,13 +149,8 @@
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)>3){
@@ -168,6 +182,4 @@
x=0;
}
}
-}
-
-
+}
\ No newline at end of file