Menu system broken

Dependencies:   ANSITermMenuSystem

Fork of menuSystemMbed by Ryan Scott

Committer:
Rybowonder
Date:
Sat May 04 17:37:57 2013 +0000
Revision:
8:6ddb8c26387a
Parent:
7:df9f5b6dd4ed
For Mitchener

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rybowonder 3:bdf42b6c15f4 1 #include "mbed.h"
Rybowonder 3:bdf42b6c15f4 2
Rybowonder 3:bdf42b6c15f4 3 #include "menuIDs.h"
Rybowonder 3:bdf42b6c15f4 4 #include "MainMenu.h"
Rybowonder 3:bdf42b6c15f4 5 #include "console.h"
Rybowonder 3:bdf42b6c15f4 6
Rybowonder 3:bdf42b6c15f4 7 extern BusInOut switches; //(p21, p22, p23, p24)
Rybowonder 3:bdf42b6c15f4 8 extern MainMenu pageMenu[MAXPAGES ];
Rybowonder 7:df9f5b6dd4ed 9 extern volatile bool exittorecord;
Rybowonder 7:df9f5b6dd4ed 10 Timer t;
Rybowonder 7:df9f5b6dd4ed 11 Ticker printtime;
Rybowonder 3:bdf42b6c15f4 12
Rybowonder 3:bdf42b6c15f4 13
Rybowonder 7:df9f5b6dd4ed 14 void displaytime(void)
Rybowonder 7:df9f5b6dd4ed 15 {
Rybowonder 7:df9f5b6dd4ed 16 char tickertime[50];
Rybowonder 7:df9f5b6dd4ed 17 sprintf(tickertime, "Song Length:%4.2f", t.read());
Rybowonder 7:df9f5b6dd4ed 18 printXY(tickertime, 2, 2);
Rybowonder 7:df9f5b6dd4ed 19 }
Rybowonder 7:df9f5b6dd4ed 20
Rybowonder 3:bdf42b6c15f4 21 int RecordscreenPageHandler()
Rybowonder 3:bdf42b6c15f4 22 {
Rybowonder 7:df9f5b6dd4ed 23 bool recordflag = true;
Rybowonder 7:df9f5b6dd4ed 24
Rybowonder 7:df9f5b6dd4ed 25 char timebuf[50];
Rybowonder 7:df9f5b6dd4ed 26
Rybowonder 7:df9f5b6dd4ed 27
Rybowonder 7:df9f5b6dd4ed 28 clrscr();
Rybowonder 3:bdf42b6c15f4 29 int userSelection = 0;
Rybowonder 3:bdf42b6c15f4 30 unsigned char lastState = 0x0f; //0000 1111
Rybowonder 3:bdf42b6c15f4 31 bool exitCurrentMenu = false;
Rybowonder 7:df9f5b6dd4ed 32
Rybowonder 7:df9f5b6dd4ed 33 printtime.attach(&displaytime, 1);
Rybowonder 7:df9f5b6dd4ed 34
Rybowonder 7:df9f5b6dd4ed 35 t.start();
Rybowonder 7:df9f5b6dd4ed 36
Rybowonder 7:df9f5b6dd4ed 37
Rybowonder 3:bdf42b6c15f4 38 while ( exitCurrentMenu == false)
Rybowonder 7:df9f5b6dd4ed 39 {
Rybowonder 7:df9f5b6dd4ed 40
Rybowonder 7:df9f5b6dd4ed 41 if (exittorecord == true && recordflag == true)
Rybowonder 7:df9f5b6dd4ed 42 {
Rybowonder 7:df9f5b6dd4ed 43 printXY("Recording", 5, 2);
Rybowonder 7:df9f5b6dd4ed 44 // printXY("To Stop", 2, 5);
Rybowonder 7:df9f5b6dd4ed 45 // printXY("Recording", 2, 6);
Rybowonder 7:df9f5b6dd4ed 46 recordflag = false;
Rybowonder 7:df9f5b6dd4ed 47 }
Rybowonder 3:bdf42b6c15f4 48 unsigned char currentState = switches.read(); //reading a port add a AND MASK & 0b00000111
Rybowonder 3:bdf42b6c15f4 49 wait_ms(10);
Rybowonder 3:bdf42b6c15f4 50 if( currentState == switches.read() && currentState != lastState)
Rybowonder 3:bdf42b6c15f4 51 {
Rybowonder 3:bdf42b6c15f4 52 lastState = currentState;
Rybowonder 3:bdf42b6c15f4 53 switch(currentState)
Rybowonder 3:bdf42b6c15f4 54 {
Rybowonder 3:bdf42b6c15f4 55 case 0x0e:
Rybowonder 7:df9f5b6dd4ed 56 if (exittorecord == false)
Rybowonder 7:df9f5b6dd4ed 57 {
Rybowonder 3:bdf42b6c15f4 58 pageMenu[RECORDSCR].erase();
Rybowonder 3:bdf42b6c15f4 59 printXY(" ", 5, 10); //erases the ACTION prompt
Rybowonder 3:bdf42b6c15f4 60 userSelection = HOME;
Rybowonder 7:df9f5b6dd4ed 61 exitCurrentMenu = true;
Rybowonder 7:df9f5b6dd4ed 62 }
Rybowonder 7:df9f5b6dd4ed 63 break;
Rybowonder 3:bdf42b6c15f4 64 case 0x07:
Rybowonder 7:df9f5b6dd4ed 65 if (exittorecord == true)
Rybowonder 3:bdf42b6c15f4 66 {
Rybowonder 7:df9f5b6dd4ed 67 clrscr();
Rybowonder 7:df9f5b6dd4ed 68 t.stop();
Rybowonder 7:df9f5b6dd4ed 69 printtime.detach();
Rybowonder 7:df9f5b6dd4ed 70 sprintf(timebuf, "Total Length:%4.2f", t.read());
Rybowonder 7:df9f5b6dd4ed 71 printXY(timebuf, 2, 2);
Rybowonder 7:df9f5b6dd4ed 72 t.reset();
Rybowonder 7:df9f5b6dd4ed 73 exittorecord = false;
Rybowonder 3:bdf42b6c15f4 74 }
Rybowonder 7:df9f5b6dd4ed 75 break;
Rybowonder 7:df9f5b6dd4ed 76 }
Rybowonder 3:bdf42b6c15f4 77 wait_ms(200);
Rybowonder 7:df9f5b6dd4ed 78
Rybowonder 7:df9f5b6dd4ed 79
Rybowonder 3:bdf42b6c15f4 80 }//eo if kbhit
Rybowonder 3:bdf42b6c15f4 81 }//eo while
Rybowonder 3:bdf42b6c15f4 82 return userSelection;
Rybowonder 3:bdf42b6c15f4 83 }