summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/playlist.c22
-rw-r--r--apps/recorder/icons.c169
-rw-r--r--apps/recorder/icons.h55
-rw-r--r--apps/recorder/widgets.c161
-rw-r--r--apps/recorder/widgets.h36
-rw-r--r--apps/settings.c8
-rw-r--r--apps/settings.h3
-rw-r--r--apps/settings_menu.c10
-rw-r--r--apps/status.c50
-rw-r--r--apps/status.h11
-rw-r--r--apps/tree.c97
-rw-r--r--apps/wps.c91
-rw-r--r--apps/wps.h2
-rw-r--r--firmware/drivers/lcd.c149
-rw-r--r--firmware/drivers/lcd.h17
-rw-r--r--uisimulator/win32/Makefile5
-rw-r--r--uisimulator/win32/lcd-win32.c4
-rw-r--r--uisimulator/x11/Makefile5
-rw-r--r--uisimulator/x11/lcd-x11.c16
19 files changed, 677 insertions, 234 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 44d1e34349..48c66dbc80 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -30,6 +30,13 @@
30#include "lcd.h" 30#include "lcd.h"
31#include "kernel.h" 31#include "kernel.h"
32#include "settings.h" 32#include "settings.h"
33#include "status.h"
34
35#ifdef HAVE_LCD_BITMAP
36#define LINE_Y (global_settings.statusbar&&statusbar_enabled?1:0) /* Y position the entry-list starts at */
37#else /* HAVE_LCD_BITMAP */
38#define LINE_Y 0 /* Y position the entry-list starts at */
39#endif /* HAVE_LCD_BITMAP */
33 40
34playlist_info_t playlist; 41playlist_info_t playlist;
35 42
@@ -165,7 +172,8 @@ void play_list(char *dir, char *file, int start_index)
165 /* If file is NULL, the list is in RAM */ 172 /* If file is NULL, the list is in RAM */
166 if(file) { 173 if(file) {
167 lcd_clear_display(); 174 lcd_clear_display();
168 lcd_puts(0,0,"Loading..."); 175 lcd_puts(0,LINE_Y,"Loading...");
176 status_draw();
169 lcd_update(); 177 lcd_update();
170 playlist.in_ram = false; 178 playlist.in_ram = false;
171 } else { 179 } else {
@@ -194,14 +202,16 @@ void play_list(char *dir, char *file, int start_index)
194 202
195 if(global_settings.playlist_shuffle) { 203 if(global_settings.playlist_shuffle) {
196 if(!playlist.in_ram) { 204 if(!playlist.in_ram) {
197 lcd_puts(0,0,"Shuffling..."); 205 lcd_puts(0,LINE_Y,"Shuffling...");
206 status_draw();
198 lcd_update(); 207 lcd_update();
199 } 208 }
200 randomise_playlist( current_tick ); 209 randomise_playlist( current_tick );
201 } 210 }
202 211
203 if(!playlist.in_ram) { 212 if(!playlist.in_ram) {
204 lcd_puts(0,0,"Playing... "); 213 lcd_puts(0,LINE_Y,"Playing... ");
214 status_draw();
205 lcd_update(); 215 lcd_update();
206 } 216 }
207 /* also make the first song get playing */ 217 /* also make the first song get playing */
@@ -287,7 +297,8 @@ void add_indices_to_playlist(void)
287 next_tick = current_tick + HZ; 297 next_tick = current_tick + HZ;
288 snprintf(line, sizeof line, "%d files", 298 snprintf(line, sizeof line, "%d files",
289 playlist.amount); 299 playlist.amount);
290 lcd_puts(0,1,line); 300 lcd_puts(0,LINE_Y+1,line);
301 status_draw();
291 lcd_update(); 302 lcd_update();
292 } 303 }
293 } 304 }
@@ -301,7 +312,8 @@ void add_indices_to_playlist(void)
301 } 312 }
302 if(!playlist.in_ram) { 313 if(!playlist.in_ram) {
303 snprintf(line, sizeof line, "%d files", playlist.amount); 314 snprintf(line, sizeof line, "%d files", playlist.amount);
304 lcd_puts(0,1,line); 315 lcd_puts(0,LINE_Y+1,line);
316 status_draw();
305 lcd_update(); 317 lcd_update();
306 close(fd); 318 close(fd);
307 } 319 }
diff --git a/apps/recorder/icons.c b/apps/recorder/icons.c
index 50475eb8c9..482c764b52 100644
--- a/apps/recorder/icons.c
+++ b/apps/recorder/icons.c
@@ -19,6 +19,12 @@
19#include <lcd.h> 19#include <lcd.h>
20 20
21#include "icons.h" 21#include "icons.h"
22#ifndef SIMULATOR
23#include "sprintf.h"
24#endif
25#ifdef HAVE_RTC
26#include "rtc.h"
27#endif
22 28
23#ifdef HAVE_LCD_BITMAP 29#ifdef HAVE_LCD_BITMAP
24 30
@@ -34,6 +40,12 @@ unsigned char slider_bar[] =
34 0x7c, 0x28, 0x28, 0x28, 0x28, 0x38 40 0x7c, 0x28, 0x28, 0x28, 0x28, 0x38
35}; 41};
36 42
43static unsigned char bitmap_icon_5x8[][5] =
44{
45 /* Lock */
46 {0x78,0x7f,0x49,0x7f,0x78}
47};
48
37unsigned char bitmap_icons_6x8[LastIcon][6] = 49unsigned char bitmap_icons_6x8[LastIcon][6] =
38{ 50{
39 /* Box_Filled */ 51 /* Box_Filled */
@@ -58,6 +70,36 @@ unsigned char bitmap_icons_6x8[LastIcon][6] =
58 { 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x00 }, 70 { 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x00 },
59}; 71};
60 72
73static unsigned char bitmap_icon_7x8[][7] =
74{
75 /* Power plug */
76 {0x08,0x1c,0x1c,0x3e,0x3e,0x14,0x14},
77 /* Speaker */
78 {0x00,0x1c,0x1c,0x3e,0x7f,0x00,0x00},
79 /* Speaker mute */
80 {0x01,0x1e,0x1c,0x3e,0x7f,0x20,0x40},
81 /* Play */
82 {0x00,0x7f,0x7f,0x3e,0x1c,0x08,0x00},
83 /* Stop */
84 {0x7f,0x7f,0x7f,0x7f,0x7f,0x7f,0x7f},
85 /* Pause */
86 {0x00,0x7f,0x7f,0x00,0x7f,0x7f,0x00},
87 /* Fast forward */
88 {0x7f,0x3e,0x1c,0x7f,0x3e,0x1c,0x08},
89 /* Fast backward */
90 {0x08,0x1c,0x3e,0x7f,0x1c,0x3e,0x7f},
91 /* Record */
92 {0x1c,0x3e,0x7f,0x7f,0x7f,0x3e,0x1c},
93 /* Record pause */
94 {0x1c,0x3e,0x7f,0x00,0x7f,0x3e,0x1c},
95 /* Normal playmode */
96 {0x08,0x08,0x08,0x08,0x3e,0x1c,0x08},
97 /* Repeat playmode */
98 {0x38,0x44,0x44,0x4e,0x5f,0x44,0x38},
99 /* Shuffle playmode (dice) */
100 {0x3e,0x41,0x51,0x41,0x45,0x41,0x3e}
101};
102
61unsigned char rockbox112x37[]={ 103unsigned char rockbox112x37[]={
62 0x00, 0x00, 0x02, 0xff, 0x02, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 104 0x00, 0x00, 0x02, 0xff, 0x02, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa,
63 0xf8, 0xf8, 0xf0, 0xe0, 0x80, 0x00, 0x00, 0x80, 0xe0, 0xf0, 0xf8, 0xf8, 0xfc, 105 0xf8, 0xf8, 0xf0, 0xe0, 0x80, 0x00, 0x00, 0x80, 0xe0, 0xf0, 0xf8, 0xf8, 0xfc,
@@ -111,4 +153,131 @@ unsigned char rockbox112x37[]={
111 153
112}; 154};
113 155
156/*
157 * Wipe statusbar
158 */
159void statusbar_wipe(void)
160{
161 int x;
162
163 for (x = 0; x < LCD_WIDTH; x++)
164 lcd_framebuffer[x][STATUSBAR_Y_POS/8]=0x00;
165}
166
167/*
168 * Print battery icon to status bar
169 */
170void statusbar_icon_battery(int percent, bool charging)
171{
172 int i,j;
173 int fill;
174
175 /* draw battery */
176 for(i=0;i<17;i++) {
177 DRAW_PIXEL((ICON_BATTERY_X_POS+i),STATUSBAR_Y_POS);
178 DRAW_PIXEL((ICON_BATTERY_X_POS+i),(STATUSBAR_Y_POS+6));
179 }
180 for(i=1;i<6;i++) {
181 DRAW_PIXEL(ICON_BATTERY_X_POS,(STATUSBAR_Y_POS+i));
182 DRAW_PIXEL((ICON_BATTERY_X_POS+16),(STATUSBAR_Y_POS+i));
183 }
184 for(i=2;i<5;i++)
185 DRAW_PIXEL((ICON_BATTERY_X_POS+17),(STATUSBAR_Y_POS+i));
186
187 /* fill battery */
188 fill=percent;
189 if(fill<0)
190 fill=0;
191 if(fill>100)
192 fill=100;
193 fill=fill*15/100;
194
195 for(i=1;i<=fill;i++)
196 for(j=1;j<6;j++)
197 DRAW_PIXEL((ICON_BATTERY_X_POS+i),(STATUSBAR_Y_POS+j));
198
199 if(charging)
200 lcd_bitmap(bitmap_icon_7x8[Icon_Plug], ICON_PLUG_X_POS, STATUSBAR_Y_POS, ICON_PLUG_WIDTH, STATUSBAR_HEIGHT, false);
201};
202
203/*
204 * Print volume gauge to status bar
205 */
206void statusbar_icon_volume(int percent)
207{
208 int i,j;
209 int volume;
210 int step=0;
211
212 volume=percent;
213 if(volume<0)
214 volume=0;
215 if(volume>100)
216 volume=100;
217
218 if(volume==0)
219 lcd_bitmap(bitmap_icon_7x8[Icon_Mute], ICON_VOLUME_X_POS+ICON_VOLUME_WIDTH/2-4, STATUSBAR_Y_POS, 7, STATUSBAR_HEIGHT, false);
220 else {
221 volume=volume*14/100;
222 for(i=0;i<volume;i++) {
223 if(i%2 == 0)
224 step++;
225 for(j=1;j<=step;j++)
226 DRAW_PIXEL((ICON_VOLUME_X_POS+i),(STATUSBAR_Y_POS+7-j));
227 }
228 }
229}
230
231/*
232 * Print play state to status bar
233 */
234void statusbar_icon_play_state(int state)
235{
236 lcd_bitmap(bitmap_icon_7x8[state], ICON_PLAY_STATE_X_POS, STATUSBAR_Y_POS, ICON_PLAY_STATE_WIDTH, STATUSBAR_HEIGHT, false);
237}
238
239/*
240 * Print play mode to status bar
241 */
242void statusbar_icon_play_mode(int mode)
243{
244 lcd_bitmap(bitmap_icon_7x8[mode], ICON_PLAY_MODE_X_POS, STATUSBAR_Y_POS, ICON_PLAY_MODE_WIDTH, STATUSBAR_HEIGHT, false);
245}
246
247/*
248 * Print shuffle mode to status bar
249 */
250void statusbar_icon_shuffle(void)
251{
252 lcd_bitmap(bitmap_icon_7x8[Icon_Shuffle], ICON_SHUFFLE_X_POS, STATUSBAR_Y_POS, ICON_SHUFFLE_WIDTH, STATUSBAR_HEIGHT, false);
253}
254
255/*
256 * Print lock when keys are locked
257 */
258void statusbar_icon_lock(void)
259{
260 lcd_bitmap(bitmap_icon_5x8[Icon_Lock], LOCK_X_POS, STATUSBAR_Y_POS, 5, 8, false);
261}
262
263#ifdef HAVE_RTC
264/*
265 * Print time to status bar
266 */
267void statusbar_time(void)
268{
269 int hour,minute;
270 unsigned char buffer[6];
271
272 hour = rtc_read(0x03);
273 minute = rtc_read(0x02);
274
275 snprintf(buffer, sizeof(buffer), "%d%d:%d%d",
276 (hour & 0x30) >> 4,
277 hour & 0x0f,
278 (minute & 0xf0) >> 4,
279 minute & 0x0f);
280 lcd_putsxy(TIME_X_POS, STATUSBAR_Y_POS, buffer, 0);
281}
282#endif
114#endif 283#endif
diff --git a/apps/recorder/icons.h b/apps/recorder/icons.h
index 866e4888f2..da94c2269a 100644
--- a/apps/recorder/icons.h
+++ b/apps/recorder/icons.h
@@ -36,9 +36,56 @@ extern unsigned char rockbox112x37[];
36 36
37extern unsigned char slider_bar[]; 37extern unsigned char slider_bar[];
38 38
39#endif /* End HAVE_LCD_BITMAP */ 39#define STATUSBAR_X_POS 0
40 40#define STATUSBAR_Y_POS 0 // MUST be a multiple of 8
41 41#define STATUSBAR_HEIGHT 8
42 42#define STATUSBAR_WIDTH LCD_WIDTH
43#define ICON_BATTERY_X_POS 0
44#define ICON_BATTERY_WIDTH 18
45#define ICON_PLUG_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+2
46#define ICON_PLUG_WIDTH 7
47#define ICON_VOLUME_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+2+2
48#define ICON_VOLUME_WIDTH 14
49#define ICON_PLAY_STATE_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+ICON_VOLUME_WIDTH+2+2+2
50#define ICON_PLAY_STATE_WIDTH 7
51#define ICON_PLAY_MODE_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+ICON_VOLUME_WIDTH+ICON_PLAY_STATE_WIDTH+2+2+2+2
52#define ICON_PLAY_MODE_WIDTH 7
53#define ICON_SHUFFLE_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+ICON_VOLUME_WIDTH+ICON_PLAY_STATE_WIDTH+ICON_PLAY_MODE_WIDTH+2+2+2+2+2
54#define ICON_SHUFFLE_WIDTH 7
55#define LOCK_X_POS STATUSBAR_X_POS+ICON_BATTERY_WIDTH+ICON_PLUG_WIDTH+ICON_VOLUME_WIDTH+ICON_PLAY_STATE_WIDTH+ICON_PLAY_MODE_WIDTH+ICON_SHUFFLE_WIDTH+2+2+2+2+2+2
56#define LOCK_WIDTH 5
57#define TIME_X_POS STATUSBAR_WIDTH-5*6-1
43 58
59/* Symbolic names for icons */
60enum
61{
62 Icon_Lock = 0
63};
64enum
65{
66 Icon_Plug = 0,
67 Icon_Speaker,
68 Icon_Mute,
69 Icon_Play,
70 Icon_Stop,
71 Icon_Pause,
72 Icon_FastForward,
73 Icon_FastBackward,
74 Icon_Record,
75 Icon_RecPause,
76 Icon_Normal,
77 Icon_Repeat,
78 Icon_Shuffle
79};
44 80
81extern void statusbar_wipe(void);
82extern void statusbar_icon_battery(int percent, bool charging);
83extern void statusbar_icon_volume(int percent);
84extern void statusbar_icon_play_state(int state);
85extern void statusbar_icon_play_mode(int mode);
86extern void statusbar_icon_shuffle(void);
87extern void statusbar_icon_lock(void);
88#ifdef HAVE_RTC
89extern void statusbar_time(void);
90#endif
91#endif /* End HAVE_LCD_BITMAP */
diff --git a/apps/recorder/widgets.c b/apps/recorder/widgets.c
new file mode 100644
index 0000000000..1c3f0b1a10
--- /dev/null
+++ b/apps/recorder/widgets.c
@@ -0,0 +1,161 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: not checked in
9 *
10 * Copyright (C) 2002 Markus Braun
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#include <lcd.h>
20
21#include "widgets.h"
22
23#ifdef HAVE_LCD_BITMAP
24/*
25 * Print a progress bar
26 */
27void progressbar(int x, int y, int width, int height, int percent, int direction)
28{
29 int pos;
30 int i,j;
31
32 /* draw horizontal lines */
33 for(i=x+1;i<=x+width-2;i++) {
34 DRAW_PIXEL(i,y);
35 DRAW_PIXEL(i,(y+height-1));
36 }
37
38 /* draw vertical lines */
39 for(i=1;i<height;i++) {
40 DRAW_PIXEL(x,(y+i));
41 DRAW_PIXEL((x+width-1),(y+i));
42 }
43
44 /* clear edge pixels */
45 CLEAR_PIXEL(x,y);
46 CLEAR_PIXEL((x+width-1),y);
47 CLEAR_PIXEL(x,(y+height-1));
48 CLEAR_PIXEL((x+width-1),(y+height-1));
49
50 /* clear pixels in progress bar */
51 for(i=1;i<=width-2;i++) {
52 for(j=1;j<=height-2;j++) {
53 CLEAR_PIXEL((x+i),(y+j));
54 CLEAR_PIXEL((x+i),(y+j));
55 }
56 }
57
58 /* draw bar */
59 pos=percent;
60 if(pos<0)
61 pos=0;
62 if(pos>100)
63 pos=100;
64
65 switch (direction)
66 {
67 case Grow_Right:
68 pos=(width-2)*pos/100;
69 for(i=1;i<=pos;i++)
70 for(j=1;j<height-1;j++)
71 DRAW_PIXEL((x+i),(y+j));
72 break;
73 case Grow_Left:
74 pos=(width-2)*(100-pos)/100;
75 for(i=pos+1;i<=width-2;i++)
76 for(j=1;j<height-1;j++)
77 DRAW_PIXEL((x+i),(y+j));
78 break;
79 case Grow_Down:
80 pos=(height-2)*pos/100;
81 for(i=1;i<=pos;i++)
82 for(j=1;j<width-1;j++)
83 DRAW_PIXEL((x+j),(y+i));
84 break;
85 case Grow_Up:
86 pos=(height-2)*(100-pos)/100;
87 for(i=pos+1;i<=height-2;i++)
88 for(j=1;j<width-1;j++)
89 DRAW_PIXEL((x+j),(y+i));
90 break;
91 }
92
93}
94
95
96/*
97 * Print a slidebar bar
98 */
99void slidebar(int x, int y, int width, int height, int percent, int direction)
100{
101 int pos;
102 int i,j;
103
104 /* draw horizontal lines */
105 for(i=x+1;i<=x+width-2;i++) {
106 DRAW_PIXEL(i,y);
107 DRAW_PIXEL(i,(y+height-1));
108 }
109
110 /* draw vertical lines */
111 for(i=1;i<height;i++) {
112 DRAW_PIXEL(x,(y+i));
113 DRAW_PIXEL((x+width-1),(y+i));
114 }
115
116 /* clear edge pixels */
117 CLEAR_PIXEL(x,y);
118 CLEAR_PIXEL((x+width-1),y);
119 CLEAR_PIXEL(x,(y+height-1));
120 CLEAR_PIXEL((x+width-1),(y+height-1));
121
122 /* clear pixels in progress bar */
123 for(i=1;i<=width-2;i++)
124 for(j=1;j<=height-2;j++) {
125 CLEAR_PIXEL((x+i),(y+j));
126 CLEAR_PIXEL((x+i),(y+j));
127 }
128
129 /* draw point */
130 pos=percent;
131 if(pos<0)
132 pos=0;
133 if(pos>100)
134 pos=100;
135
136 switch (direction)
137 {
138 case Grow_Right:
139 pos=(width-height-1)*pos/100;
140 break;
141 case Grow_Left:
142 pos=(width-height-1)*(100-pos)/100;
143 break;
144 case Grow_Down:
145 pos=(height-width-1)*pos/100;
146 break;
147 case Grow_Up:
148 pos=(height-width-1)*(100-pos)/100;
149 break;
150 }
151
152 if(direction == Grow_Left || direction == Grow_Right)
153 for(i=1;i<height;i++)
154 for(j=1;j<height;j++)
155 DRAW_PIXEL((x+pos+i),(y+j));
156 else
157 for(i=1;i<width;i++)
158 for(j=1;j<width;j++)
159 DRAW_PIXEL((x+i),(y+pos+j));
160}
161#endif
diff --git a/apps/recorder/widgets.h b/apps/recorder/widgets.h
new file mode 100644
index 0000000000..bae9f391de
--- /dev/null
+++ b/apps/recorder/widgets.h
@@ -0,0 +1,36 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: not checked in
9 *
10 * Copyright (C) 2002 Markus Braun
11 *
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.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef __WIDGETS_H__
20#define __WIDGETS_H__
21#include <lcd.h>
22
23#ifdef HAVE_LCD_BITMAP
24/* Directions for progressbar and scrollbar */
25enum
26{
27 Grow_Right = 0,
28 Grow_Left,
29 Grow_Down,
30 Grow_Up
31};
32
33extern void progressbar(int x, int y, int width, int height, int percent, int direction);
34extern void slidebar(int x, int y, int width, int height, int percent, int direction);
35#endif /* HAVE_LCD_BITMAP */
36#endif /* __WIDGETS_H__ */
diff --git a/apps/settings.c b/apps/settings.c
index 4160721e8a..f3e7e554ad 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -275,6 +275,9 @@ int settings_save( void )
275 275
276 rtc_config_block[0x11] = (unsigned char)global_settings.avc; 276 rtc_config_block[0x11] = (unsigned char)global_settings.avc;
277 277
278 rtc_config_block[0x12] = (unsigned char)
279 ((global_settings.statusbar & 1));
280
278 memcpy(&rtc_config_block[0x24], &global_settings.total_uptime, 4); 281 memcpy(&rtc_config_block[0x24], &global_settings.total_uptime, 4);
279 282
280 if(save_config_buffer()) 283 if(save_config_buffer())
@@ -347,6 +350,10 @@ void settings_load(void)
347 350
348 if (rtc_config_block[0x11] != 0xFF) 351 if (rtc_config_block[0x11] != 0xFF)
349 global_settings.avc = rtc_config_block[0x11]; 352 global_settings.avc = rtc_config_block[0x11];
353
354 if (rtc_config_block[0x12] != 0xFF) {
355 global_settings.statusbar = rtc_config_block[0x12] & 1;
356 }
350 357
351 if (rtc_config_block[0x24] != 0xFF) 358 if (rtc_config_block[0x24] != 0xFF)
352 memcpy(&global_settings.total_uptime, &rtc_config_block[0x24], 4); 359 memcpy(&global_settings.total_uptime, &rtc_config_block[0x24], 4);
@@ -378,6 +385,7 @@ void settings_reset(void) {
378 global_settings.wps_display = DEFAULT_WPS_DISPLAY; 385 global_settings.wps_display = DEFAULT_WPS_DISPLAY;
379 global_settings.mp3filter = true; 386 global_settings.mp3filter = true;
380 global_settings.sort_case = false; 387 global_settings.sort_case = false;
388 global_settings.statusbar = true;
381 global_settings.playlist_shuffle = false; 389 global_settings.playlist_shuffle = false;
382 global_settings.discharge = 0; 390 global_settings.discharge = 0;
383 global_settings.total_uptime = 0; 391 global_settings.total_uptime = 0;
diff --git a/apps/settings.h b/apps/settings.h
index b39ac73c89..e66bf8f53d 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -62,6 +62,9 @@ struct user_settings
62 62
63 /* while playing screen settings */ 63 /* while playing screen settings */
64 int wps_display; /* 0=id3, 1=file, 2=parse */ 64 int wps_display; /* 0=id3, 1=file, 2=parse */
65
66 /* show status bar */
67 bool statusbar; /* 0=hide, 1=show */
65 68
66 /* geeky persistent statistics */ 69 /* geeky persistent statistics */
67 unsigned int total_uptime; /* total uptime since rockbox was first booted */ 70 unsigned int total_uptime; /* total uptime since rockbox was first booted */
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 98c47b753c..7ab1b0479d 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -76,6 +76,13 @@ static void deep_discharge(void)
76} 76}
77#endif 77#endif
78 78
79#ifdef HAVE_LCD_BITMAP
80static void statusbar(void)
81{
82 set_bool( "[Show status bar]", &global_settings.statusbar );
83}
84#endif
85
79void settings_menu(void) 86void settings_menu(void)
80{ 87{
81 int m; 88 int m;
@@ -89,6 +96,9 @@ void settings_menu(void)
89#ifdef HAVE_CHARGE_CTRL 96#ifdef HAVE_CHARGE_CTRL
90 { "Deep discharge", deep_discharge }, 97 { "Deep discharge", deep_discharge },
91#endif 98#endif
99#ifdef HAVE_LCD_BITMAP
100 { "Status bar", statusbar },
101#endif
92 }; 102 };
93 bool old_shuffle = global_settings.playlist_shuffle; 103 bool old_shuffle = global_settings.playlist_shuffle;
94 104
diff --git a/apps/status.c b/apps/status.c
index fde7146a88..c4bd958964 100644
--- a/apps/status.c
+++ b/apps/status.c
@@ -24,8 +24,18 @@
24#include "settings.h" 24#include "settings.h"
25#include "status.h" 25#include "status.h"
26#include "mpeg.h" 26#include "mpeg.h"
27#include "wps.h"
28#ifdef HAVE_LCD_BITMAP
29#include "icons.h"
30#endif
31#include "power.h"
32
27static enum playmode current_mode; 33static enum playmode current_mode;
28 34
35#ifdef HAVE_LCD_BITMAP
36bool statusbar_enabled = true;
37#endif
38
29void status_init(void) 39void status_init(void)
30{ 40{
31 status_set_playmode(STATUS_STOP); 41 status_set_playmode(STATUS_STOP);
@@ -36,6 +46,22 @@ void status_set_playmode(enum playmode mode)
36 current_mode = mode; 46 current_mode = mode;
37} 47}
38 48
49#ifdef HAVE_LCD_BITMAP
50bool statusbar(bool state)
51{
52 bool laststate=statusbar_enabled;
53
54 statusbar_enabled=state;
55
56 return(laststate);
57}
58
59void statusbar_toggle(void)
60{
61 statusbar_enabled=!statusbar_enabled;
62}
63#endif
64
39void status_draw(void) 65void status_draw(void)
40{ 66{
41#if defined(HAVE_LCD_CHARCELLS) && !defined(SIMULATOR) 67#if defined(HAVE_LCD_CHARCELLS) && !defined(SIMULATOR)
@@ -97,4 +123,28 @@ void status_draw(void)
97 break; 123 break;
98 } 124 }
99#endif 125#endif
126#ifdef HAVE_LCD_BITMAP
127 int battlevel = battery_level();
128 int volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume);
129
130 if(global_settings.statusbar && statusbar_enabled) {
131 statusbar_wipe();
132#ifdef HAVE_CHARGE_CTRL
133 statusbar_icon_battery(battlevel,charger_enabled);
134#else
135 statusbar_icon_battery(battlevel,false);
136#endif
137 statusbar_icon_volume(volume);
138 statusbar_icon_play_state(current_mode+Icon_Play);
139 if (global_settings.loop_playlist)
140 statusbar_icon_play_mode(Icon_Repeat);
141 else
142 statusbar_icon_play_mode(Icon_Normal);
143 if(global_settings.playlist_shuffle) statusbar_icon_shuffle();
144 if (keys_locked) statusbar_icon_lock();
145#ifdef HAVE_RTC
146 statusbar_time();
147#endif
148 }
149#endif
100} 150}
diff --git a/apps/status.h b/apps/status.h
index 344d12f91b..41251bef28 100644
--- a/apps/status.h
+++ b/apps/status.h
@@ -23,11 +23,20 @@ enum playmode
23{ 23{
24 STATUS_PLAY, 24 STATUS_PLAY,
25 STATUS_STOP, 25 STATUS_STOP,
26 STATUS_PAUSE 26 STATUS_PAUSE,
27 STATUS_FASTFORWARD,
28 STATUS_FASTBACKWARD,
29 STATUS_RECORD,
30 STATUS_RECORD_PAUSE
27}; 31};
28 32
29void status_init(void); 33void status_init(void);
30void status_set_playmode(enum playmode mode); 34void status_set_playmode(enum playmode mode);
35#ifdef HAVE_LCD_BITMAP
36extern bool statusbar_enabled;
37bool statusbar(bool state);
38void statusbar_toggle(void);
39#endif
31void status_draw(void); 40void status_draw(void);
32 41
33#endif 42#endif
diff --git a/apps/tree.c b/apps/tree.c
index 733545aa17..68b893c78f 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -65,12 +65,12 @@ void browse_root(void)
65 65
66#ifdef HAVE_LCD_BITMAP 66#ifdef HAVE_LCD_BITMAP
67 67
68#define TREE_MAX_ON_SCREEN ((LCD_HEIGHT-MARGIN_Y)/LINE_HEIGTH) 68#define TREE_MAX_ON_SCREEN ((LCD_HEIGHT-MARGIN_Y)/LINE_HEIGTH-LINE_Y)
69#define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */ 69#define TREE_MAX_LEN_DISPLAY 16 /* max length that fits on screen */
70 70
71#define MARGIN_Y 0 /* Y pixel margin */ 71#define MARGIN_Y 0 /* Y pixel margin */
72#define MARGIN_X 12 /* X pixel margin */ 72#define MARGIN_X 12 /* X pixel margin */
73#define LINE_Y 0 /* Y position the entry-list starts at */ 73#define LINE_Y (global_settings.statusbar&&statusbar_enabled?1:0) /* Y position the entry-list starts at */
74#define LINE_X 2 /* X position the entry-list starts at */ 74#define LINE_X 2 /* X position the entry-list starts at */
75#define LINE_HEIGTH 8 /* pixels for each text line */ 75#define LINE_HEIGTH 8 /* pixels for each text line */
76 76
@@ -226,7 +226,7 @@ static int showdir(char *path, int start)
226 icon_type = File; 226 icon_type = File;
227 } 227 }
228 lcd_bitmap(bitmap_icons_6x8[icon_type], 228 lcd_bitmap(bitmap_icons_6x8[icon_type],
229 6, MARGIN_Y+(i-start)*LINE_HEIGTH, 6, 8, true); 229 6, MARGIN_Y+(LINE_Y+i-start)*LINE_HEIGTH, 6, 8, true);
230#endif 230#endif
231 231
232 /* if MP3 filter is on, cut off the extension */ 232 /* if MP3 filter is on, cut off the extension */
@@ -264,6 +264,7 @@ bool dirbrowse(char *root)
264{ 264{
265 char buf[MAX_PATH]; 265 char buf[MAX_PATH];
266 int i; 266 int i;
267 int lasti=-1;
267 int rc; 268 int rc;
268 int button; 269 int button;
269 int browse_speed = 0; 270 int browse_speed = 0;
@@ -274,33 +275,12 @@ bool dirbrowse(char *root)
274 if (numentries == -1) 275 if (numentries == -1)
275 return -1; /* root is not a directory */ 276 return -1; /* root is not a directory */
276 277
277 put_cursorxy(0, CURSOR_Y + dircursor, true); 278 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
278 279
279 while(1) { 280 while(1) {
280 bool restore = false; 281 bool restore = false;
281 282
282 if ( numentries ) { 283 button = button_get_w_tmo(HZ/5);
283 i = start+dircursor;
284
285 /* if MP3 filter is on, cut off the extension */
286 if (global_settings.mp3filter &&
287 (dircacheptr[i]->attr &
288 (TREE_ATTR_M3U|TREE_ATTR_MP3)))
289 {
290 int len = strlen(dircacheptr[i]->name);
291 char temp = dircacheptr[i]->name[len-4];
292 dircacheptr[i]->name[len-4] = 0;
293 lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
294 dircacheptr[i]->name);
295 dircacheptr[i]->name[len-4] = temp;
296 }
297 else
298 lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
299 dircacheptr[i]->name);
300 }
301 lcd_update();
302
303 button = button_get(true);
304 switch ( button ) { 284 switch ( button ) {
305 case TREE_EXIT: 285 case TREE_EXIT:
306 i=strlen(currdir); 286 i=strlen(currdir);
@@ -327,6 +307,8 @@ bool dirbrowse(char *root)
327 case BUTTON_OFF: 307 case BUTTON_OFF:
328 mpeg_stop(); 308 mpeg_stop();
329 status_set_playmode(STATUS_STOP); 309 status_set_playmode(STATUS_STOP);
310 status_draw();
311 restore = true;
330 break; 312 break;
331#endif 313#endif
332 314
@@ -389,7 +371,7 @@ bool dirbrowse(char *root)
389 if (browse_speed < TREE_MAX_ON_SCREEN - 1) { 371 if (browse_speed < TREE_MAX_ON_SCREEN - 1) {
390 /* moving the cursor up through a full screen */ 372 /* moving the cursor up through a full screen */
391 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, 373 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor,
392 false); 374 false);
393 dircursor--; 375 dircursor--;
394 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); 376 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
395 } 377 }
@@ -489,7 +471,7 @@ bool dirbrowse(char *root)
489 dircursor=7; 471 dircursor=7;
490 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); 472 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
491 } 473 }
492 474
493 } 475 }
494 else { 476 else {
495 /* leaving the cursor at bottom line and moving screen up */ 477 /* leaving the cursor at bottom line and moving screen up */
@@ -561,9 +543,15 @@ bool dirbrowse(char *root)
561 case TREE_MENU: { 543 case TREE_MENU: {
562 bool lastfilter = global_settings.mp3filter; 544 bool lastfilter = global_settings.mp3filter;
563 bool lastsortcase = global_settings.sort_case; 545 bool lastsortcase = global_settings.sort_case;
546#ifdef HAVE_LCD_BITMAP
547 bool laststate=statusbar(false);
548#endif
564 browse_speed = 0; 549 browse_speed = 0;
565 lcd_stop_scroll(); 550 lcd_stop_scroll();
566 main_menu(); 551 main_menu();
552#ifdef HAVE_LCD_BITMAP
553 statusbar(laststate);
554#endif
567 /* do we need to rescan dir? */ 555 /* do we need to rescan dir? */
568 if ( lastfilter != global_settings.mp3filter || 556 if ( lastfilter != global_settings.mp3filter ||
569 lastsortcase != global_settings.sort_case) 557 lastsortcase != global_settings.sort_case)
@@ -591,8 +579,26 @@ bool dirbrowse(char *root)
591 } 579 }
592 break; 580 break;
593 581
582#ifdef HAVE_RECORDER_KEYPAD
583 case BUTTON_F3:
584#endif
585#ifdef HAVE_LCD_BITMAP
586 if(global_settings.statusbar) {
587 statusbar_toggle();
588 if(CURSOR_Y+LINE_Y+dircursor>TREE_MAX_ON_SCREEN) {
589 start++;
590 dircursor--;
591 }
592 restore = true;
593 }
594#endif
595 break;
596
594#ifndef SIMULATOR 597#ifndef SIMULATOR
595 case SYS_USB_CONNECTED: 598 case SYS_USB_CONNECTED: {
599#ifdef HAVE_LCD_BITMAP
600 bool laststate=statusbar(false);
601#endif
596 /* Tell the USB thread that we are safe */ 602 /* Tell the USB thread that we are safe */
597 DEBUGF("dirbrowse got SYS_USB_CONNECTED\n"); 603 DEBUGF("dirbrowse got SYS_USB_CONNECTED\n");
598 usb_acknowledge(SYS_USB_CONNECTED_ACK); 604 usb_acknowledge(SYS_USB_CONNECTED_ACK);
@@ -607,7 +613,11 @@ bool dirbrowse(char *root)
607 dirlevel = 0; 613 dirlevel = 0;
608 dircursor = 0; 614 dircursor = 0;
609 start = 0; 615 start = 0;
610 break; 616#ifdef HAVE_LCD_BITMAP
617 statusbar(laststate);
618#endif
619 }
620 break;
611#endif 621#endif
612 } 622 }
613 623
@@ -617,7 +627,32 @@ bool dirbrowse(char *root)
617 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true); 627 put_cursorxy(0, CURSOR_Y + LINE_Y+dircursor, true);
618 } 628 }
619 629
620 lcd_stop_scroll(); 630 if ( numentries ) {
631 i = start+dircursor;
632
633 /* if MP3 filter is on, cut off the extension */
634 if(lasti!=i || restore) {
635 lasti=i;
636 lcd_stop_scroll();
637 if (global_settings.mp3filter &&
638 (dircacheptr[i]->attr &
639 (TREE_ATTR_M3U|TREE_ATTR_MP3)))
640 {
641 int len = strlen(dircacheptr[i]->name);
642 char temp = dircacheptr[i]->name[len-4];
643 dircacheptr[i]->name[len-4] = 0;
644 lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
645 dircacheptr[i]->name);
646 dircacheptr[i]->name[len-4] = temp;
647 }
648 else
649 lcd_puts_scroll(LINE_X, LINE_Y+dircursor,
650 dircacheptr[i]->name);
651 }
652 }
653 status_draw();
654 lcd_update();
655
621 } 656 }
622 657
623 return false; 658 return false;
diff --git a/apps/wps.c b/apps/wps.c
index c3398e2ea4..db97a3c708 100644
--- a/apps/wps.c
+++ b/apps/wps.c
@@ -34,8 +34,16 @@
34#include "power.h" 34#include "power.h"
35#include "status.h" 35#include "status.h"
36#include "main_menu.h" 36#include "main_menu.h"
37#ifdef HAVE_LCD_BITMAP
38#include "icons.h"
39#include "widgets.h"
40#endif
37 41
38#define LINE_Y 1 /* initial line */ 42#ifdef HAVE_LCD_BITMAP
43#define LINE_Y (global_settings.statusbar&&statusbar_enabled?1:0) /* Y position the entry-list starts at */
44#else /* HAVE_LCD_BITMAP */
45#define LINE_Y 0 /* Y position the entry-list starts at */
46#endif /* HAVE_LCD_BITMAP */
39 47
40#define PLAY_DISPLAY_DEFAULT 0 48#define PLAY_DISPLAY_DEFAULT 0
41#define PLAY_DISPLAY_FILENAME_SCROLL 1 49#define PLAY_DISPLAY_FILENAME_SCROLL 1
@@ -47,6 +55,8 @@
47#define RELEASE_MASK (BUTTON_MENU | BUTTON_STOP) 55#define RELEASE_MASK (BUTTON_MENU | BUTTON_STOP)
48#endif 56#endif
49 57
58bool keys_locked = false;
59
50static void draw_screen(struct mp3entry* id3) 60static void draw_screen(struct mp3entry* id3)
51{ 61{
52 lcd_clear_display(); 62 lcd_clear_display();
@@ -83,14 +93,14 @@ static void draw_screen(struct mp3entry* id3)
83 strncpy(szArtist,szTok,sizeof(szArtist)); 93 strncpy(szArtist,szTok,sizeof(szArtist));
84 szArtist[sizeof(szArtist)-1] = 0; 94 szArtist[sizeof(szArtist)-1] = 0;
85 szDelimit = strrchr(id3->path, ch); 95 szDelimit = strrchr(id3->path, ch);
86 lcd_puts(0,0, szArtist?szArtist:"<nothing>"); 96 lcd_puts(0,LINE_Y, szArtist?szArtist:"<nothing>");
87 97
88 // removes the .mp3 from the end of the display buffer 98 // removes the .mp3 from the end of the display buffer
89 szPeriod = strrchr(szDelimit, '.'); 99 szPeriod = strrchr(szDelimit, '.');
90 if (szPeriod != NULL) 100 if (szPeriod != NULL)
91 *szPeriod = 0; 101 *szPeriod = 0;
92 102
93 lcd_puts_scroll(0,LINE_Y,(++szDelimit)); 103 lcd_puts_scroll(0,LINE_Y+1,(++szDelimit));
94 break; 104 break;
95 } 105 }
96 case PLAY_DISPLAY_FILENAME_SCROLL: 106 case PLAY_DISPLAY_FILENAME_SCROLL:
@@ -99,14 +109,14 @@ static void draw_screen(struct mp3entry* id3)
99 char* szLast = strrchr(id3->path, ch); 109 char* szLast = strrchr(id3->path, ch);
100 110
101 if (szLast) 111 if (szLast)
102 lcd_puts_scroll(0,0, (++szLast)); 112 lcd_puts_scroll(0,LINE_Y, (++szLast));
103 else 113 else
104 lcd_puts_scroll(0,0, id3->path); 114 lcd_puts_scroll(0,LINE_Y, id3->path);
105 break; 115 break;
106 } 116 }
107 case PLAY_DISPLAY_DEFAULT: 117 case PLAY_DISPLAY_DEFAULT:
108 { 118 {
109 int l = 0; 119 int l = LINE_Y;
110#ifdef HAVE_LCD_BITMAP 120#ifdef HAVE_LCD_BITMAP
111 char buffer[64]; 121 char buffer[64];
112 122
@@ -115,16 +125,28 @@ static void draw_screen(struct mp3entry* id3)
115 lcd_puts(0, l++, id3->album?id3->album:""); 125 lcd_puts(0, l++, id3->album?id3->album:"");
116 lcd_puts(0, l++, id3->artist?id3->artist:""); 126 lcd_puts(0, l++, id3->artist?id3->artist:"");
117 127
118 if(id3->vbr) 128 if(LINE_Y==0) {
119 snprintf(buffer, sizeof(buffer), "%d kbit (avg)", 129 if(id3->vbr)
120 id3->bitrate); 130 snprintf(buffer, sizeof(buffer), "%d kbit (avg)",
121 else 131 id3->bitrate);
122 snprintf(buffer, sizeof(buffer), "%d kbit", id3->bitrate); 132 else
133 snprintf(buffer, sizeof(buffer), "%d kbit", id3->bitrate);
134
135 lcd_puts(0, l++, buffer);
123 136
124 lcd_puts(0, l++, buffer); 137 snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency);
138 lcd_puts(0, l++, buffer);
139 }
140 else {
141 if(id3->vbr)
142 snprintf(buffer, sizeof(buffer), "%dkbit(a) %dHz",
143 id3->bitrate, id3->frequency);
144 else
145 snprintf(buffer, sizeof(buffer), "%dkbit %dHz",
146 id3->bitrate, id3->frequency);
125 147
126 snprintf(buffer,sizeof(buffer), "%d Hz", id3->frequency); 148 lcd_puts(0, l++, buffer);
127 lcd_puts(0, l++, buffer); 149 }
128#else 150#else
129 151
130 lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>"); 152 lcd_puts(0, l++, id3->artist?id3->artist:"<no artist>");
@@ -166,7 +188,6 @@ void display_keylock_text(bool locked)
166int wps_show(void) 188int wps_show(void)
167{ 189{
168 struct mp3entry* id3 = NULL; 190 struct mp3entry* id3 = NULL;
169 bool keys_locked = false;
170 bool dont_go_to_menu = false; 191 bool dont_go_to_menu = false;
171 bool menu_button_is_down = false; 192 bool menu_button_is_down = false;
172 bool pending_keylock = true; /* Keylock will go ON next time */ 193 bool pending_keylock = true; /* Keylock will go ON next time */
@@ -364,9 +385,15 @@ int wps_show(void)
364#endif 385#endif
365 if(!keys_locked && !dont_go_to_menu && menu_button_is_down) 386 if(!keys_locked && !dont_go_to_menu && menu_button_is_down)
366 { 387 {
388#ifdef HAVE_LCD_BITMAP
389 bool laststate=statusbar(false);
390#endif
367 lcd_stop_scroll(); 391 lcd_stop_scroll();
368 button_set_release(old_release_mask); 392 button_set_release(old_release_mask);
369 main_menu(); 393 main_menu();
394#ifdef HAVE_LCD_BITMAP
395 statusbar(laststate);
396#endif
370 old_release_mask = button_set_release(RELEASE_MASK); 397 old_release_mask = button_set_release(RELEASE_MASK);
371 id3 = mpeg_current_track(); 398 id3 = mpeg_current_track();
372 draw_screen(id3); 399 draw_screen(id3);
@@ -379,6 +406,17 @@ int wps_show(void)
379 break; 406 break;
380 407
381#ifdef HAVE_RECORDER_KEYPAD 408#ifdef HAVE_RECORDER_KEYPAD
409 case BUTTON_F3:
410#ifdef HAVE_LCD_BITMAP
411 if(global_settings.statusbar) {
412 statusbar_toggle();
413 draw_screen(id3);
414 }
415#endif
416 break;
417#endif
418
419#ifdef HAVE_RECORDER_KEYPAD
382 case BUTTON_OFF: 420 case BUTTON_OFF:
383#else 421#else
384 case BUTTON_STOP: 422 case BUTTON_STOP:
@@ -396,7 +434,10 @@ int wps_show(void)
396 return 0; 434 return 0;
397 435
398#ifndef SIMULATOR 436#ifndef SIMULATOR
399 case SYS_USB_CONNECTED: 437 case SYS_USB_CONNECTED: {
438#ifdef HAVE_LCD_BITMAP
439 bool laststate=statusbar(false);
440#endif
400 /* Tell the USB thread that we are safe */ 441 /* Tell the USB thread that we are safe */
401 DEBUGF("wps got SYS_USB_CONNECTED\n"); 442 DEBUGF("wps got SYS_USB_CONNECTED\n");
402 usb_acknowledge(SYS_USB_CONNECTED_ACK); 443 usb_acknowledge(SYS_USB_CONNECTED_ACK);
@@ -404,16 +445,20 @@ int wps_show(void)
404 /* Wait until the USB cable is extracted again */ 445 /* Wait until the USB cable is extracted again */
405 usb_wait_for_disconnect(&button_queue); 446 usb_wait_for_disconnect(&button_queue);
406 447
448#ifdef HAVE_LCD_BITMAP
449 statusbar(laststate);
450#endif
407 /* Signal to our caller that we have been in USB mode */ 451 /* Signal to our caller that we have been in USB mode */
408 return SYS_USB_CONNECTED; 452 return SYS_USB_CONNECTED;
409 break; 453 break;
454 }
410#endif 455#endif
411 case BUTTON_NONE: /* Timeout */ 456 case BUTTON_NONE: /* Timeout */
412 if (mpeg_is_playing() && id3) 457 if (mpeg_is_playing() && id3)
413 { 458 {
414#ifdef HAVE_LCD_BITMAP 459#ifdef HAVE_LCD_BITMAP
415 snprintf(buffer,sizeof(buffer), 460 snprintf(buffer,sizeof(buffer),
416 "Time: %d:%02d / %d:%02d", 461 "Time:%3d:%02d/%d:%02d",
417 id3->elapsed / 60000, 462 id3->elapsed / 60000,
418 id3->elapsed % 60000 / 1000, 463 id3->elapsed % 60000 / 1000,
419 id3->length / 60000, 464 id3->length / 60000,
@@ -421,9 +466,9 @@ int wps_show(void)
421 466
422 lcd_puts(0, 6, buffer); 467 lcd_puts(0, 6, buffer);
423 468
424 lcd_slidebar(1, LCD_HEIGHT-7, LCD_WIDTH-2, 5, 469 slidebar(0, LCD_HEIGHT-6, LCD_WIDTH, 6,
425 id3->elapsed*100/id3->length, 470 id3->elapsed*100/id3->length,
426 BAR_RIGHT); 471 Grow_Right);
427 472
428 lcd_update(); 473 lcd_update();
429#else 474#else
@@ -432,7 +477,7 @@ int wps_show(void)
432 if (global_settings.wps_display == 477 if (global_settings.wps_display ==
433 PLAY_DISPLAY_FILENAME_SCROLL) 478 PLAY_DISPLAY_FILENAME_SCROLL)
434 { 479 {
435 snprintf(buffer,sizeof(buffer), "%d:%02d/%d:%02d", 480 snprintf(buffer,sizeof(buffer), "Time:%3d:%02d/%d:%02d",
436 id3->elapsed / 60000, 481 id3->elapsed / 60000,
437 id3->elapsed % 60000 / 1000, 482 id3->elapsed % 60000 / 1000,
438 id3->length / 60000, 483 id3->length / 60000,
@@ -445,12 +490,6 @@ int wps_show(void)
445 } 490 }
446 491
447 status_draw(); 492 status_draw();
448#ifdef HAVE_LCD_BITMAP
449 /* draw battery indicator line */
450 lcd_clearline(0,LCD_HEIGHT-1,LCD_WIDTH-1, LCD_HEIGHT-1);
451 lcd_drawline(0,LCD_HEIGHT-1,battery_level() *
452 (LCD_WIDTH-1) / 100, LCD_HEIGHT-1);
453#endif
454 break; 493 break;
455 } 494 }
456 } 495 }
diff --git a/apps/wps.h b/apps/wps.h
index 4b4e63efc5..b0673157f4 100644
--- a/apps/wps.h
+++ b/apps/wps.h
@@ -21,6 +21,8 @@
21#include "id3.h" 21#include "id3.h"
22#include "playlist.h" 22#include "playlist.h"
23 23
24extern bool keys_locked;
25
24int wps_show(void); 26int wps_show(void);
25 27
26#endif 28#endif
diff --git a/firmware/drivers/lcd.c b/firmware/drivers/lcd.c
index 5e86647280..fe1e13a522 100644
--- a/firmware/drivers/lcd.c
+++ b/firmware/drivers/lcd.c
@@ -529,7 +529,7 @@ void lcd_init (void)
529 * 529 *
530 * Memory copy of display bitmap 530 * Memory copy of display bitmap
531 */ 531 */
532unsigned char display[LCD_WIDTH][LCD_HEIGHT/8] __attribute__ ((section (".idata"))); 532unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8] __attribute__ ((section (".idata")));
533 533
534static int font=0; 534static int font=0;
535static int xmargin=0; 535static int xmargin=0;
@@ -590,7 +590,7 @@ void lcd_update (void)
590 lcd_write (true, LCD_CNTL_LOWCOL); 590 lcd_write (true, LCD_CNTL_LOWCOL);
591 591
592 for (x = 0; x < LCD_WIDTH; x++) 592 for (x = 0; x < LCD_WIDTH; x++)
593 lcd_write (false, display[x][y]); 593 lcd_write (false, lcd_framebuffer[x][y]);
594 } 594 }
595} 595}
596 596
@@ -601,7 +601,7 @@ void lcd_update (void)
601 */ 601 */
602void lcd_clear_display (void) 602void lcd_clear_display (void)
603{ 603{
604 memset (display, 0, sizeof display); 604 memset (lcd_framebuffer, 0, sizeof lcd_framebuffer);
605#if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS) 605#if defined(SIMULATOR) && defined(HAVE_LCD_CHARCELLS)
606 /* this function is being used when simulating a charcell LCD and 606 /* this function is being used when simulating a charcell LCD and
607 then we update immediately */ 607 then we update immediately */
@@ -791,7 +791,7 @@ void lcd_bitmap (unsigned char *src, int x, int y, int nx, int ny,
791 ny = LCD_HEIGHT - y; 791 ny = LCD_HEIGHT - y;
792 792
793 shift = y & 7; 793 shift = y & 7;
794 dst2 = &display[x][y/8]; 794 dst2 = &lcd_framebuffer[x][y/8];
795 ny += shift; 795 ny += shift;
796 796
797 /* Calculate bit masks */ 797 /* Calculate bit masks */
@@ -881,9 +881,6 @@ void lcd_invertrect (int x, int y, int nx, int ny)
881 lcd_bitmap (ones, x+i, y, 1, ny, false); 881 lcd_bitmap (ones, x+i, y, 1, ny, false);
882} 882}
883 883
884#define DRAW_PIXEL(x,y) display[x][y/8] |= (1<<(y&7))
885#define CLEAR_PIXEL(x,y) display[x][y/8] &= ~(1<<(y&7))
886
887void lcd_drawline( int x1, int y1, int x2, int y2 ) 884void lcd_drawline( int x1, int y1, int x2, int y2 )
888{ 885{
889 int numpixels; 886 int numpixels;
@@ -1051,144 +1048,6 @@ void lcd_getfontsize(unsigned int font, int *width, int *height)
1051 } 1048 }
1052} 1049}
1053 1050
1054/*
1055 * Print a progress bar
1056 */
1057void lcd_progressbar(int x, int y, int width, int height, int percent, int direction)
1058{
1059 int pos;
1060 int i,j;
1061
1062 /* draw horizontal lines */
1063 for(i=x+1;i<=x+width-2;i++) {
1064 DRAW_PIXEL(i,y);
1065 DRAW_PIXEL(i,(y+height-1));
1066 }
1067
1068 /* draw vertical lines */
1069 for(i=1;i<height;i++) {
1070 DRAW_PIXEL(x,(y+i));
1071 DRAW_PIXEL((x+width-1),(y+i));
1072 }
1073
1074 /* clear edge pixels */
1075 CLEAR_PIXEL(x,y);
1076 CLEAR_PIXEL((x+width-1),y);
1077 CLEAR_PIXEL(x,(y+height-1));
1078 CLEAR_PIXEL((x+width-1),(y+height-1));
1079
1080 /* clear pixels in progress bar */
1081 for(i=1;i<=width-2;i++) {
1082 for(j=1;j<=height-2;j++) {
1083 CLEAR_PIXEL((x+i),(y+j));
1084 CLEAR_PIXEL((x+i),(y+j));
1085 }
1086 }
1087
1088 /* draw bar */
1089 pos=percent;
1090 if(pos<0)
1091 pos=0;
1092 if(pos>100)
1093 pos=100;
1094
1095 switch (direction)
1096 {
1097 case BAR_RIGHT:
1098 pos=(width-2)*pos/100;
1099 for(i=1;i<=pos;i++)
1100 for(j=1;j<height-1;j++)
1101 DRAW_PIXEL((x+i),(y+j));
1102 break;
1103 case BAR_LEFT:
1104 pos=(width-2)*(100-pos)/100;
1105 for(i=pos+1;i<=width-2;i++)
1106 for(j=1;j<height-1;j++)
1107 DRAW_PIXEL((x+i),(y+j));
1108 break;
1109 case BAR_DOWN:
1110 pos=(height-2)*pos/100;
1111 for(i=1;i<=pos;i++)
1112 for(j=1;j<width-1;j++)
1113 DRAW_PIXEL((x+j),(y+i));
1114 break;
1115 case BAR_UP:
1116 pos=(height-2)*(100-pos)/100;
1117 for(i=pos+1;i<=height-2;i++)
1118 for(j=1;j<width-1;j++)
1119 DRAW_PIXEL((x+j),(y+i));
1120 break;
1121 }
1122
1123}
1124
1125
1126/*
1127 * Print a slidebar bar
1128 */
1129void lcd_slidebar(int x, int y, int width, int height, int percent, int direction)
1130{
1131 int pos;
1132 int i,j;
1133
1134 /* draw horizontal lines */
1135 for(i=x+1;i<=x+width-2;i++) {
1136 DRAW_PIXEL(i,y);
1137 DRAW_PIXEL(i,(y+height-1));
1138 }
1139
1140 /* draw vertical lines */
1141 for(i=1;i<height;i++) {
1142 DRAW_PIXEL(x,(y+i));
1143 DRAW_PIXEL((x+width-1),(y+i));
1144 }
1145
1146 /* clear edge pixels */
1147 CLEAR_PIXEL(x,y);
1148 CLEAR_PIXEL((x+width-1),y);
1149 CLEAR_PIXEL(x,(y+height-1));
1150 CLEAR_PIXEL((x+width-1),(y+height-1));
1151
1152 /* clear pixels in progress bar */
1153 for(i=1;i<=width-2;i++)
1154 for(j=1;j<=height-2;j++) {
1155 CLEAR_PIXEL((x+i),(y+j));
1156 CLEAR_PIXEL((x+i),(y+j));
1157 }
1158
1159 /* draw point */
1160 pos=percent;
1161 if(pos<0)
1162 pos=0;
1163 if(pos>100)
1164 pos=100;
1165
1166 switch (direction)
1167 {
1168 case BAR_RIGHT:
1169 pos=(width-height-1)*pos/100;
1170 break;
1171 case BAR_LEFT:
1172 pos=(width-height-1)*(100-pos)/100;
1173 break;
1174 case BAR_DOWN:
1175 pos=(height-width-1)*pos/100;
1176 break;
1177 case BAR_UP:
1178 pos=(height-width-1)*(100-pos)/100;
1179 break;
1180 }
1181
1182 if(direction == BAR_LEFT || direction == BAR_RIGHT)
1183 for(i=1;i<height;i++)
1184 for(j=1;j<height;j++)
1185 DRAW_PIXEL((x+pos+i),(y+j));
1186 else
1187 for(i=1;i<width;i++)
1188 for(j=1;j<width;j++)
1189 DRAW_PIXEL((x+i),(y+pos+j));
1190}
1191
1192#else 1051#else
1193/* no LCD defined, no code to use */ 1052/* no LCD defined, no code to use */
1194#endif 1053#endif
diff --git a/firmware/drivers/lcd.h b/firmware/drivers/lcd.h
index c985cb067d..23e333287b 100644
--- a/firmware/drivers/lcd.h
+++ b/firmware/drivers/lcd.h
@@ -74,14 +74,13 @@ extern void lcd_double_height (bool on);
74#define LCD_WIDTH 112 /* Display width in pixels */ 74#define LCD_WIDTH 112 /* Display width in pixels */
75#define LCD_HEIGHT 64 /* Display height in pixels */ 75#define LCD_HEIGHT 64 /* Display height in pixels */
76 76
77/* Directions for progressbar and scrollbar */ 77#define DRAW_PIXEL(x,y) lcd_framebuffer[x][y/8] |= (1<<(y&7))
78enum 78#define CLEAR_PIXEL(x,y) lcd_framebuffer[x][y/8] &= ~(1<<(y&7))
79{ 79
80 BAR_RIGHT = 0, 80/*
81 BAR_LEFT, 81 * Memory copy of display bitmap
82 BAR_DOWN, 82 */
83 BAR_UP 83extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8] __attribute__ ((section (".idata")));
84};
85 84
86extern void lcd_putsxy(int x, int y, unsigned char *string, int font); 85extern void lcd_putsxy(int x, int y, unsigned char *string, int font);
87extern void lcd_setfont(int font); 86extern void lcd_setfont(int font);
@@ -97,8 +96,6 @@ extern void lcd_drawline( int x1, int y1, int x2, int y2 );
97extern void lcd_clearline( int x1, int y1, int x2, int y2 ); 96extern void lcd_clearline( int x1, int y1, int x2, int y2 );
98extern void lcd_drawpixel(int x, int y); 97extern void lcd_drawpixel(int x, int y);
99extern void lcd_clearpixel(int x, int y); 98extern void lcd_clearpixel(int x, int y);
100extern void lcd_progressbar(int x, int y, int width, int height, int percent, int direction);
101extern void lcd_slidebar(int x, int y, int width, int height, int percent, int direction);
102 99
103#endif /* CHARCELLS / BITMAP */ 100#endif /* CHARCELLS / BITMAP */
104 101
diff --git a/uisimulator/win32/Makefile b/uisimulator/win32/Makefile
index 3a84a2dd70..4cdcef345e 100644
--- a/uisimulator/win32/Makefile
+++ b/uisimulator/win32/Makefile
@@ -68,7 +68,7 @@ APPS = main.c tree.c menu.c credits.c main_menu.c\
68MENUS = games_menu.c screensavers_menu.c settings_menu.c sound_menu.c 68MENUS = games_menu.c screensavers_menu.c settings_menu.c sound_menu.c
69 69
70ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP) 70ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
71 APPS += tetris.c sokoban.c bounce.c boxes.c icons.c bmp.c 71 APPS += tetris.c sokoban.c bounce.c boxes.c icons.c bmp.c widgets.c
72endif 72endif
73 73
74SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \ 74SRCS = button.c dir-win32.c lcd-win32.c panic-win32.c thread-win32.c \
@@ -116,6 +116,9 @@ $(OBJDIR)/settings_menu.o: $(APPDIR)/settings_menu.c
116$(OBJDIR)/icons.o: $(RECDIR)/icons.c 116$(OBJDIR)/icons.o: $(RECDIR)/icons.c
117 $(CC) $(APPCFLAGS) -c $< -o $@ 117 $(CC) $(APPCFLAGS) -c $< -o $@
118 118
119$(OBJDIR)/widgets.o: $(RECDIR)/widgets.c
120 $(CC) $(APPCFLAGS) -c $< -o $@
121
119$(OBJDIR)/tetris.o: $(RECDIR)/tetris.c 122$(OBJDIR)/tetris.o: $(RECDIR)/tetris.c
120 $(CC) $(APPCFLAGS) -c $< -o $@ 123 $(CC) $(APPCFLAGS) -c $< -o $@
121 124
diff --git a/uisimulator/win32/lcd-win32.c b/uisimulator/win32/lcd-win32.c
index 510117ed9d..102e262346 100644
--- a/uisimulator/win32/lcd-win32.c
+++ b/uisimulator/win32/lcd-win32.c
@@ -27,7 +27,7 @@
27// 27//
28 28
29// varaibles 29// varaibles
30unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; // the display 30unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8]; // the display
31char bitmap[LCD_HEIGHT][LCD_WIDTH]; // the ui display 31char bitmap[LCD_HEIGHT][LCD_WIDTH]; // the ui display
32 32
33BITMAPINFO2 bmi = 33BITMAPINFO2 bmi =
@@ -54,7 +54,7 @@ void lcd_update()
54 54
55 for (x = 0; x < LCD_WIDTH; x++) 55 for (x = 0; x < LCD_WIDTH; x++)
56 for (y = 0; y < LCD_HEIGHT; y++) 56 for (y = 0; y < LCD_HEIGHT; y++)
57 bitmap[y][x] = ((display[x][y/8] >> (y & 7)) & 1); 57 bitmap[y][x] = ((lcd_framebuffer[x][y/8] >> (y & 7)) & 1);
58 58
59 InvalidateRect (hGUIWnd, NULL, FALSE); 59 InvalidateRect (hGUIWnd, NULL, FALSE);
60 60
diff --git a/uisimulator/x11/Makefile b/uisimulator/x11/Makefile
index 3d40303271..e327a1cdb9 100644
--- a/uisimulator/x11/Makefile
+++ b/uisimulator/x11/Makefile
@@ -81,7 +81,7 @@ APPS = main.c tree.c menu.c credits.c main_menu.c\
81MENUS = games_menu.c screensavers_menu.c settings_menu.c sound_menu.c 81MENUS = games_menu.c screensavers_menu.c settings_menu.c sound_menu.c
82 82
83ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP) 83ifeq ($(DISPLAY),-DHAVE_LCD_BITMAP)
84 APPS += tetris.c sokoban.c bounce.c boxes.c icons.c bmp.c 84 APPS += tetris.c sokoban.c bounce.c boxes.c icons.c bmp.c widgets.c
85endif 85endif
86 86
87SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \ 87SRCS = screenhack.c uibasic.c resources.c visual.c lcd-x11.c stubs.c \
@@ -167,6 +167,9 @@ $(OBJDIR)/settings_menu.o: $(APPDIR)/settings_menu.c
167$(OBJDIR)/icons.o: $(RECDIR)/icons.c 167$(OBJDIR)/icons.o: $(RECDIR)/icons.c
168 $(CC) $(APPCFLAGS) -c $< -o $@ 168 $(CC) $(APPCFLAGS) -c $< -o $@
169 169
170$(OBJDIR)/widgets.o: $(RECDIR)/widgets.c
171 $(CC) $(APPCFLAGS) -c $< -o $@
172
170$(OBJDIR)/tetris.o: $(RECDIR)/tetris.c 173$(OBJDIR)/tetris.o: $(RECDIR)/tetris.c
171 $(CC) $(APPCFLAGS) -c $< -o $@ 174 $(CC) $(APPCFLAGS) -c $< -o $@
172 175
diff --git a/uisimulator/x11/lcd-x11.c b/uisimulator/x11/lcd-x11.c
index 96ce800c8f..e1d1953d54 100644
--- a/uisimulator/x11/lcd-x11.c
+++ b/uisimulator/x11/lcd-x11.c
@@ -38,11 +38,11 @@
38 38
39#include "lcd-x11.h" 39#include "lcd-x11.h"
40 40
41extern unsigned char display[LCD_WIDTH][LCD_HEIGHT/8]; 41extern unsigned char lcd_framebuffer[LCD_WIDTH][LCD_HEIGHT/8];
42extern void screen_resized(int width, int height); 42extern void screen_resized(int width, int height);
43extern Display *dpy; 43extern Display *dpy;
44 44
45unsigned char display_copy[LCD_WIDTH][LCD_HEIGHT/8]; 45unsigned char lcd_framebuffer_copy[LCD_WIDTH][LCD_HEIGHT/8];
46 46
47/* this is in uibasic.c */ 47/* this is in uibasic.c */
48extern void drawdots(int color, XPoint *points, int count); 48extern void drawdots(int color, XPoint *points, int count);
@@ -61,10 +61,10 @@ void lcd_update (void)
61 61
62 for(y=0; y<LCD_HEIGHT; y+=8) { 62 for(y=0; y<LCD_HEIGHT; y+=8) {
63 for(x=0; x<LCD_WIDTH; x++) { 63 for(x=0; x<LCD_WIDTH; x++) {
64 if(display[x][y/8]) { 64 if(lcd_framebuffer[x][y/8]) {
65 /* one or more bits/pixels are set */ 65 /* one or more bits/pixels are set */
66 for(bit=0; bit<8; bit++) { 66 for(bit=0; bit<8; bit++) {
67 if(display[x][y/8]&(1<<bit)) { 67 if(lcd_framebuffer[x][y/8]&(1<<bit)) {
68 points[p].x = x + MARGIN_X; 68 points[p].x = x + MARGIN_X;
69 points[p].y = y+bit + MARGIN_Y; 69 points[p].y = y+bit + MARGIN_Y;
70 p++; /* increase the point counter */ 70 p++; /* increase the point counter */
@@ -76,13 +76,13 @@ void lcd_update (void)
76#else 76#else
77 for(y=0; y<LCD_HEIGHT; y+=8) { 77 for(y=0; y<LCD_HEIGHT; y+=8) {
78 for(x=0; x<LCD_WIDTH; x++) { 78 for(x=0; x<LCD_WIDTH; x++) {
79 if(display[x][y/8] || display_copy[x][y/8]) { 79 if(lcd_framebuffer[x][y/8] || lcd_framebuffer_copy[x][y/8]) {
80 /* one or more bits/pixels are changed */ 80 /* one or more bits/pixels are changed */
81 unsigned char diff = 81 unsigned char diff =
82 display[x][y/8] ^ display_copy[x][y/8]; 82 lcd_framebuffer[x][y/8] ^ lcd_framebuffer_copy[x][y/8];
83 83
84 for(bit=0; bit<8; bit++) { 84 for(bit=0; bit<8; bit++) {
85 if(display[x][y/8]&(1<<bit)) { 85 if(lcd_framebuffer[x][y/8]&(1<<bit)) {
86 /* set a dot */ 86 /* set a dot */
87 points[p].x = x + MARGIN_X; 87 points[p].x = x + MARGIN_X;
88 points[p].y = y+bit + MARGIN_Y; 88 points[p].y = y+bit + MARGIN_Y;
@@ -100,7 +100,7 @@ void lcd_update (void)
100 } 100 }
101 101
102 /* copy a huge block */ 102 /* copy a huge block */
103 memcpy(display_copy, display, sizeof(display)); 103 memcpy(lcd_framebuffer_copy, lcd_framebuffer, sizeof(lcd_framebuffer));
104 104
105#endif 105#endif
106 106