Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 6:3a4e9ce12911
- Parent:
- 5:e785b9cd58c9
- Child:
- 7:33cb5f2db1ee
--- a/main.cpp Sun May 03 13:01:59 2020 +0000 +++ b/main.cpp Mon May 04 14:27:35 2020 +0000 @@ -12,19 +12,21 @@ */ /* TO DO: -string continues at line ends LEDS INSTALL -STICK INSTALL +pass variables between functions using pointers +menu starts select at item 0? */ // Includes #include "mbed.h" #include "Gamepad.h" #include "N5110.h" +#include "menu.h" // Objects Gamepad pad; N5110 lcd; +menu menu; Ticker down; Ticker period; @@ -36,17 +38,10 @@ void startup(); //void squareWave(); void wavetable(); -int mainmenu(); -void printmainmenu(); //void sinspeak(); //void down_isr(); //void up_isr(); -//Arrays for startup -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 @@ -64,7 +59,7 @@ printf("RUNNING CODE \n"); startup(); //initialises board and displays start screen wavetable(); //generates wavtable array - mainmenu(); //generates main menu + menu.mainmenu(lcd, pad); //generates main menu //pad.leds_on(); //squareWave(); //generates pulse wave modulated by sin wave //pad.leds_off(); @@ -81,11 +76,9 @@ lcd.clear(); lcd.setContrast(0.5); //contrast setting lcd.inverseMode(); //puts screen in -ve - //position for CARTSYNTH - const int x = 6; - const int y = 2; //Prints CART SYNTH to display - lcd.printString(CARTSYNTH,x,y); + lcd.printString("CART",12,2); + lcd.printString("SYNTH",32,3); lcd.refresh(); wait_ms(1800); //timer to allow theme to play out lcd.clear(); @@ -100,7 +93,6 @@ 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 @@ -109,26 +101,7 @@ 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() {