Luke Cartwright / Mbed 2 deprecated ELEC2645_Project_el18loc_nearlythere

Dependencies:   mbed

Revision:
5:e785b9cd58c9
Parent:
4:9b7ea5528a5c
Child:
6:3a4e9ce12911
--- a/main.cpp	Tue Apr 07 18:56:28 2020 +0000
+++ b/main.cpp	Sun May 03 13:01:59 2020 +0000
@@ -11,6 +11,12 @@
 Last Edited: 07/04/2020
 */
 
+/* TO DO:
+string continues at line ends
+LEDS INSTALL
+STICK INSTALL
+
+*/
 // Includes
 #include "mbed.h"
 #include "Gamepad.h"
@@ -28,14 +34,19 @@
 
 //Functions
 void startup();
-void squareWave();
+//void squareWave();
 void wavetable();
+int mainmenu();
+void printmainmenu();
 //void sinspeak();
-void down_isr();
-void up_isr();
+//void down_isr();
+//void up_isr();
 
 //Arrays for startup
-const char CART[4] = {'C','A','R','T'};
+char CARTSYNTH[9] = {'C','A','R','T','S','Y','N','T','H'};
+char MAIN_MENU[9] = {'M','A','I','N',' ','M','E','N','U'};
+char Waveforms[9] = {'W','a','v','e','f','o','r','m','s'};
+char Credits[7] = {'C','r','e','d','i','t','s'};
 
 //Global Variables
 volatile double wavtable[4096]; //Wavetable array
@@ -53,8 +64,9 @@
     printf("RUNNING CODE \n");
     startup(); //initialises board and displays start screen
     wavetable(); //generates wavtable array
+    mainmenu(); //generates main menu
     //pad.leds_on();
-    squareWave(); //generates pulse wave modulated by sin wave
+    //squareWave(); //generates pulse wave modulated by sin wave
     //pad.leds_off();
     //sinspeak();
 }
@@ -69,11 +81,11 @@
     lcd.clear();
     lcd.setContrast(0.5); //contrast setting
     lcd.inverseMode(); //puts screen in -ve
-    //position for CART
-    const int x = 10;
+    //position for CARTSYNTH
+    const int x = 6;
     const int y = 2;
     //Prints CART SYNTH to display
-    lcd.printString(CART,x,y);
+    lcd.printString(CARTSYNTH,x,y);
     lcd.refresh();
     wait_ms(1800); //timer to allow theme to play out
     lcd.clear();
@@ -97,7 +109,27 @@
     pad.leds_off();
 }
 
+int mainmenu()
+{
+    printmainmenu();
 
+
+
+    return(1);
+}
+
+void printmainmenu()
+{
+    printf("Printing Main Menu \n");
+    lcd.clear();
+    lcd.printString(MAIN_MENU,3,0);
+    lcd.printString(Waveforms,3,1);
+    lcd.printString(Credits,3,2);
+    lcd.refresh();
+
+
+}
+/*
 void squareWave()
 {
     printf("Generating SIN PWM \n");
@@ -107,32 +139,32 @@
     float f=50; //frequency of sin wave produced
     period.attach_us(&up_isr,g_period_us); //ticker to write 1 to rca
     down.attach_us(&down_isr,g_uptime_us); //ticker to write 0 to rca
-    
-    
+
+
     printf("g_period_us: %d \n", g_period_us);
     printf("sin Frequency: %f \n", f);
 
     while (1) { //continual loop for pulse production
         float dutyratio = wavtable[i]; //calcualtes duty ratio of pulse
-        
+
         g_uptime_us= dutyratio*g_period_us; //calculates duty ratio in usecs
         if (g_uptime_us<1) {
             g_uptime_us=g_period_us/100;
             } //sets to be value for timebeing to eliminate 0 error
         //float f=440*(pad.read_pot1()+1); //removed for simplification
-        
+
         if (g_upflag==0) {
-            
+
             ifl = ifl + (4096*f*g_period); //once rca=1 itterate sin function
             if (ifl>4096) {
                 ifl= ifl-4096;
                 }
             i=ifl;
-            
+
             g_upflag=1; //reset flag
             //printf("iterate i: i= %d, ifl= %f \n", i, ifl);
         }
-        
+
         //printf("DR: %f \n",dutyratio);
         //printf("sleep \n");
         sleep(); //sleeps till next isr
@@ -160,7 +192,7 @@
     //printf("1 \n"); //only in while at v low frequency
 }
 
-
+*/
 /*
 void sinspeak ()
 {