Ryan Scott / menuSystemMbed

Fork of menuSystemMbed by Brad Smith

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HANDLER_RecordSettings.cpp Source File

HANDLER_RecordSettings.cpp

00001 #include "mbed.h"
00002 
00003 #include "menuIDs.h"
00004 #include "MainMenu.h"
00005 #include "console.h"
00006 
00007 extern BusInOut switches; //(p21, p22, p23, p24)
00008 extern MainMenu pageMenu[MAXPAGES ];
00009 
00010 int RecordSettingsHandler()
00011 {
00012      int userSelection = 0;
00013      pageMenu[RECORDSET].printMenu();
00014 
00015      unsigned char lastState = 0x0f;  //0000 1111
00016      bool exitCurrentMenu = false;
00017 
00018      while ( exitCurrentMenu == false)
00019         {
00020         
00021         unsigned char currentState = switches.read();  //reading a port add a AND MASK & 0b00000111
00022         wait_ms(10);
00023         if( currentState == switches.read() && currentState != lastState)
00024             {
00025             lastState = currentState; 
00026             switch(currentState)
00027                 {
00028                 case 0x0e:
00029                     pageMenu[RECORDSET].erase();
00030                     userSelection = HOME;
00031                     exitCurrentMenu = true;
00032                     break;
00033                 case 0x0d:
00034                      pageMenu[RECORDSET].highlightPrevItem();
00035                     break;
00036                 case 0x0b:
00037                      pageMenu[RECORDSET].highlightNextItem();
00038                     break;
00039                 case 0x07:
00040                     pageMenu[RECORDSET].erase();
00041                     userSelection = pageMenu[RECORDSET].getHighlightedItem() - RECSETOFFSET;
00042                     exitCurrentMenu = true;
00043                     break;
00044                 }//eo select
00045             wait_ms(200);
00046             }//eo if kbhit
00047         }//eo while
00048         return userSelection;
00049 }