summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/menu.c55
1 files changed, 10 insertions, 45 deletions
diff --git a/apps/menu.c b/apps/menu.c
index 0455ecd6e8..36cb6152fb 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -34,50 +34,15 @@ static int itemcount;
34 * Move the cursor to a particular id, 34 * Move the cursor to a particular id,
35 * target: where you want it to be 35 * target: where you want it to be
36 */ 36 */
37void put_cursor(int target) 37static void put_cursor(int target)
38{ 38{
39 lcd_puts(0, cursor, " "); 39 lcd_puts(0, cursor, " ");
40 cursor = target; 40 cursor = target;
41 lcd_puts(0, cursor, "-"); 41 lcd_puts(0, cursor, "-");
42} 42}
43 43
44int is_cursor_menu_top(void)
45{
46 return ((cursor == menu_top) ? 1 : 0);
47}
48
49int is_cursor_menu_bottom(void)
50{
51 return ((cursor == menu_bottom) ? 1 : 0);
52}
53
54void put_cursor_menu_top(void)
55{
56 put_cursor(menu_top);
57}
58
59void put_cursor_menu_bottom(void)
60{
61 put_cursor(menu_bottom);
62}
63
64void move_cursor_up(void)
65{
66 put_cursor(cursor-1);
67}
68
69void move_cursor_down(void)
70{
71 put_cursor(cursor+1);
72}
73
74void redraw_cursor(void)
75{
76 lcd_puts(0, cursor, "-");
77}
78
79/* We call the function pointer related to the current cursor position */ 44/* We call the function pointer related to the current cursor position */
80void execute_menu_item(void) 45static void execute_menu_item(void)
81{ 46{
82 /* call the proper function for this line */ 47 /* call the proper function for this line */
83 items[cursor].function(); 48 items[cursor].function();
@@ -92,7 +57,7 @@ void menu_init(struct menu_items* mitems, int count)
92 cursor = menu_top; 57 cursor = menu_top;
93} 58}
94 59
95void menu_draw(void) 60static void menu_draw(void)
96{ 61{
97 int i = 0; 62 int i = 0;
98 63
@@ -109,7 +74,7 @@ void menu_draw(void)
109 menu_bottom = i; 74 menu_bottom = i;
110 } 75 }
111 76
112 redraw_cursor(); 77 lcd_puts(0, cursor, "-");
113 lcd_update(); 78 lcd_update();
114} 79}
115 80
@@ -132,12 +97,12 @@ void menu_run(void)
132#else 97#else
133 case BUTTON_LEFT: 98 case BUTTON_LEFT:
134#endif 99#endif
135 if(is_cursor_menu_top()){ 100 if (cursor == menu_top) {
136 /* wrap around to menu bottom */ 101 /* wrap around to menu bottom */
137 put_cursor_menu_bottom(); 102 put_cursor(menu_bottom);
138 } else { 103 } else {
139 /* move up */ 104 /* move up */
140 move_cursor_up(); 105 put_cursor(cursor-1);
141 } 106 }
142 break; 107 break;
143 108
@@ -146,12 +111,12 @@ void menu_run(void)
146#else 111#else
147 case BUTTON_RIGHT: 112 case BUTTON_RIGHT:
148#endif 113#endif
149 if(is_cursor_menu_bottom() ){ 114 if (cursor == menu_bottom) {
150 /* wrap around to menu top */ 115 /* wrap around to menu top */
151 put_cursor_menu_top(); 116 put_cursor(menu_top);
152 } else { 117 } else {
153 /* move down */ 118 /* move down */
154 move_cursor_down(); 119 put_cursor(cursor+1);
155 } 120 }
156 break; 121 break;
157 122