Signal Generator

Dependencies:   IniManager RA8875 Watchdog mbed-rtos mbed

Fork of speaker_demo_Analog by jim hamblen

Revision:
2:8f71b71fce1b
Parent:
1:dd07e1deec6c
Child:
3:d22f3e52d06a
--- a/main.cpp	Fri Jan 13 12:33:37 2017 +0000
+++ b/main.cpp	Sun Jan 15 03:11:22 2017 +0000
@@ -1,10 +1,12 @@
 
 #include "mbed.h"
-#include "SignalGenDisplay.h"
 #include "RA8875.h"
 #include "Watchdog.h"           // ver 2
 #include "IniManager.h"         // v19
 
+#include "SignalGenDisplay.h"
+#include "SignalGenDAC.h"
+
 const char * PROG_MANF = "Smartware Computing";
 const char * PROG_NAME = "Signal Generator";
 const char * PROG_VERS = "0.01";
@@ -12,7 +14,7 @@
 
 RA8875 lcd(p5,p6,p7,p12, NC, "tft");             // SPI:{MOSI,MISO,SCK,/ChipSelect,/reset}, name
 INI ini;
-SignalGenerator g_signal(p18);
+SignalGenDAC g_signal(p18);
 
 SignalGenDisplay ui(&lcd, &g_signal, PROG_NAME, PROG_MANF, PROG_VERS, BUILD_DATE);
 
@@ -26,12 +28,6 @@
 void AvailableLedIndicator(); //<! Ticker callback
 Ticker g_available;
  
-/* SignalGenerator usage
- */
-void SynchronousUserInput(); //<! Ticker callback
-Ticker g_synchronousUserInput;
-
-
 
 // Calibrate the resistive touch screen, and store the data on the
 // local file system.
@@ -98,22 +94,13 @@
     lcd.frequency(2000000);
     lcd.init(480,272,16, true, true, true);
     lcd.TouchPanelInit();
-    int bl = ini.ReadLongInt("Settings", "Backlight", 80);
-    lcd.Backlight_u8(bl);
     InitTS();
     
     // Bring the signal generator online
-    ui.Init();
+    ui.Refresh();
     
-    //volatile SignalGenerator::SignalGeneratorType _choice; //<! User selects the desired signal type
-    //volatile int frequency; //<! Signal frequency
- 
     wait(1); // Needed after startup
     
-    // Launch available indicator
-    g_availableLed = 1;
-    g_available.attach(&AvailableLedIndicator, 2.0); // Never detached
-
     ui.ShowMenu();
     // Start infinite loop
     while(true)
@@ -125,44 +112,7 @@
         } else {
             ui.Poll();
         }
-#if 0
-        // Acquire settings
-        //_choice = DisplaySignalGeneratorTestMenuAndGetChoice();
-        printf("\r\nEnter signal frequency (< 1MHz/# of samples): ");
-        scanf("%d", &frequency);
-        
-        // Prepare the signal
-        g_signal.SetSignalFrequency(_choice, frequency);
-
-        // Launch execution
-        if (g_signal.BeginRunAsync() == -1) {
-            // Synchronous mode
-            g_synchronousUserInput.attach(&SynchronousUserInput, 0.005); // 5ms
-            g_signal.Run(); // Never stopped
-            printf("\r\nSignal Generator terminated\r\n");
-            g_synchronousUserInput.detach();
-        } else {
-            // Asynchronous mode
-            printf("\r\n\r\nPress 'q' to terminate\r\n");
-            while (getchar() != 'q');
-            g_signal.EndRunAsync();
-        }
-#endif
     } // End of 'while' statement
 } // End of main program
  
-/** Callbak used by CPU availabe ticker to indicate the program is alive
- */
-void AvailableLedIndicator() {
-    g_availableLed != g_availableLed;
-} // End of function AvailableLedIndicator
- 
-/** Callbak used when SignalLibrary is used in synchronous mode (Run() method)
- */
-void SynchronousUserInput() {
-    if (pc.readable()) {
-        g_signal.Stop();
-        getchar();
-    }
-} // End of function SynchronousUserInput
- 
+