Signal Generator

Dependencies:   IniManager RA8875 Watchdog mbed-rtos mbed

Fork of speaker_demo_Analog by jim hamblen

Revision:
3:d22f3e52d06a
Parent:
2:8f71b71fce1b
Child:
4:10281ddb673d
--- a/main.cpp	Sun Jan 15 03:11:22 2017 +0000
+++ b/main.cpp	Mon Jan 16 04:33:06 2017 +0000
@@ -2,24 +2,19 @@
 #include "mbed.h"
 #include "RA8875.h"
 #include "Watchdog.h"           // ver 2
-#include "IniManager.h"         // v19
+//#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";
-const char * BUILD_DATE = __DATE__ " " __TIME__;
-
 RA8875 lcd(p5,p6,p7,p12, NC, "tft");             // SPI:{MOSI,MISO,SCK,/ChipSelect,/reset}, name
-INI ini;
-SignalGenDAC g_signal(p18);
-
-SignalGenDisplay ui(&lcd, &g_signal, PROG_NAME, PROG_MANF, PROG_VERS, BUILD_DATE);
+//INI ini;
 
 RawSerial pc(USBTX, USBRX);
 LocalFileSystem local("local");
+SignalGenDAC g_signal(p18);
+SignalGenDisplay ui(&lcd, &g_signal);
+
 Watchdog wd;
 
 /* CPU Available indicator
@@ -27,53 +22,8 @@
 DigitalOut g_availableLed(LED1); //<! Led used to indicate the program is alive
 void AvailableLedIndicator(); //<! Ticker callback
 Ticker g_available;
- 
 
-// Calibrate the resistive touch screen, and store the data on the
-// local file system.
-//
-void CalibrateTS(void)
-{
-    FILE * fh;
-    tpMatrix_t matrix;
-    RetCode_t r;
-    Timer testperiod;
- 
-    r = lcd.TouchPanelCalibrate("Calibrate the touch panel", &matrix);
-    if (r == noerror) {
-        fh = fopen("/local/tpcal.cfg", "wb");
-        if (fh) {
-            fwrite(&matrix, sizeof(tpMatrix_t), 1, fh);
-            fclose(fh);
-            printf("  tp cal written.\r\n");
-            lcd.cls();
-        } else {
-            printf("  couldn't open tpcal file.\r\n");
-        }
-    } else {
-        printf("error return: %d\r\n", r);
-    }
-    lcd.cls();
-}
 
-// Try to load a previous resistive touch screen calibration from storage. If it
-// doesn't exist, activate the touch screen calibration process.
-//
-void InitTS(void)
-{
-    FILE * fh;
-    tpMatrix_t matrix;
-
-    fh = fopen("/local/tpcal.cfg", "rb");
-    if (fh) {
-        fread(&matrix, sizeof(tpMatrix_t), 1, fh);
-        fclose(fh);
-        lcd.TouchPanelSetMatrix(&matrix);
-        printf("  tp cal loaded.\r\n");
-    } else {
-        CalibrateTS();
-    }
-}
 
 
 
@@ -81,31 +31,17 @@
  */
 int main() {
     pc.baud(460800);
-    pc.printf("\r\n%s %s\r\n", PROG_NAME, BUILD_DATE);
 
     if (wd.WatchdogCausedReset()) {
         pc.printf("**** Watchdog Event caused reset ****\r\n");
     }
-    // Set very long timeout because the <PrintScreen> function is incredibly slow with local filesystem...
-//    wd.Configure(120.0);   // This is forever for real-time embedded, but for a casual network appliance...
-    ini.SetFile("/local/SigGen.ini", 2);
+    wd.Configure(30.0);
+    //ini.SetFile("/local/SigGen.ini", 2);
 
-    // Bring the LCD online
-    lcd.frequency(2000000);
     lcd.init(480,272,16, true, true, true);
-    lcd.TouchPanelInit();
-    InitTS();
-    
-    // Bring the signal generator online
-    ui.Refresh();
-    
-    wait(1); // Needed after startup
-    
-    ui.ShowMenu();
-    // Start infinite loop
-    while(true)
+    while (true)
     {
-//        wd.Service();
+        wd.Service();
         if (pc.readable()) {
             int c = pc.getc();
             ui.Poll(c);