Ryan Scott / menuSystemMbedBroken

Dependencies:   ANSITermMenuSystem

Fork of menuSystemMbed by Ryan Scott

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HANDLER_PlaybackmenuPage.cpp Source File

HANDLER_PlaybackmenuPage.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 extern Serial pc;
00011 
00012 int PlaybackmenuPageHandler()
00013 {
00014      int userSelection = 0;
00015      pageMenu[PLAYBACK].printMenu();
00016 
00017      unsigned char lastState = 0x0f;  //0000 1111
00018      bool exitCurrentMenu = false;
00019 
00020      while ( exitCurrentMenu == false)
00021         {
00022         
00023         unsigned char currentState = switches.read();  //reading a port add a AND MASK & 0b00000111
00024         wait_ms(10);
00025         if( currentState == switches.read() && currentState != lastState)
00026             {
00027             lastState = currentState; 
00028             switch(currentState)
00029                 {
00030                 case 0x0e:
00031                     pageMenu[PLAYBACK].erase();
00032                     userSelection = HOME;
00033                     exitCurrentMenu = true;
00034                     break;
00035                 case 0x0d:
00036                      pageMenu[PLAYBACK].highlightPrevItem();
00037                     break;
00038                 case 0x0b:
00039                      pageMenu[PLAYBACK].highlightNextItem();
00040                     break;
00041                 case 0x07:
00042                     pageMenu[PLAYBACK].erase();
00043                     
00044                     if (pageMenu[PLAYBACK].getHighlightedItem()== 702) userSelection = 9;
00045                     if (pageMenu[PLAYBACK].getHighlightedItem()== 701) userSelection = 8;
00046                     exitCurrentMenu = true;
00047        //             pc.printf("userselction: %d \n", userSelection);
00048          //           pc.printf("highlighteditem: %d \n", pageMenu[PLAYBACK].getHighlightedItem());
00049                     break;
00050                 }//eo select
00051             wait_ms(200);
00052             if (exittorecord == true)
00053                break;
00054             
00055             }//eo if kbhit
00056         }//eo while
00057         return userSelection;
00058 }