1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Robert E. Hak
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
26 #ifdef HAVE_LCD_BITMAP
33 struct menu_items
* items
;
39 #ifdef HAVE_LCD_BITMAP
45 #ifdef HAVE_NEW_CHARCELL_LCD
46 #define CURSOR_CHAR "\x7e"
48 #define CURSOR_CHAR "\x89"
51 static struct menu menus
[MAX_MENUS
];
52 static bool inuse
[MAX_MENUS
] = { false };
54 /* count in letter posistions, NOT pixels */
55 void put_cursorxy(int x
, int y
, bool on
)
57 /* place the cursor */
59 #ifdef HAVE_LCD_BITMAP
60 lcd_bitmap ( bitmap_icons_6x8
[Cursor
],
61 x
*6, y
*8, 4, 8, true);
62 #elif defined(SIMULATOR)
63 /* player simulator */
64 unsigned char cursor
[] = { 0x7f, 0x3e, 0x1c, 0x08 };
65 lcd_bitmap ( cursor
, x
*6, 12+y
*16, 4, 8, true);
67 lcd_puts(x
, y
, CURSOR_CHAR
);
71 #if defined(HAVE_LCD_BITMAP)
72 /* I use xy here since it needs to disregard the margins */
73 lcd_clearrect (x
*6, y
*8, 4, 8);
74 #elif defined(SIMULATOR)
75 /* player simulator in action */
76 lcd_clearrect (x
*6, 12+y
*16, 4, 8);
83 static void menu_draw(int m
)
89 #ifdef HAVE_LCD_BITMAP
93 for (i
= menus
[m
].top
;
94 (i
< menus
[m
].itemcount
) && (i
<menus
[m
].top
+MENU_LINES
);
96 if((menus
[m
].cursor
- menus
[m
].top
)==(i
-menus
[m
].top
))
97 lcd_puts_scroll(1, i
-menus
[m
].top
, menus
[m
].items
[i
].desc
);
99 lcd_puts(1, i
-menus
[m
].top
, menus
[m
].items
[i
].desc
);
102 /* place the cursor */
103 put_cursorxy(0, menus
[m
].cursor
- menus
[m
].top
, true);
108 * Move the cursor to a particular id,
109 * target: where you want it to be
111 static void put_cursor(int m
, int target
)
113 bool do_update
= true;
115 put_cursorxy(0, menus
[m
].cursor
- menus
[m
].top
, false);
116 menus
[m
].cursor
= target
;
119 if ( target
< menus
[m
].top
) {
124 else if ( target
-menus
[m
].top
> MENU_LINES
-1 ) {
131 put_cursorxy(0, menus
[m
].cursor
- menus
[m
].top
, true);
137 int menu_init(struct menu_items
* mitems
, int count
)
141 for ( i
=0; i
<MAX_MENUS
; i
++ ) {
147 if ( i
== MAX_MENUS
) {
148 DEBUGF("Out of menus!\n");
151 menus
[i
].items
= mitems
;
152 menus
[i
].itemcount
= count
;
159 void menu_exit(int m
)
169 switch( button_get(true) ) {
170 #ifdef HAVE_RECORDER_KEYPAD
174 case BUTTON_LEFT
| BUTTON_REPEAT
:
176 if (menus
[m
].cursor
) {
178 put_cursor(m
, menus
[m
].cursor
-1);
182 #ifdef HAVE_RECORDER_KEYPAD
186 case BUTTON_RIGHT
| BUTTON_REPEAT
:
188 if (menus
[m
].cursor
< menus
[m
].itemcount
-1) {
190 put_cursor(m
, menus
[m
].cursor
+1);
194 #ifdef HAVE_RECORDER_KEYPAD
198 /* Erase current display state */
202 menus
[m
].items
[menus
[m
].cursor
].function();
204 /* Return to previous display state */
208 #ifdef HAVE_RECORDER_KEYPAD