mbed menu system
HANDLER_OutputPage.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 | #include "console.h" |
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 | |
mbedDevLondon | 0:a5ece7312edc | 11 | int OutputPageHandler() |
mbedDevLondon | 0:a5ece7312edc | 12 | { |
mbedDevLondon | 0:a5ece7312edc | 13 | int userSelection = 0; |
mbedDevLondon | 0:a5ece7312edc | 14 | pageMenu[OUTPUT].printMenu(); |
mbedDevLondon | 0:a5ece7312edc | 15 | |
mbedDevLondon | 0:a5ece7312edc | 16 | unsigned char lastState = 0x0f; //0000 1111 |
mbedDevLondon | 0:a5ece7312edc | 17 | bool exitCurrentMenu = false; |
mbedDevLondon | 0:a5ece7312edc | 18 | |
mbedDevLondon | 0:a5ece7312edc | 19 | while ( exitCurrentMenu == false) |
mbedDevLondon | 0:a5ece7312edc | 20 | { |
mbedDevLondon | 0:a5ece7312edc | 21 | |
mbedDevLondon | 0:a5ece7312edc | 22 | unsigned char currentState = switches.read(); //reading a port add a AND MASK & 0b00000111 |
mbedDevLondon | 0:a5ece7312edc | 23 | wait_ms(10); |
mbedDevLondon | 0:a5ece7312edc | 24 | if( currentState == switches.read() && currentState != lastState) |
mbedDevLondon | 0:a5ece7312edc | 25 | { |
mbedDevLondon | 0:a5ece7312edc | 26 | lastState = currentState; |
mbedDevLondon | 0:a5ece7312edc | 27 | switch(currentState) |
mbedDevLondon | 0:a5ece7312edc | 28 | { |
mbedDevLondon | 0:a5ece7312edc | 29 | case 0x0e: |
mbedDevLondon | 0:a5ece7312edc | 30 | pageMenu[OUTPUT].erase(); |
mbedDevLondon | 0:a5ece7312edc | 31 | printXY(" ", 5, 10); |
mbedDevLondon | 0:a5ece7312edc | 32 | userSelection = RECORDSET; |
mbedDevLondon | 0:a5ece7312edc | 33 | exitCurrentMenu = true; |
mbedDevLondon | 0:a5ece7312edc | 34 | break; |
mbedDevLondon | 0:a5ece7312edc | 35 | case 0x0d: |
mbedDevLondon | 0:a5ece7312edc | 36 | pageMenu[OUTPUT].highlightPrevItem(); |
mbedDevLondon | 0:a5ece7312edc | 37 | break; |
mbedDevLondon | 0:a5ece7312edc | 38 | case 0x0b: |
mbedDevLondon | 0:a5ece7312edc | 39 | pageMenu[OUTPUT].highlightNextItem(); |
mbedDevLondon | 0:a5ece7312edc | 40 | break; |
mbedDevLondon | 0:a5ece7312edc | 41 | case 0x07: |
mbedDevLondon | 0:a5ece7312edc | 42 | userSelection = pageMenu[OUTPUT].getHighlightedItem() ; |
mbedDevLondon | 0:a5ece7312edc | 43 | break; |
mbedDevLondon | 0:a5ece7312edc | 44 | }//eo select |
mbedDevLondon | 0:a5ece7312edc | 45 | |
mbedDevLondon | 0:a5ece7312edc | 46 | |
mbedDevLondon | 0:a5ece7312edc | 47 | if (userSelection != 0 && userSelection != RECORDSET) |
mbedDevLondon | 0:a5ece7312edc | 48 | { |
mbedDevLondon | 0:a5ece7312edc | 49 | // place code here to handle actions processed directly from this page |
mbedDevLondon | 0:a5ece7312edc | 50 | switch(userSelection) |
mbedDevLondon | 0:a5ece7312edc | 51 | { |
mbedDevLondon | 0:a5ece7312edc | 52 | case LINE: |
mbedDevLondon | 0:a5ece7312edc | 53 | printXY("Line selected ", 5, 10); |
mbedDevLondon | 0:a5ece7312edc | 54 | //call function to perform task |
mbedDevLondon | 0:a5ece7312edc | 55 | break; |
mbedDevLondon | 0:a5ece7312edc | 56 | case HEADPHONES: |
mbedDevLondon | 0:a5ece7312edc | 57 | printXY("Headphones selected ",5,10); |
mbedDevLondon | 0:a5ece7312edc | 58 | //call function to perform task |
mbedDevLondon | 0:a5ece7312edc | 59 | break; |
mbedDevLondon | 0:a5ece7312edc | 60 | case SPEAKERS: |
mbedDevLondon | 0:a5ece7312edc | 61 | printXY("Speakers selected ", 5, 10); |
mbedDevLondon | 0:a5ece7312edc | 62 | //call function to perform task |
mbedDevLondon | 0:a5ece7312edc | 63 | break; |
mbedDevLondon | 0:a5ece7312edc | 64 | } |
mbedDevLondon | 0:a5ece7312edc | 65 | // eo place code here ...... |
mbedDevLondon | 0:a5ece7312edc | 66 | userSelection = 0; |
mbedDevLondon | 0:a5ece7312edc | 67 | } |
mbedDevLondon | 0:a5ece7312edc | 68 | wait_ms(200); |
mbedDevLondon | 0:a5ece7312edc | 69 | }//eo if kbhit |
mbedDevLondon | 0:a5ece7312edc | 70 | }//eo while |
mbedDevLondon | 0:a5ece7312edc | 71 | return userSelection; |
mbedDevLondon | 0:a5ece7312edc | 72 | } |