[c5c522c] | 1 | #include "lcd.h" |
---|
| 2 | #include "menu.h" |
---|
| 3 | |
---|
| 4 | |
---|
| 5 | |
---|
| 6 | extern menu_item MainMenu[]; |
---|
| 7 | extern menu_item OptionsMenu[]; |
---|
| 8 | extern int Shutdown_func(); |
---|
| 9 | extern int Close_func(); |
---|
| 10 | extern int OK_func(); |
---|
| 11 | extern int Time24_func(); |
---|
| 12 | extern int Contrast_func(); |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | menu_item MainMenu[] = { |
---|
| 16 | "MAIN MENU", 0, 0, // Title |
---|
| 17 | "Options", TYPE_MENU, (void *)OptionsMenu, |
---|
| 18 | "Kill LCDproc", TYPE_FUNC, (void *)Shutdown_func, |
---|
| 19 | "OK", TYPE_FUNC, (void *)OK_func, |
---|
| 20 | 0, 0, 0, |
---|
| 21 | |
---|
| 22 | }; |
---|
| 23 | |
---|
| 24 | menu_item OptionsMenu[] = { |
---|
| 25 | "OPTIONS MENU", TYPE_TITL, 0, // Title |
---|
| 26 | "24-hour Time", TYPE_CHEK, (void *)Time24_func, |
---|
| 27 | "Contrast...", TYPE_SLID, (void *)Contrast_func, |
---|
| 28 | "OK", TYPE_FUNC, (void *)OK_func, |
---|
| 29 | "Close Menu", TYPE_FUNC, (void *)Close_func, |
---|
| 30 | "Exit Program", TYPE_FUNC, (void *)Shutdown_func, |
---|
| 31 | "Another Title",TYPE_TITL, 0, |
---|
| 32 | 0, 0, 0, |
---|
| 33 | }; |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | ///////////////// Elsewhere, we declare these... |
---|
| 37 | |
---|
| 38 | int Shutdown_func() |
---|
| 39 | { |
---|
| 40 | // Do something here... |
---|
| 41 | return MENU_KILL; |
---|
| 42 | } |
---|
| 43 | |
---|
| 44 | int Close_func() |
---|
| 45 | { |
---|
| 46 | return MENU_CLOSE; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | int OK_func() |
---|
| 50 | { |
---|
| 51 | return MENU_OK; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | |
---|
| 55 | int Time24_func(int input) |
---|
| 56 | { |
---|
| 57 | static int status=0; |
---|
| 58 | |
---|
| 59 | if(input == MENU_READ) return status; |
---|
| 60 | if(input == MENU_CHECK) status ^= 1; // does something. |
---|
| 61 | return (status | MENU_OK); |
---|
| 62 | // The status is "or"-ed with the MENU value to let do_menu() |
---|
| 63 | // know what to do after selecting the item. (two return |
---|
| 64 | // values in one. :) |
---|
| 65 | |
---|
| 66 | // Also, "MENU_OK" happens to be zero, so it does not matter |
---|
| 67 | // unless you want something else (like MENU_CLOSE) |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | int Contrast_func(int input) |
---|
| 71 | { |
---|
| 72 | static int status=128; |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | if(input == MENU_READ) return status; |
---|
| 76 | if(input == MENU_PLUS) status++; // does something. |
---|
| 77 | if(input == MENU_MINUS) status--; // does something. |
---|
| 78 | return (status | MENU_OK); |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | |
---|
| 82 | void main() |
---|
| 83 | { |
---|
| 84 | lcd_init("", "curses"); |
---|
| 85 | |
---|
| 86 | do_menu(MainMenu); |
---|
| 87 | |
---|
| 88 | } |
---|