Ryan Scott / menuSystemMbedBroken

Dependencies:   ANSITermMenuSystem

Fork of menuSystemMbed by Ryan Scott

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HANDLER_InputPage.cpp Source File

HANDLER_InputPage.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 extern volatile bool exittorecord;
00010 
00011 int InputPageHandler()
00012 {
00013      int userSelection = 0;
00014      pageMenu[INPUT].printMenu();
00015 
00016      unsigned char lastState = 0x0f;  //0000 1111
00017      bool exitCurrentMenu = false;
00018 
00019      while ( exitCurrentMenu == false)
00020         {
00021         
00022         unsigned char currentState = switches.read();  //reading a port add a AND MASK & 0b00000111
00023         wait_ms(10);
00024         if( currentState == switches.read() && currentState != lastState)
00025             {
00026             lastState = currentState; 
00027             switch(currentState)
00028                 {
00029                 case 0x0e:
00030                     pageMenu[INPUT].erase();
00031                     printXY("                       ", 5, 10);    //erases the ACTION prompt
00032                     userSelection = RECORDSET;
00033                     exitCurrentMenu = true;
00034                     break;
00035                 case 0x0d:
00036                      pageMenu[INPUT].highlightPrevItem();
00037                     break;
00038                 case 0x0b:
00039                      pageMenu[INPUT].highlightNextItem();
00040                     break;
00041                 case 0x07:
00042                     userSelection = pageMenu[INPUT].getHighlightedItem() ;
00043                     pageMenu[INPUT].removeselection();
00044                     pageMenu[INPUT].selection();
00045                     break;
00046                 }//eo select
00047 
00048                 // is the user selection an ACTION  assigned to this page
00049  /*               
00050                 if (userSelection != 0 && userSelection > INPUTOFFSET)  //page selections are 0 through 12
00051                     {
00052                     // place code here to handle actions processed directly from this page
00053                     switch(userSelection)
00054                         {
00055                         case INMIC:
00056                             printXY("Mic selected          ", 5, 10);
00057         //                    pageMenu[INPUT].selection;
00058                             //call function to perform task
00059                             break;
00060                         case INLINE:
00061                             printXY("Line selected    ",5,10);
00062                             //call function to perform task
00063                             break;
00064                         }
00065                     // eo place code here ......
00066                     userSelection = 0;
00067                     }
00068  */                   
00069                 wait_ms(200);
00070                 if (exittorecord == true)
00071                 break;
00072                 
00073             }//eo if kbhit
00074         }//eo while
00075         return userSelection;
00076 }