Signal Generator

Dependencies:   IniManager RA8875 Watchdog mbed-rtos mbed

Fork of speaker_demo_Analog by jim hamblen

Revision:
6:1f48212fbaf9
Parent:
5:49dd0c647a40
--- a/SignalGenDisplay.cpp	Mon Jan 16 22:57:59 2017 +0000
+++ b/SignalGenDisplay.cpp	Sat May 20 19:52:23 2017 +0000
@@ -93,7 +93,7 @@
     { BTN_MODE_X+4*(BTN_W+BTN_S),BTN_MODE_Y,  BTN_MODE_X+4*(BTN_W+BTN_S)+BTN_W,BTN_MODE_Y+BTN_H },
 };
 static const int ModeCount = sizeof(ModeButtons)/sizeof(ModeButtons[0]);
-static const SG_Mode UI_ModeList[] = {
+static const SG_Waveform UI_ModeList[] = {
     SG_SINE,
     SG_SQUARE,
     SG_TRIANGLE,
@@ -317,6 +317,7 @@
                         for (int i=0; i<radio_CyclesCount; i++) {
                             if (lcd->Intersect(radio_Cycles[i], point)) {
                                 pulseMode = i;
+                                SaveSettings(OM_PULSE);
                                 signal->Stop();
                                 ShowCyclesControl();
                             }
@@ -346,7 +347,7 @@
         ini.ReadString("Signal", "Waveform", buf, sizeof(buf), ModeNames[0]);
         for (int i=0; i<ModeCount; i++) {
             if (strcmp(ModeNames[i], buf) == 0) {
-                mode = (SG_Mode)i;
+                mode = (SG_Waveform)i;
                 printf("Read ini mode is %d\r\n", mode);
                 break;
             }
@@ -761,7 +762,7 @@
     return ret;
 }
 
-bool SignalGenDisplay::SetWaveformMode(SG_Mode _mode, bool force) {
+bool SignalGenDisplay::SetWaveformMode(SG_Waveform _mode, bool force) {
     if (/* _mode >= SG_SINE && */ _mode <= SG_USER) {
         mode = _mode;
         printf("mode is %d\r\n", mode);
@@ -949,7 +950,7 @@
 //           .             |    |          \ /     /    |
 //            ++           +----+           +     +     +
 //
-void SignalGenDisplay::DrawWaveform(rect_t r, SG_Mode mode, color_t color, bool drawPure) {
+void SignalGenDisplay::DrawWaveform(rect_t r, SG_Waveform mode, color_t color, bool drawPure) {
     loc_t x,y;
     loc_t y0 = (r.p1.y + r.p2.y)/2;
     dim_t w = r.p2.x - r.p1.x;
@@ -1165,7 +1166,7 @@
     }
 }
 
-void SignalGenDisplay::DrawButton(rect_t r, bool pressed, SG_Mode mode, bool enable, int label) {
+void SignalGenDisplay::DrawButton(rect_t r, bool pressed, SG_Waveform mode, bool enable, int label) {
     rect_t wave;
     color_t buttonface = UI_BUTTON_FACE_DISABLED;
     color_t buttonshadow = UI_BUTTON_SHADOW_DISABLED;
@@ -1273,10 +1274,12 @@
         printf("SaveSettings - timeout [%02X]\r\n", Changes);
         if (Changes & OM_MODE) {
             Changes &= ~ OM_MODE;
+            printf("  Signal:Waveform=%s\r\n", ModeNames[mode]);
             ini.WriteString("Signal", "Waveform", ModeNames[mode]);
         }
         if (Changes & OM_PULSE) {
             Changes &= ~ OM_PULSE;
+            printf("  Signal:Pulse Mode=%s\r\n", PulseModeLabels[pulseMode]);
             ini.WriteString("Signal", "Pulse Mode", PulseModeLabels[pulseMode]);
         }
         if (Changes & OM_FREQ) {