Menu system broken

Dependencies:   ANSITermMenuSystem

Fork of menuSystemMbed by Ryan Scott

HANDLER_RecordSettings.cpp

Committer:
mbedDevLondon
Date:
2013-02-28
Revision:
0:a5ece7312edc
Child:
3:bdf42b6c15f4

File content as of revision 0:a5ece7312edc:

#include "mbed.h"

#include "menuIDs.h"
#include "MainMenu.h"
#include "console.h"

extern BusInOut switches; //(p21, p22, p23, p24)
extern MainMenu pageMenu[12];

int RecordSettingsHandler()
{
     int userSelection = 0;
     pageMenu[RECORDSET].printMenu();

     unsigned char lastState = 0x0f;  //0000 1111
     bool exitCurrentMenu = false;

     while ( exitCurrentMenu == false)
        {
        
        unsigned char currentState = switches.read();  //reading a port add a AND MASK & 0b00000111
        wait_ms(10);
        if( currentState == switches.read() && currentState != lastState)
            {
            lastState = currentState; 
            switch(currentState)
                {
                case 0x0e:
                    pageMenu[RECORDSET].erase();
                    userSelection = HOME;
                    exitCurrentMenu = true;
                    break;
                case 0x0d:
                     pageMenu[RECORDSET].highlightPrevItem();
                    break;
                case 0x0b:
                     pageMenu[RECORDSET].highlightNextItem();
                    break;
                case 0x07:
                    pageMenu[RECORDSET].erase();
                    userSelection = pageMenu[RECORDSET].getHighlightedItem() - RECSETOFFSET;
                    exitCurrentMenu = true;
                    break;
                }//eo select
            wait_ms(200);
            }//eo if kbhit
        }//eo while
        return userSelection;
}