Luke Cartwright / Mbed 2 deprecated ELEC2645_Project_el18loc_nearlythere

Dependencies:   mbed

Revision:
7:33cb5f2db1ee
Parent:
6:3a4e9ce12911
Child:
8:f305ea78b2b1
diff -r 3a4e9ce12911 -r 33cb5f2db1ee main.cpp
--- a/main.cpp	Mon May 04 14:27:35 2020 +0000
+++ b/main.cpp	Tue May 05 14:32:04 2020 +0000
@@ -8,13 +8,17 @@
 Username: el18loc
 Student ID Number: 201225242
 Start Date: 06/02/2020
-Last Edited: 07/04/2020
+Last Edited: 04/05/2020
 */
 
 /* TO DO:
 LEDS INSTALL
 pass variables between functions using pointers
-menu starts select at item 0?
+Settings tab
+Other wavetables
+Generate sound
+ADSR
+Startup.h
 
 */
 // Includes
@@ -22,11 +26,15 @@
 #include "Gamepad.h"
 #include "N5110.h"
 #include "menu.h"
+#include "startup.h"
+#include "Front.h"
 
 // Objects
 Gamepad pad;
 N5110 lcd;
 menu menu;
+startup start;
+//Front front;
 Ticker down;
 Ticker period;
 
@@ -35,73 +43,32 @@
 Serial pc(USBTX, USBRX);
 
 //Functions
-void startup();
 //void squareWave();
-void wavetable();
 //void sinspeak();
 //void down_isr();
 //void up_isr();
 
 
 //Global Variables
-volatile double wavtable[4096]; //Wavetable array
 // all times drastically slowed to attempt debugging in teraterm
-float g_period = 0.002;
-float g_unused= g_period*1000000.0f;
-int g_period_us=g_unused;
-volatile uint64_t g_uptime_us = g_period_us/2; // placeholder value
+//float g_period = 0.002;
+//float g_unused= g_period*1000000.0f;
+//int g_period_us=g_unused;
+//volatile uint64_t g_uptime_us = g_period_us/2; // placeholder value
 //isr interrupt flags
-volatile int g_upflag=1;
-volatile int g_downflag=1;
+//volatile int g_upflag=1;
+//volatile int g_downflag=1;
 
 int main()
 {
     printf("RUNNING CODE \n");
-    startup(); //initialises board and displays start screen
-    wavetable(); //generates wavtable array
-    menu.mainmenu(lcd, pad); //generates main menu
-    //pad.leds_on();
+    start.initialise(lcd,pad); //initialises board and displays start screen
+    menu.mainmenu(lcd,pad);
+    //menu.mainmenu(lcd, pad); //generates main menu
     //squareWave(); //generates pulse wave modulated by sin wave
-    //pad.leds_off();
     //sinspeak();
 }
 
-
-void startup()
-{
-    pad.init(); //initiate Gamepad
-    pad.leds_on(); //turn LEDS on to show starting up
-    printf("Initialising Pad\n");
-    lcd.init(); //intitates screen
-    lcd.clear();
-    lcd.setContrast(0.5); //contrast setting
-    lcd.inverseMode(); //puts screen in -ve
-    //Prints CART SYNTH to display
-    lcd.printString("CART",12,2);
-    lcd.printString("SYNTH",32,3);
-    lcd.refresh();
-    wait_ms(1800); //timer to allow theme to play out
-    lcd.clear();
-    lcd.refresh(); //sets clear screen
-    pad.leds_off(); //turns of leds to show ready
-}
-
-
-void wavetable()
-{
-    double sin_d[4096];
-
-    pad.leds_on(); //shows computating (debug)
-    printf("Generating Wavetable \n");
-    for (int i=0; i<4096; i++) {
-        sin_d[i] = 0.5f*sin(2.0f*PI*(i/4096.0f));
-        wavtable[i]= sin_d[i]+0.5; //generates wave table 0<1 in double
-        //printf("wav[i]= %f \n", wavtable[i]); // Used for Debug
-    }
-    pad.leds_off();
-}
-
-
 /*
 void squareWave()
 {