ELEC2645 (2019/20) / Mbed 2 deprecated el18loc_final

Dependencies:   mbed

Committer:
lukeocarwright
Date:
Tue May 26 10:17:47 2020 +0000
Revision:
30:08cc4ec58d07
Parent:
29:207111ffd6e6
Child:
31:cfdb014ff086
Sorted Settings Menu Final Touches. More Code Tidying.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lukeocarwright 8:f305ea78b2b1 1 #include "mbed.h"
lukeocarwright 8:f305ea78b2b1 2 #include "Menu.h"
lukeocarwright 8:f305ea78b2b1 3
lukeocarwright 29:207111ffd6e6 4 //Global Variables
lukeocarwright 29:207111ffd6e6 5 volatile int g_mainmenu_flag;
lukeocarwright 8:f305ea78b2b1 6 //objects
lukeocarwright 8:f305ea78b2b1 7 Front front;
lukeocarwright 8:f305ea78b2b1 8
lukeocarwright 8:f305ea78b2b1 9 //constructor/destructor
lukeocarwright 8:f305ea78b2b1 10 Menu::Menu()
lukeocarwright 8:f305ea78b2b1 11 {
lukeocarwright 8:f305ea78b2b1 12 }
lukeocarwright 8:f305ea78b2b1 13 Menu::~Menu()
lukeocarwright 8:f305ea78b2b1 14 {
lukeocarwright 8:f305ea78b2b1 15 }
lukeocarwright 8:f305ea78b2b1 16
lukeocarwright 8:f305ea78b2b1 17 // PUBLIC methods---------------------------------------------------------------
lukeocarwright 8:f305ea78b2b1 18 void Menu::mainmenu(N5110 &lcd, Gamepad &pad) //main menu
lukeocarwright 8:f305ea78b2b1 19 {
lukeocarwright 29:207111ffd6e6 20 g_mainmenu_flag=0; //Globals Init
lukeocarwright 8:f305ea78b2b1 21 g_selecty=10;
lukeocarwright 29:207111ffd6e6 22 submenu=menuflag=1; //Variables Init
lukeocarwright 29:207111ffd6e6 23 menusize=4;
lukeocarwright 8:f305ea78b2b1 24 printmainmenu(lcd); //prints menu to display
lukeocarwright 29:207111ffd6e6 25 pad.reset_buttons();//elimnates Prev Button Press
lukeocarwright 8:f305ea78b2b1 26 while (menuflag==1) {
lukeocarwright 13:27300c533dd1 27 s=scroll(lcd, pad, submenu, menusize);
lukeocarwright 8:f305ea78b2b1 28 if (s==1) {
lukeocarwright 8:f305ea78b2b1 29 printmainmenu(lcd);
lukeocarwright 13:27300c533dd1 30 submenu++;
lukeocarwright 13:27300c533dd1 31 wait_ms(200);
lukeocarwright 13:27300c533dd1 32 }
lukeocarwright 13:27300c533dd1 33 if (s==-1) {
lukeocarwright 13:27300c533dd1 34 printmainmenu(lcd);
lukeocarwright 13:27300c533dd1 35 submenu--;
lukeocarwright 13:27300c533dd1 36 wait_ms(200);
lukeocarwright 8:f305ea78b2b1 37 }
lukeocarwright 8:f305ea78b2b1 38 if ( pad.A_pressed()) { //selects
lukeocarwright 8:f305ea78b2b1 39 // printf("A pressed\n");
lukeocarwright 29:207111ffd6e6 40 //printf("SubMenu %d selected\n", submenu);
lukeocarwright 8:f305ea78b2b1 41 wait_ms(200); //debounce
lukeocarwright 8:f305ea78b2b1 42 menuflag=0;
lukeocarwright 8:f305ea78b2b1 43 }
lukeocarwright 8:f305ea78b2b1 44 }
lukeocarwright 29:207111ffd6e6 45 switch (submenu) {
lukeocarwright 29:207111ffd6e6 46 case 1:
lukeocarwright 29:207111ffd6e6 47 subwaveforms(lcd,pad);
lukeocarwright 29:207111ffd6e6 48 case 2:
lukeocarwright 8:f305ea78b2b1 49 subinstructions(lcd,pad);
lukeocarwright 29:207111ffd6e6 50 case 3:
lukeocarwright 29:207111ffd6e6 51 subsettings(lcd,pad);
lukeocarwright 29:207111ffd6e6 52 case 4:
lukeocarwright 29:207111ffd6e6 53 subcredits(lcd,pad);
lukeocarwright 8:f305ea78b2b1 54 }
lukeocarwright 8:f305ea78b2b1 55 }
lukeocarwright 8:f305ea78b2b1 56
lukeocarwright 13:27300c533dd1 57 void Menu::subwaveforms(N5110 &lcd, Gamepad &pad) //waveforms sub
lukeocarwright 8:f305ea78b2b1 58 {
lukeocarwright 29:207111ffd6e6 59 while (1) {
lukeocarwright 29:207111ffd6e6 60 g_selecty=10; //initialises Global var
lukeocarwright 29:207111ffd6e6 61 submenu=menuflag=1; //initialises Variables
lukeocarwright 29:207111ffd6e6 62 menusize=3;
lukeocarwright 29:207111ffd6e6 63 //printf("Waveforms menu \n"); //Debug
lukeocarwright 29:207111ffd6e6 64 printsubwaveforms(lcd);
lukeocarwright 29:207111ffd6e6 65 pad.reset_buttons();
lukeocarwright 29:207111ffd6e6 66 while (menuflag==1) { //looped
lukeocarwright 29:207111ffd6e6 67 s=scroll(lcd,pad,submenu,menusize);
lukeocarwright 29:207111ffd6e6 68 if (s==1) {
lukeocarwright 29:207111ffd6e6 69 printsubwaveforms(lcd);
lukeocarwright 29:207111ffd6e6 70 submenu++;
lukeocarwright 29:207111ffd6e6 71 wait_ms(200);
lukeocarwright 29:207111ffd6e6 72 }
lukeocarwright 29:207111ffd6e6 73 if (s==-1) {
lukeocarwright 29:207111ffd6e6 74 printsubwaveforms(lcd);
lukeocarwright 29:207111ffd6e6 75 submenu--;
lukeocarwright 29:207111ffd6e6 76 wait_ms(200);
lukeocarwright 29:207111ffd6e6 77 }
lukeocarwright 29:207111ffd6e6 78 if (pad.A_pressed()) { //Select
lukeocarwright 29:207111ffd6e6 79 //printf("Submenu: %d selected\n", submenu); //debug
lukeocarwright 29:207111ffd6e6 80 wait_ms(200); //debounce
lukeocarwright 29:207111ffd6e6 81 menuflag=0; //sets flag
lukeocarwright 29:207111ffd6e6 82 }
lukeocarwright 29:207111ffd6e6 83 if (pad.B_pressed()) { //go back menu
lukeocarwright 29:207111ffd6e6 84 //printf("Main Menu selected\n"); //debug
lukeocarwright 29:207111ffd6e6 85 submenu=0;
lukeocarwright 29:207111ffd6e6 86 wait_ms(200); //debounce
lukeocarwright 29:207111ffd6e6 87 menuflag=0; //sets flag
lukeocarwright 29:207111ffd6e6 88 }
lukeocarwright 8:f305ea78b2b1 89 }
lukeocarwright 29:207111ffd6e6 90 if(submenu==0) { //allows main selected
lukeocarwright 29:207111ffd6e6 91 mainmenu(lcd,pad);
lukeocarwright 29:207111ffd6e6 92 break;
lukeocarwright 8:f305ea78b2b1 93 }
lukeocarwright 29:207111ffd6e6 94 if(submenu>=1) { //allows waveform selected
lukeocarwright 29:207111ffd6e6 95 front.frontrun(lcd,pad,submenu);
lukeocarwright 8:f305ea78b2b1 96 }
lukeocarwright 8:f305ea78b2b1 97 mainmenu(lcd,pad);
lukeocarwright 29:207111ffd6e6 98 break;
lukeocarwright 8:f305ea78b2b1 99 }
lukeocarwright 8:f305ea78b2b1 100 }
lukeocarwright 8:f305ea78b2b1 101
lukeocarwright 8:f305ea78b2b1 102 void Menu::subinstructions(N5110 &lcd, Gamepad &pad) //instruction sub
lukeocarwright 8:f305ea78b2b1 103 {
lukeocarwright 8:f305ea78b2b1 104 menuflag=1; //sets flag
lukeocarwright 29:207111ffd6e6 105 //printf("Instructions menu \n");
lukeocarwright 8:f305ea78b2b1 106 lcd.clear();
lukeocarwright 29:207111ffd6e6 107 lcd.printString("Instructions:",2,0);
lukeocarwright 29:207111ffd6e6 108 lcd.printString("See attached",3,1);
lukeocarwright 29:207111ffd6e6 109 lcd.printString("User Manual",3,2);
lukeocarwright 16:14c231624f3e 110 pad.reset_buttons();
lukeocarwright 29:207111ffd6e6 111 lcd.refresh();
lukeocarwright 8:f305ea78b2b1 112 while (menuflag==1) {
lukeocarwright 8:f305ea78b2b1 113 if (pad.B_pressed()) {
lukeocarwright 8:f305ea78b2b1 114 // printf("B pressed\n");
lukeocarwright 8:f305ea78b2b1 115 printf("Main Menu selected\n");
lukeocarwright 8:f305ea78b2b1 116 submenu=0;
lukeocarwright 8:f305ea78b2b1 117 wait_ms(200); //debounce
lukeocarwright 8:f305ea78b2b1 118 menuflag=0; //sets flag
lukeocarwright 8:f305ea78b2b1 119 }
lukeocarwright 8:f305ea78b2b1 120 }
lukeocarwright 8:f305ea78b2b1 121 if(submenu==0) { //allows main menu select
lukeocarwright 8:f305ea78b2b1 122 mainmenu(lcd,pad);
lukeocarwright 8:f305ea78b2b1 123 }
lukeocarwright 8:f305ea78b2b1 124 }
lukeocarwright 8:f305ea78b2b1 125
lukeocarwright 8:f305ea78b2b1 126 void Menu::subcredits(N5110 &lcd, Gamepad &pad) //credits sub menu
lukeocarwright 8:f305ea78b2b1 127 {
lukeocarwright 29:207111ffd6e6 128 //printf("Credits \n");
lukeocarwright 8:f305ea78b2b1 129 lcd.clear();
lukeocarwright 8:f305ea78b2b1 130 lcd.printString("Credits",22,0); //prints credits to screen
lukeocarwright 8:f305ea78b2b1 131 lcd.printString("Coded,Produced",0,1);
lukeocarwright 8:f305ea78b2b1 132 lcd.printString("+ Built by",10,2);
lukeocarwright 8:f305ea78b2b1 133 lcd.printString("Luke",30,3);
lukeocarwright 8:f305ea78b2b1 134 lcd.printString("Cartwright",13,4);
lukeocarwright 8:f305ea78b2b1 135 lcd.refresh(); //refresh buffer
lukeocarwright 8:f305ea78b2b1 136 menuflag=1; //sets flag
lukeocarwright 16:14c231624f3e 137 pad.reset_buttons();
lukeocarwright 8:f305ea78b2b1 138 while (menuflag==1) {
lukeocarwright 8:f305ea78b2b1 139 if (pad.B_pressed()) { //go back menu
lukeocarwright 29:207111ffd6e6 140 //printf("Main Menu selected\n");
lukeocarwright 8:f305ea78b2b1 141 submenu=0;
lukeocarwright 8:f305ea78b2b1 142 wait_ms(200); //debounce
lukeocarwright 8:f305ea78b2b1 143 menuflag=0; //sets flag
lukeocarwright 8:f305ea78b2b1 144 }
lukeocarwright 8:f305ea78b2b1 145 }
lukeocarwright 8:f305ea78b2b1 146 if(submenu==0) { //back to main
lukeocarwright 8:f305ea78b2b1 147 mainmenu(lcd,pad);
lukeocarwright 8:f305ea78b2b1 148 }
lukeocarwright 8:f305ea78b2b1 149 }
lukeocarwright 29:207111ffd6e6 150
lukeocarwright 16:14c231624f3e 151 void Menu::subsettings(N5110 &lcd, Gamepad &pad)
lukeocarwright 16:14c231624f3e 152 {
lukeocarwright 29:207111ffd6e6 153 g_selecty=10;
lukeocarwright 29:207111ffd6e6 154 submenu=menuflag=1; //initialises Variables
lukeocarwright 30:08cc4ec58d07 155 menusize=4;
lukeocarwright 29:207111ffd6e6 156 //printf("Settings menu \n");
lukeocarwright 16:14c231624f3e 157 printsubsettings(lcd);
lukeocarwright 16:14c231624f3e 158 pad.reset_buttons();
lukeocarwright 16:14c231624f3e 159 while (menuflag==1) { //looped
lukeocarwright 16:14c231624f3e 160 s=scroll(lcd,pad,submenu,menusize);
lukeocarwright 16:14c231624f3e 161 if (s==1) {
lukeocarwright 16:14c231624f3e 162 printsubsettings(lcd);
lukeocarwright 16:14c231624f3e 163 submenu++;
lukeocarwright 16:14c231624f3e 164 wait_ms(200);
lukeocarwright 16:14c231624f3e 165 }
lukeocarwright 16:14c231624f3e 166 if (s==-1) {
lukeocarwright 16:14c231624f3e 167 printsubsettings(lcd);
lukeocarwright 16:14c231624f3e 168 submenu--;
lukeocarwright 16:14c231624f3e 169 wait_ms(200);
lukeocarwright 16:14c231624f3e 170 }
lukeocarwright 16:14c231624f3e 171 if (pad.A_pressed()) { //go back menu
lukeocarwright 29:207111ffd6e6 172 //printf("Submenu: %d selected\n", submenu); //debug
lukeocarwright 16:14c231624f3e 173 wait_ms(200); //debounce
lukeocarwright 16:14c231624f3e 174 menuflag=0; //sets flag
lukeocarwright 16:14c231624f3e 175 }
lukeocarwright 16:14c231624f3e 176 if (pad.B_pressed()) { //go back menu
lukeocarwright 29:207111ffd6e6 177 //printf("Main Menu selected\n"); //debug
lukeocarwright 16:14c231624f3e 178 submenu=0;
lukeocarwright 16:14c231624f3e 179 wait_ms(200); //debounce
lukeocarwright 16:14c231624f3e 180 menuflag=0; //sets flag
lukeocarwright 16:14c231624f3e 181 }
lukeocarwright 16:14c231624f3e 182 }
lukeocarwright 29:207111ffd6e6 183 switch (submenu) {
lukeocarwright 29:207111ffd6e6 184 case 0:
lukeocarwright 29:207111ffd6e6 185 mainmenu(lcd,pad);
lukeocarwright 29:207111ffd6e6 186 case 1:
lukeocarwright 29:207111ffd6e6 187 volumerun(lcd,pad);
lukeocarwright 29:207111ffd6e6 188 case 2:
lukeocarwright 30:08cc4ec58d07 189 backlightrun(lcd,pad);
lukeocarwright 29:207111ffd6e6 190 case 3:
lukeocarwright 29:207111ffd6e6 191 contrastrun(lcd,pad);
lukeocarwright 30:08cc4ec58d07 192 case 4:
lukeocarwright 30:08cc4ec58d07 193 inverse_mode(lcd,pad);
lukeocarwright 16:14c231624f3e 194 }
lukeocarwright 16:14c231624f3e 195 }
lukeocarwright 16:14c231624f3e 196
lukeocarwright 16:14c231624f3e 197 void Menu::volumerun(N5110 &lcd, Gamepad &pad)
lukeocarwright 17:358987e9f30e 198 {
lukeocarwright 29:207111ffd6e6 199 //printf("Volume Settings \n");
lukeocarwright 16:14c231624f3e 200 menuflag=1; //sets flag
lukeocarwright 16:14c231624f3e 201 lcd.clear();
lukeocarwright 16:14c231624f3e 202 lcd.printString("Volume:",3,0);
lukeocarwright 29:207111ffd6e6 203 lcd.printString("Use screw",3,1);
lukeocarwright 29:207111ffd6e6 204 lcd.printString("potentiometer",3,2);
lukeocarwright 29:207111ffd6e6 205 lcd.printString("on rear",3,3);
lukeocarwright 29:207111ffd6e6 206 lcd.refresh();
lukeocarwright 16:14c231624f3e 207 pad.reset_buttons();
lukeocarwright 16:14c231624f3e 208 while (menuflag==1) {
lukeocarwright 16:14c231624f3e 209 if (pad.B_pressed()) {
lukeocarwright 16:14c231624f3e 210 // printf("B pressed\n");
lukeocarwright 16:14c231624f3e 211 printf("Main Menu selected\n");
lukeocarwright 16:14c231624f3e 212 submenu=0;
lukeocarwright 16:14c231624f3e 213 wait_ms(200); //debounce
lukeocarwright 16:14c231624f3e 214 menuflag=0; //sets flag
lukeocarwright 16:14c231624f3e 215 }
lukeocarwright 16:14c231624f3e 216 }
lukeocarwright 16:14c231624f3e 217 if(submenu==0) { //allows main menu select
lukeocarwright 16:14c231624f3e 218 subsettings(lcd,pad);
lukeocarwright 16:14c231624f3e 219 }
lukeocarwright 16:14c231624f3e 220 }
lukeocarwright 16:14c231624f3e 221
lukeocarwright 30:08cc4ec58d07 222 void Menu::inverse_mode(N5110 &lcd, Gamepad &pad)
lukeocarwright 16:14c231624f3e 223 {
lukeocarwright 16:14c231624f3e 224 lcd.clear();
lukeocarwright 30:08cc4ec58d07 225 lcd.printString("Inverse Mode:",3,0);
lukeocarwright 30:08cc4ec58d07 226 lcd.printString("Press A to",3,1);
lukeocarwright 30:08cc4ec58d07 227 lcd.printString("toggle",3,2);
lukeocarwright 30:08cc4ec58d07 228 lcd.refresh();
lukeocarwright 30:08cc4ec58d07 229 menuflag=1;
lukeocarwright 30:08cc4ec58d07 230 toggle=true;
lukeocarwright 16:14c231624f3e 231 while (menuflag==1) {
lukeocarwright 30:08cc4ec58d07 232 if (pad.A_pressed()) {
lukeocarwright 30:08cc4ec58d07 233 if (toggle==true) {
lukeocarwright 30:08cc4ec58d07 234 lcd.normalMode();
lukeocarwright 30:08cc4ec58d07 235 toggle=false;
lukeocarwright 30:08cc4ec58d07 236 } else if (toggle==false) {
lukeocarwright 30:08cc4ec58d07 237 lcd.inverseMode();
lukeocarwright 30:08cc4ec58d07 238 toggle=true;
lukeocarwright 30:08cc4ec58d07 239 }
lukeocarwright 30:08cc4ec58d07 240 wait_ms(500);//debounce
lukeocarwright 30:08cc4ec58d07 241 }
lukeocarwright 30:08cc4ec58d07 242 if (pad.B_pressed()) {
lukeocarwright 30:08cc4ec58d07 243 menuflag=0;
lukeocarwright 16:14c231624f3e 244 }
lukeocarwright 16:14c231624f3e 245 }
lukeocarwright 30:08cc4ec58d07 246 wait_ms(500);//debounce
lukeocarwright 30:08cc4ec58d07 247 pad.reset_buttons();
lukeocarwright 30:08cc4ec58d07 248 subsettings(lcd,pad);
lukeocarwright 16:14c231624f3e 249 }
lukeocarwright 16:14c231624f3e 250
lukeocarwright 16:14c231624f3e 251 void Menu::contrastrun(N5110 &lcd, Gamepad &pad)
lukeocarwright 16:14c231624f3e 252 {
lukeocarwright 16:14c231624f3e 253 menuflag=1; //sets flag
lukeocarwright 30:08cc4ec58d07 254 //printf("Contrast Settings \n");
lukeocarwright 16:14c231624f3e 255 lcd.clear();
lukeocarwright 16:14c231624f3e 256 lcd.printString("Contrast:",3,0);
lukeocarwright 17:358987e9f30e 257 contrast=0.5;
lukeocarwright 16:14c231624f3e 258 pad.reset_buttons();
lukeocarwright 17:358987e9f30e 259 printcontrast(lcd,contrast);
lukeocarwright 17:358987e9f30e 260 while (menuflag==1) { //looped
lukeocarwright 17:358987e9f30e 261 s=scroll(lcd,pad,10,20);
lukeocarwright 17:358987e9f30e 262 if (s!=s_1) {
lukeocarwright 29:207111ffd6e6 263 //printf("S= %d",s);
lukeocarwright 17:358987e9f30e 264 if (s==1) {
lukeocarwright 17:358987e9f30e 265 printcontrast(lcd,contrast);
lukeocarwright 17:358987e9f30e 266 contrast=contrast+0.05f;
lukeocarwright 17:358987e9f30e 267 lcd.setContrast(contrast);
lukeocarwright 29:207111ffd6e6 268 //printf("CONTRAST UP\n");
lukeocarwright 17:358987e9f30e 269 wait_ms(200);
lukeocarwright 17:358987e9f30e 270 }
lukeocarwright 17:358987e9f30e 271 if (s==-1) {
lukeocarwright 17:358987e9f30e 272 printcontrast(lcd,contrast);
lukeocarwright 17:358987e9f30e 273 contrast=contrast-0.05f;
lukeocarwright 17:358987e9f30e 274 lcd.setContrast(contrast);
lukeocarwright 29:207111ffd6e6 275 //printf("CONTRAST DOWN\n");
lukeocarwright 17:358987e9f30e 276 wait_ms(200);
lukeocarwright 17:358987e9f30e 277 }
lukeocarwright 29:207111ffd6e6 278 }
lukeocarwright 29:207111ffd6e6 279 if (pad.B_pressed()) { //go back menu
lukeocarwright 29:207111ffd6e6 280 // printf("B pressed\n");
lukeocarwright 29:207111ffd6e6 281 //printf("Main Menu selected\n"); //debug
lukeocarwright 29:207111ffd6e6 282 submenu=0;
lukeocarwright 29:207111ffd6e6 283 lcd.clear();
lukeocarwright 29:207111ffd6e6 284 lcd.printString("Contrast Set",3,3);
lukeocarwright 29:207111ffd6e6 285 lcd.refresh();
lukeocarwright 29:207111ffd6e6 286 wait_ms(900); //debounce + display
lukeocarwright 29:207111ffd6e6 287 menuflag=0; //sets flag
lukeocarwright 16:14c231624f3e 288 }
lukeocarwright 17:358987e9f30e 289 s=s_1;
lukeocarwright 16:14c231624f3e 290 }
lukeocarwright 29:207111ffd6e6 291 subsettings(lcd,pad);
lukeocarwright 16:14c231624f3e 292 }
lukeocarwright 8:f305ea78b2b1 293
lukeocarwright 30:08cc4ec58d07 294 void Menu::backlightrun(N5110 &lcd, Gamepad &pad)
lukeocarwright 30:08cc4ec58d07 295 {
lukeocarwright 30:08cc4ec58d07 296 lcd.clear();
lukeocarwright 30:08cc4ec58d07 297 lcd.printString("Backlight:",3,0);
lukeocarwright 30:08cc4ec58d07 298 lcd.printString("Press A to",3,1);
lukeocarwright 30:08cc4ec58d07 299 lcd.printString("toggle",3,2);
lukeocarwright 30:08cc4ec58d07 300 lcd.refresh();
lukeocarwright 30:08cc4ec58d07 301 menuflag=1;
lukeocarwright 30:08cc4ec58d07 302 toggle=true;
lukeocarwright 30:08cc4ec58d07 303 while (menuflag==1) {
lukeocarwright 30:08cc4ec58d07 304 if (pad.A_pressed()) {
lukeocarwright 30:08cc4ec58d07 305 if (toggle==true) {
lukeocarwright 30:08cc4ec58d07 306 lcd.backLightOn();
lukeocarwright 30:08cc4ec58d07 307 toggle=false;
lukeocarwright 30:08cc4ec58d07 308 } else if (toggle==false) {
lukeocarwright 30:08cc4ec58d07 309 lcd.backLightOff();
lukeocarwright 30:08cc4ec58d07 310 toggle=true;
lukeocarwright 30:08cc4ec58d07 311 }
lukeocarwright 30:08cc4ec58d07 312 wait_ms(500);//debounce
lukeocarwright 30:08cc4ec58d07 313
lukeocarwright 30:08cc4ec58d07 314 }
lukeocarwright 30:08cc4ec58d07 315 if (pad.B_pressed()) {
lukeocarwright 30:08cc4ec58d07 316 menuflag=0;
lukeocarwright 30:08cc4ec58d07 317 }
lukeocarwright 30:08cc4ec58d07 318 }
lukeocarwright 30:08cc4ec58d07 319 wait_ms(500);//debounce
lukeocarwright 30:08cc4ec58d07 320 pad.reset_buttons();
lukeocarwright 30:08cc4ec58d07 321 subsettings(lcd,pad);
lukeocarwright 30:08cc4ec58d07 322 }
lukeocarwright 17:358987e9f30e 323
lukeocarwright 8:f305ea78b2b1 324 //Private Methods--------------------------------------------------------------
lukeocarwright 17:358987e9f30e 325 void Menu::printmainmenu(N5110 &lcd) //prints main menu
lukeocarwright 8:f305ea78b2b1 326 {
lukeocarwright 30:08cc4ec58d07 327 //printf("Printing Main Menu \n");
lukeocarwright 8:f305ea78b2b1 328 lcd.clear(); //clears current buffer
lukeocarwright 8:f305ea78b2b1 329 lcd.drawRect(78,g_selecty,5,5,FILL_BLACK); //prints select box at y value
lukeocarwright 8:f305ea78b2b1 330 lcd.printString("MAIN MENU",3,0); //title print
lukeocarwright 8:f305ea78b2b1 331 //SUBMENU TITLES
lukeocarwright 8:f305ea78b2b1 332 lcd.printString("Waveforms",3,1);
lukeocarwright 8:f305ea78b2b1 333 lcd.printString("Instructions",3,2);
lukeocarwright 29:207111ffd6e6 334 lcd.printString("Settings",3,3);
lukeocarwright 29:207111ffd6e6 335 lcd.printString("Credits",3,4);
lukeocarwright 8:f305ea78b2b1 336 lcd.refresh(); //updates display
lukeocarwright 8:f305ea78b2b1 337 }
lukeocarwright 29:207111ffd6e6 338
lukeocarwright 17:358987e9f30e 339 void Menu::printsubwaveforms(N5110 &lcd) //prints subwaveforms menu
lukeocarwright 8:f305ea78b2b1 340 {
lukeocarwright 8:f305ea78b2b1 341 printf("Printing Waveforms menu\n");
lukeocarwright 8:f305ea78b2b1 342 lcd.clear(); //clears current buffer
lukeocarwright 8:f305ea78b2b1 343 lcd.drawRect(78,g_selecty,5,5,FILL_BLACK); //prints select box at y value
lukeocarwright 8:f305ea78b2b1 344 lcd.printString("WAVEFORMS:",3,0); //title print
lukeocarwright 8:f305ea78b2b1 345 //SUBMENU TITLES
lukeocarwright 8:f305ea78b2b1 346 lcd.printString("Sine",3,1);
lukeocarwright 8:f305ea78b2b1 347 lcd.printString("Triangle",3,2);
lukeocarwright 8:f305ea78b2b1 348 lcd.printString("Square",3,3);
lukeocarwright 8:f305ea78b2b1 349 lcd.refresh(); //updates display
lukeocarwright 8:f305ea78b2b1 350 }
lukeocarwright 8:f305ea78b2b1 351
lukeocarwright 17:358987e9f30e 352 void Menu::printsubsettings(N5110 &lcd) //prints settings menu
lukeocarwright 16:14c231624f3e 353 {
lukeocarwright 29:207111ffd6e6 354 //printf("Printing Settings menu\n");
lukeocarwright 16:14c231624f3e 355 lcd.clear();
lukeocarwright 16:14c231624f3e 356 lcd.drawRect(78,g_selecty,5,5,FILL_BLACK); //prints select box at y value
lukeocarwright 16:14c231624f3e 357 lcd.printString("Settings:",3,0); //title print
lukeocarwright 16:14c231624f3e 358 //SUBMENU TITLES
lukeocarwright 16:14c231624f3e 359 lcd.printString("Volume",3,1);
lukeocarwright 30:08cc4ec58d07 360 lcd.printString("Backlight",3,2);
lukeocarwright 16:14c231624f3e 361 lcd.printString("Contrast",3,3);
lukeocarwright 30:08cc4ec58d07 362 lcd.printString("Inverse Mode",3,4);
lukeocarwright 16:14c231624f3e 363 lcd.refresh(); //updates display
lukeocarwright 16:14c231624f3e 364 }
lukeocarwright 16:14c231624f3e 365
lukeocarwright 17:358987e9f30e 366 void Menu::printcontrast(N5110 &lcd, float contrast) //prints contrast edit screen
lukeocarwright 17:358987e9f30e 367 {
lukeocarwright 17:358987e9f30e 368 lcd.clear();
lukeocarwright 17:358987e9f30e 369 lcd.printString("Contrast:",3,0);//title print
lukeocarwright 17:358987e9f30e 370 lcd.printString("VISIBILITY",12,3);
lukeocarwright 17:358987e9f30e 371 lcd.refresh();
lukeocarwright 17:358987e9f30e 372 }
lukeocarwright 29:207111ffd6e6 373
lukeocarwright 17:358987e9f30e 374 void Menu::subunavailiable(N5110 &lcd) //for currently undeveloped menu
lukeocarwright 8:f305ea78b2b1 375 {
lukeocarwright 29:207111ffd6e6 376 //printf("sub unavailiable\n");
lukeocarwright 8:f305ea78b2b1 377 lcd.printString("Unavailiable",3,1);
lukeocarwright 8:f305ea78b2b1 378 lcd.refresh();
lukeocarwright 8:f305ea78b2b1 379 }
lukeocarwright 8:f305ea78b2b1 380
lukeocarwright 17:358987e9f30e 381 int Menu::scroll(N5110 &lcd, Gamepad &pad, int submenu, int menusize) //checks srolling
lukeocarwright 8:f305ea78b2b1 382 {
lukeocarwright 8:f305ea78b2b1 383 int d=scroll_check(pad);
lukeocarwright 8:f305ea78b2b1 384 if(d != 0) {
lukeocarwright 13:27300c533dd1 385 if (d==1) { //N scrolls up
lukeocarwright 29:207111ffd6e6 386 //printf("N \n"); //debug
lukeocarwright 13:27300c533dd1 387 submenu--;
lukeocarwright 13:27300c533dd1 388 g_selecty=g_selecty-8; //line size=8
lukeocarwright 29:207111ffd6e6 389 if (submenu<=0) { //stops overflow
lukeocarwright 13:27300c533dd1 390 submenu++;
lukeocarwright 13:27300c533dd1 391 g_selecty = g_selecty+8;
lukeocarwright 13:27300c533dd1 392 return(0);
lukeocarwright 8:f305ea78b2b1 393 }
lukeocarwright 29:207111ffd6e6 394 //printf("SubMenu= %d\n", submenu); //debug
lukeocarwright 12:7a399a476cfd 395 return(-1);
lukeocarwright 8:f305ea78b2b1 396 }
lukeocarwright 13:27300c533dd1 397 if (d==5) { //S scrolls down
lukeocarwright 29:207111ffd6e6 398 //printf("S \n");
lukeocarwright 13:27300c533dd1 399 submenu++;
lukeocarwright 13:27300c533dd1 400 g_selecty=g_selecty+8;
lukeocarwright 13:27300c533dd1 401 if (submenu >menusize) { //stops overflow
lukeocarwright 13:27300c533dd1 402 submenu--;
lukeocarwright 13:27300c533dd1 403 g_selecty = g_selecty-8;
lukeocarwright 13:27300c533dd1 404 return(0);
lukeocarwright 8:f305ea78b2b1 405 }
lukeocarwright 29:207111ffd6e6 406 //printf("SubMenu= %d\n", submenu); //debug
lukeocarwright 12:7a399a476cfd 407 return(1);
lukeocarwright 8:f305ea78b2b1 408 }
lukeocarwright 8:f305ea78b2b1 409 wait_ms(200); //debounce
lukeocarwright 14:9cfe0041cc4e 410 }
lukeocarwright 13:27300c533dd1 411 return(0);
lukeocarwright 8:f305ea78b2b1 412 }
lukeocarwright 13:27300c533dd1 413
lukeocarwright 8:f305ea78b2b1 414 int Menu::scroll_check (Gamepad &pad)
lukeocarwright 8:f305ea78b2b1 415 {
lukeocarwright 8:f305ea78b2b1 416 return(pad.get_direction()); //checks for stick
lukeocarwright 8:f305ea78b2b1 417 }