mbed menu system
HANDLER_HomePage.cpp@2:5c4911aba273, 2013-02-28 (annotated)
- Committer:
- mbedDevLondon
- Date:
- Thu Feb 28 03:33:50 2013 +0000
- Revision:
- 2:5c4911aba273
- Parent:
- 0:a5ece7312edc
formatting in menuIDs.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedDevLondon | 0:a5ece7312edc | 1 | #include "mbed.h" |
mbedDevLondon | 0:a5ece7312edc | 2 | |
mbedDevLondon | 0:a5ece7312edc | 3 | #include "menuIDs.h" |
mbedDevLondon | 0:a5ece7312edc | 4 | #include "MainMenu.h" |
mbedDevLondon | 0:a5ece7312edc | 5 | |
mbedDevLondon | 0:a5ece7312edc | 6 | |
mbedDevLondon | 0:a5ece7312edc | 7 | extern BusInOut switches; //(p21, p22, p23, p24) |
mbedDevLondon | 0:a5ece7312edc | 8 | extern MainMenu pageMenu[12]; |
mbedDevLondon | 0:a5ece7312edc | 9 | |
mbedDevLondon | 0:a5ece7312edc | 10 | int homePageHandler() |
mbedDevLondon | 0:a5ece7312edc | 11 | { |
mbedDevLondon | 0:a5ece7312edc | 12 | int userSelection = 0; |
mbedDevLondon | 0:a5ece7312edc | 13 | pageMenu[HOME].printMenu(); |
mbedDevLondon | 0:a5ece7312edc | 14 | |
mbedDevLondon | 0:a5ece7312edc | 15 | unsigned char lastState = 0x0f; //0000 1111 |
mbedDevLondon | 0:a5ece7312edc | 16 | bool exitCurrentMenu = false; |
mbedDevLondon | 0:a5ece7312edc | 17 | |
mbedDevLondon | 0:a5ece7312edc | 18 | while ( exitCurrentMenu == false) |
mbedDevLondon | 0:a5ece7312edc | 19 | { |
mbedDevLondon | 0:a5ece7312edc | 20 | |
mbedDevLondon | 0:a5ece7312edc | 21 | unsigned char currentState = switches.read(); //reading a port add a AND MASK & 0b00000111 |
mbedDevLondon | 0:a5ece7312edc | 22 | wait_ms(10); |
mbedDevLondon | 0:a5ece7312edc | 23 | if( currentState == switches.read() && currentState != lastState) |
mbedDevLondon | 0:a5ece7312edc | 24 | { |
mbedDevLondon | 0:a5ece7312edc | 25 | lastState = currentState; |
mbedDevLondon | 0:a5ece7312edc | 26 | switch(currentState) |
mbedDevLondon | 0:a5ece7312edc | 27 | { |
mbedDevLondon | 0:a5ece7312edc | 28 | case 0x0e: |
mbedDevLondon | 0:a5ece7312edc | 29 | pageMenu[HOME].erase(); |
mbedDevLondon | 0:a5ece7312edc | 30 | userSelection = HOME; |
mbedDevLondon | 0:a5ece7312edc | 31 | exitCurrentMenu = true; |
mbedDevLondon | 0:a5ece7312edc | 32 | break; |
mbedDevLondon | 0:a5ece7312edc | 33 | case 0x0d: |
mbedDevLondon | 0:a5ece7312edc | 34 | pageMenu[HOME].highlightPrevItem(); |
mbedDevLondon | 0:a5ece7312edc | 35 | break; |
mbedDevLondon | 0:a5ece7312edc | 36 | case 0x0b: |
mbedDevLondon | 0:a5ece7312edc | 37 | pageMenu[HOME].highlightNextItem(); |
mbedDevLondon | 0:a5ece7312edc | 38 | break; |
mbedDevLondon | 0:a5ece7312edc | 39 | case 0x07: |
mbedDevLondon | 0:a5ece7312edc | 40 | pageMenu[HOME].erase(); |
mbedDevLondon | 0:a5ece7312edc | 41 | userSelection = pageMenu[HOME].getHighlightedItem(); |
mbedDevLondon | 0:a5ece7312edc | 42 | exitCurrentMenu = true; |
mbedDevLondon | 0:a5ece7312edc | 43 | break; |
mbedDevLondon | 0:a5ece7312edc | 44 | }//eo select |
mbedDevLondon | 0:a5ece7312edc | 45 | wait_ms(200); |
mbedDevLondon | 0:a5ece7312edc | 46 | }//eo if switch press detected |
mbedDevLondon | 0:a5ece7312edc | 47 | }//eo while |
mbedDevLondon | 0:a5ece7312edc | 48 | return userSelection; |
mbedDevLondon | 0:a5ece7312edc | 49 | } |