menu system menus complete
Fork of menuSystemMbed by
HANDLER_AGCPage.cpp@3:bdf42b6c15f4, 2013-03-08 (annotated)
- Committer:
- Rybowonder
- Date:
- Fri Mar 08 17:37:11 2013 +0000
- Revision:
- 3:bdf42b6c15f4
menus complete
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rybowonder | 3:bdf42b6c15f4 | 1 | #include "mbed.h" |
Rybowonder | 3:bdf42b6c15f4 | 2 | |
Rybowonder | 3:bdf42b6c15f4 | 3 | #include "menuIDs.h" |
Rybowonder | 3:bdf42b6c15f4 | 4 | #include "MainMenu.h" |
Rybowonder | 3:bdf42b6c15f4 | 5 | #include "console.h" |
Rybowonder | 3:bdf42b6c15f4 | 6 | |
Rybowonder | 3:bdf42b6c15f4 | 7 | extern BusInOut switches; //(p21, p22, p23, p24) |
Rybowonder | 3:bdf42b6c15f4 | 8 | extern MainMenu pageMenu[MAXPAGES ]; |
Rybowonder | 3:bdf42b6c15f4 | 9 | |
Rybowonder | 3:bdf42b6c15f4 | 10 | |
Rybowonder | 3:bdf42b6c15f4 | 11 | int AGCPageHandler() |
Rybowonder | 3:bdf42b6c15f4 | 12 | { |
Rybowonder | 3:bdf42b6c15f4 | 13 | int userSelection = 0; |
Rybowonder | 3:bdf42b6c15f4 | 14 | pageMenu[AGC].printMenu(); |
Rybowonder | 3:bdf42b6c15f4 | 15 | |
Rybowonder | 3:bdf42b6c15f4 | 16 | unsigned char lastState = 0x0f; //0000 1111 |
Rybowonder | 3:bdf42b6c15f4 | 17 | bool exitCurrentMenu = false; |
Rybowonder | 3:bdf42b6c15f4 | 18 | |
Rybowonder | 3:bdf42b6c15f4 | 19 | while ( exitCurrentMenu == false) |
Rybowonder | 3:bdf42b6c15f4 | 20 | { |
Rybowonder | 3:bdf42b6c15f4 | 21 | |
Rybowonder | 3:bdf42b6c15f4 | 22 | unsigned char currentState = switches.read(); //reading a port add a AND MASK & 0b00000111 |
Rybowonder | 3:bdf42b6c15f4 | 23 | wait_ms(10); |
Rybowonder | 3:bdf42b6c15f4 | 24 | if( currentState == switches.read() && currentState != lastState) |
Rybowonder | 3:bdf42b6c15f4 | 25 | { |
Rybowonder | 3:bdf42b6c15f4 | 26 | lastState = currentState; |
Rybowonder | 3:bdf42b6c15f4 | 27 | switch(currentState) |
Rybowonder | 3:bdf42b6c15f4 | 28 | { |
Rybowonder | 3:bdf42b6c15f4 | 29 | case 0x0e: |
Rybowonder | 3:bdf42b6c15f4 | 30 | pageMenu[AGC].erase(); |
Rybowonder | 3:bdf42b6c15f4 | 31 | printXY(" ", 5, 10); |
Rybowonder | 3:bdf42b6c15f4 | 32 | userSelection = RECORDSET; |
Rybowonder | 3:bdf42b6c15f4 | 33 | exitCurrentMenu = true; |
Rybowonder | 3:bdf42b6c15f4 | 34 | break; |
Rybowonder | 3:bdf42b6c15f4 | 35 | case 0x0d: |
Rybowonder | 3:bdf42b6c15f4 | 36 | pageMenu[AGC].highlightPrevItem(); |
Rybowonder | 3:bdf42b6c15f4 | 37 | break; |
Rybowonder | 3:bdf42b6c15f4 | 38 | case 0x0b: |
Rybowonder | 3:bdf42b6c15f4 | 39 | pageMenu[AGC].highlightNextItem(); |
Rybowonder | 3:bdf42b6c15f4 | 40 | break; |
Rybowonder | 3:bdf42b6c15f4 | 41 | case 0x07: |
Rybowonder | 3:bdf42b6c15f4 | 42 | userSelection = pageMenu[AGC].getHighlightedItem() ; |
Rybowonder | 3:bdf42b6c15f4 | 43 | break; |
Rybowonder | 3:bdf42b6c15f4 | 44 | }//eo select |
Rybowonder | 3:bdf42b6c15f4 | 45 | |
Rybowonder | 3:bdf42b6c15f4 | 46 | if (userSelection != 0 && userSelection != RECORDSET) |
Rybowonder | 3:bdf42b6c15f4 | 47 | { |
Rybowonder | 3:bdf42b6c15f4 | 48 | // place code here to handle actions processed directly from this page |
Rybowonder | 3:bdf42b6c15f4 | 49 | switch(userSelection) |
Rybowonder | 3:bdf42b6c15f4 | 50 | { |
Rybowonder | 3:bdf42b6c15f4 | 51 | case AGCON: |
Rybowonder | 3:bdf42b6c15f4 | 52 | printXY("AGC is On ", 5, 10); |
Rybowonder | 3:bdf42b6c15f4 | 53 | //call function to perform task |
Rybowonder | 3:bdf42b6c15f4 | 54 | break; |
Rybowonder | 3:bdf42b6c15f4 | 55 | case AGCOFF: |
Rybowonder | 3:bdf42b6c15f4 | 56 | printXY("AGC is Off ",5,10); |
Rybowonder | 3:bdf42b6c15f4 | 57 | //call function to perform task |
Rybowonder | 3:bdf42b6c15f4 | 58 | break; |
Rybowonder | 3:bdf42b6c15f4 | 59 | } |
Rybowonder | 3:bdf42b6c15f4 | 60 | // eo place code here ...... |
Rybowonder | 3:bdf42b6c15f4 | 61 | userSelection = 0; |
Rybowonder | 3:bdf42b6c15f4 | 62 | } |
Rybowonder | 3:bdf42b6c15f4 | 63 | wait_ms(200); |
Rybowonder | 3:bdf42b6c15f4 | 64 | }//eo if kbhit |
Rybowonder | 3:bdf42b6c15f4 | 65 | }//eo while |
Rybowonder | 3:bdf42b6c15f4 | 66 | return userSelection; |
Rybowonder | 3:bdf42b6c15f4 | 67 | } |