1
0
Fork 0
forked from len0rd/rockbox

removed old statusbar and buttonbar code

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8004 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Kevin Ferrare 2005-11-20 01:02:14 +00:00
parent e3367212bd
commit 1a1abf25f4
24 changed files with 169 additions and 641 deletions

View file

@ -25,14 +25,12 @@
#include "options.h" #include "options.h"
#include "lcd.h" #include "lcd.h"
#include "font.h"
#include "button.h" #include "button.h"
#include "kernel.h" #include "kernel.h"
#include "sprintf.h" #include "sprintf.h"
#include <string.h> #include <string.h>
#include "settings.h" #include "settings.h"
#include "power.h" #include "power.h"
#include "status.h"
#include "icons.h" #include "icons.h"
#include "rtc.h" #include "rtc.h"
#include "misc.h" #include "misc.h"
@ -44,6 +42,8 @@
#include "backlight.h" #include "backlight.h"
#include "splash.h" #include "splash.h"
#include "statusbar.h"
#include "textarea.h"
#define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0) #define MARGIN_Y (global_settings.statusbar ? STATUSBAR_HEIGHT : 0)
bool alarm_screen(void) bool alarm_screen(void)
@ -54,6 +54,7 @@ bool alarm_screen(void)
struct tm *tm; struct tm *tm;
int togo; int togo;
int button; int button;
int i;
bool update = true; bool update = true;
rtc_get_alarm(&h, &m); rtc_get_alarm(&h, &m);
@ -69,18 +70,20 @@ bool alarm_screen(void)
while(!done) { while(!done) {
if(update) if(update)
{ {
lcd_clear_display(); FOR_NB_SCREENS(i)
status_draw(true); {
lcd_setfont(FONT_SYSFIXED); gui_textarea_clear(&screens[i]);
lcd_setmargins(0, MARGIN_Y); screens[i].puts(0, 3, str(LANG_ALARM_MOD_KEYS));
lcd_puts(0, 3, str(LANG_ALARM_MOD_KEYS)); }
update = false; update = false;
} }
snprintf(buf, 32, str(LANG_ALARM_MOD_TIME), h, m); snprintf(buf, 32, str(LANG_ALARM_MOD_TIME), h, m);
lcd_puts(0, 1, buf); FOR_NB_SCREENS(i)
lcd_update(); {
screens[i].puts(0, 1, buf);
gui_textarea_update(&screens[i]);
}
button = button_get_w_tmo(HZ); button = button_get_w_tmo(HZ);
switch(button) { switch(button) {
@ -152,7 +155,7 @@ bool alarm_screen(void)
break; break;
case BUTTON_NONE: case BUTTON_NONE:
status_draw(false); gui_syncstatusbar_draw(&statusbars, false);
break; break;
default: default:

View file

@ -49,6 +49,8 @@
#include "misc.h" #include "misc.h"
#include "abrepeat.h" #include "abrepeat.h"
#include "splash.h" #include "splash.h"
#include "yesno.h"
#define MAX_BOOKMARKS 10 #define MAX_BOOKMARKS 10
#define MAX_BOOKMARK_SIZE 350 #define MAX_BOOKMARK_SIZE 350
#define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark" #define RECENT_BOOKMARK_FILE ROCKBOX_DIR "/most-recent.bmark"
@ -189,10 +191,6 @@ bool bookmark_mrb_load()
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
bool bookmark_autobookmark(void) bool bookmark_autobookmark(void)
{ {
/* prompts the user as to create a bookmark */
bool done = false;
int key = 0;
if (!system_check()) if (!system_check())
return false; return false;
@ -208,42 +206,23 @@ bool bookmark_autobookmark(void)
case BOOKMARK_RECENT_ONLY_YES: case BOOKMARK_RECENT_ONLY_YES:
return write_bookmark(false); return write_bookmark(false);
} }
/* Prompting user to confirm bookmark creation */
lcd_clear_display();
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
lcd_setmargins(0, STATUSBAR_HEIGHT); char *lines[]={str(LANG_AUTO_BOOKMARK_QUERY),
lcd_puts(0,0, str(LANG_AUTO_BOOKMARK_QUERY)); str(LANG_CONFIRM_WITH_PLAY_RECORDER),
lcd_puts(0,1, str(LANG_CONFIRM_WITH_PLAY_RECORDER)); str(LANG_CANCEL_WITH_ANY_RECORDER)};
lcd_puts(0,2, str(LANG_CANCEL_WITH_ANY_RECORDER)); struct text_message message={lines, 3};
#else #else
status_draw(false); char *lines[]={str(LANG_AUTO_BOOKMARK_QUERY),
lcd_puts(0,0, str(LANG_AUTO_BOOKMARK_QUERY)); str(LANG_RESUME_CONFIRM_PLAYER)};
lcd_puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER)); struct text_message message={lines, 2};
#endif #endif
lcd_update(); gui_syncstatusbar_draw(&statusbars, false);
if(gui_syncyesno_run(&message, NULL, NULL)==YESNO_YES)
while (!done)
{ {
/* Wait for a key to be pushed */ if (global_settings.autocreatebookmark == BOOKMARK_RECENT_ONLY_ASK)
key = button_get(true);
switch (key)
{
case SETTINGS_OK:
if (global_settings.autocreatebookmark ==
BOOKMARK_RECENT_ONLY_ASK)
return write_bookmark(false); return write_bookmark(false);
else else
return write_bookmark(true); return write_bookmark(true);
break;
default:
/* Handle sys events, ignore button releases & repeats */
if(default_event_handler(key) ||
!(key & (BUTTON_REL|BUTTON_REPEAT)))
done = true;
break;
}
} }
return false; return false;
} }
@ -434,7 +413,6 @@ bool bookmark_autoload(const char* file)
{ {
return false; return false;
} }
fd = open(global_bookmark_file_name, O_RDONLY); fd = open(global_bookmark_file_name, O_RDONLY);
if(fd<0) if(fd<0)
return false; return false;
@ -444,7 +422,6 @@ bool bookmark_autoload(const char* file)
return false; return false;
} }
close(fd); close(fd);
if(global_settings.autoloadbookmark == BOOKMARK_YES) if(global_settings.autoloadbookmark == BOOKMARK_YES)
{ {
return bookmark_load(global_bookmark_file_name, true); return bookmark_load(global_bookmark_file_name, true);
@ -453,6 +430,7 @@ bool bookmark_autoload(const char* file)
{ {
/* Prompting user to confirm bookmark load */ /* Prompting user to confirm bookmark load */
lcd_clear_display(); lcd_clear_display();
gui_syncstatusbar_draw(&statusbars, false);
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
lcd_setmargins(0, STATUSBAR_HEIGHT); lcd_setmargins(0, STATUSBAR_HEIGHT);
lcd_puts_scroll(0,0, str(LANG_BOOKMARK_AUTOLOAD_QUERY)); lcd_puts_scroll(0,0, str(LANG_BOOKMARK_AUTOLOAD_QUERY));
@ -460,7 +438,6 @@ bool bookmark_autoload(const char* file)
lcd_puts(0,2, str(LANG_BOOKMARK_SELECT_LIST_BOOKMARKS)); lcd_puts(0,2, str(LANG_BOOKMARK_SELECT_LIST_BOOKMARKS));
lcd_puts(0,3, str(LANG_CANCEL_WITH_ANY_RECORDER)); lcd_puts(0,3, str(LANG_CANCEL_WITH_ANY_RECORDER));
#else #else
status_draw(false);
lcd_puts_scroll(0,0, str(LANG_BOOKMARK_AUTOLOAD_QUERY)); lcd_puts_scroll(0,0, str(LANG_BOOKMARK_AUTOLOAD_QUERY));
lcd_puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER)); lcd_puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER));
#endif #endif
@ -857,7 +834,7 @@ static void display_bookmark(const char* bookmark,
global_filename); global_filename);
} }
status_draw(false); gui_syncstatusbar_draw(&statusbars, false);
lcd_puts_scroll(0,0,global_temp_buffer); lcd_puts_scroll(0,0,global_temp_buffer);
lcd_puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER)); lcd_puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER));
if (dot) if (dot)

View file

@ -342,7 +342,6 @@ int ft_enter(struct tree_context* c)
bool play = false; bool play = false;
int start_index=0; int start_index=0;
lcd_stop_scroll();
gui_syncsplash(0, true, str(LANG_WAIT)); gui_syncsplash(0, true, str(LANG_WAIT));
switch ( file->attr & TREE_ATTR_MASK ) { switch ( file->attr & TREE_ATTR_MASK ) {
case TREE_ATTR_M3U: case TREE_ATTR_M3U:

View file

@ -56,6 +56,7 @@ static void splash(struct screen * screen,
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
screen->double_height (false); screen->double_height (false);
#endif #endif
screen->stop_scroll();
vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap ); vsnprintf( splash_buf, sizeof(splash_buf), fmt, ap );
if(center) { if(center) {

View file

@ -107,17 +107,17 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
if(!global_settings.statusbar) if(!global_settings.statusbar)
return; return;
#endif #endif /* HAVE_LCD_BITMAP */
struct screen * display = bar->display; struct screen * display = bar->display;
#ifdef HAVE_RTC #ifdef HAVE_RTC
struct tm* tm; /* For Time */ struct tm* tm; /* For Time */
#endif #endif /* HAVE_RTC */
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
(void)force_redraw; /* players always "redraw" */ (void)force_redraw; /* players always "redraw" */
#endif #endif /* HAVE_LCD_CHARCELLS */
bar->info.volume = sound_val2phys(SOUND_VOLUME, global_settings.volume); bar->info.volume = sound_val2phys(SOUND_VOLUME, global_settings.volume);
bar->info.inserted = charger_inserted(); bar->info.inserted = charger_inserted();
@ -129,22 +129,22 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
tm = get_time(); tm = get_time();
bar->info.hour = tm->tm_hour; bar->info.hour = tm->tm_hour;
bar->info.minute = tm->tm_min; bar->info.minute = tm->tm_min;
#endif #endif /* HAVE_RTC */
bar->info.shuffle = global_settings.playlist_shuffle; bar->info.shuffle = global_settings.playlist_shuffle;
#if CONFIG_KEYPAD == IRIVER_H100_PAD #if CONFIG_KEYPAD == IRIVER_H100_PAD
bar->info.keylock = button_hold(); bar->info.keylock = button_hold();
#else #else
bar->info.keylock = keys_locked; bar->info.keylock = keys_locked;
#endif #endif /* CONFIG_KEYPAD == IRIVER_H100_PAD */
bar->info.repeat = global_settings.repeat_mode; bar->info.repeat = global_settings.repeat_mode;
bar->info.playmode = current_playmode(); bar->info.playmode = current_playmode();
#if CONFIG_LED == LED_VIRTUAL if(!display->has_disk_led)
bar->info.led = led_read(HZ/2); /* delay should match polling interval */ bar->info.led = led_read(HZ/2); /* delay should match polling interval */
#endif
#ifdef HAVE_USB_POWER #ifdef HAVE_USB_POWER
bar->info.usb_power = usb_powered(); bar->info.usb_power = usb_powered();
#endif #endif /* HAVE_USB_POWER */
/* only redraw if forced to, or info has changed */ /* only redraw if forced to, or info has changed */
if (force_redraw || if (force_redraw ||
@ -161,7 +161,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
/* players always "redraw" */ /* players always "redraw" */
{ {
#endif #endif /* HAVE_LCD_BITMAP */
#ifdef HAVE_CHARGING #ifdef HAVE_CHARGING
if (bar->info.inserted) { if (bar->info.inserted) {
@ -220,7 +220,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
STATUSBAR_PLUG_X_POS, STATUSBAR_PLUG_X_POS,
STATUSBAR_Y_POS, STATUSBAR_PLUG_WIDTH, STATUSBAR_Y_POS, STATUSBAR_PLUG_WIDTH,
STATUSBAR_HEIGHT); STATUSBAR_HEIGHT);
#endif #endif /* HAVE_USB_POWER */
bar->info.redraw_volume = gui_statusbar_icon_volume(bar, bar->info.redraw_volume = gui_statusbar_icon_volume(bar,
bar->info.volume); bar->info.volume);
@ -232,7 +232,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
case REPEAT_AB: case REPEAT_AB:
gui_statusbar_icon_play_mode(display, Icon_RepeatAB); gui_statusbar_icon_play_mode(display, Icon_RepeatAB);
break; break;
#endif #endif /* AB_REPEAT_ENABLE */
case REPEAT_ONE: case REPEAT_ONE:
gui_statusbar_icon_play_mode(display, Icon_RepeatOne); gui_statusbar_icon_play_mode(display, Icon_RepeatOne);
@ -249,14 +249,12 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
gui_statusbar_icon_lock(display); gui_statusbar_icon_lock(display);
#ifdef HAVE_RTC #ifdef HAVE_RTC
gui_statusbar_time(display, bar->info.hour, bar->info.minute); gui_statusbar_time(display, bar->info.hour, bar->info.minute);
#endif #endif /* HAVE_RTC */
#if CONFIG_LED == LED_VIRTUAL if(!display->has_disk_led && bar->info.led)
if (bar->info.led) gui_statusbar_led(display);
statusbar_led();
#endif
display->update_rect(0, 0, display->width, STATUSBAR_HEIGHT); display->update_rect(0, 0, display->width, STATUSBAR_HEIGHT);
bar->lastinfo = bar->info; bar->lastinfo = bar->info;
#endif #endif /* HAVE_LCD_BITMAP */
} }
@ -284,7 +282,7 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
display->icon(ICON_AUDIO, audio); display->icon(ICON_AUDIO, audio);
display->icon(ICON_PARAM, param); display->icon(ICON_PARAM, param);
display->icon(ICON_USB, usb); display->icon(ICON_USB, usb);
#endif #endif /* HAVE_LCD_CHARCELLS */
} }
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
@ -448,7 +446,6 @@ void gui_statusbar_icon_lock(struct screen * display)
STATUSBAR_Y_POS, 5, 8); STATUSBAR_Y_POS, 5, 8);
} }
#if CONFIG_LED == LED_VIRTUAL
/* /*
* no real LED: disk activity in status bar * no real LED: disk activity in status bar
*/ */
@ -459,8 +456,6 @@ void gui_statusbar_led(struct screen * display)
STATUSBAR_Y_POS, STATUSBAR_DISK_WIDTH, STATUSBAR_Y_POS, STATUSBAR_DISK_WIDTH,
STATUSBAR_HEIGHT); STATUSBAR_HEIGHT);
} }
#endif
#ifdef HAVE_RTC #ifdef HAVE_RTC
/* /*

View file

@ -42,9 +42,8 @@ struct status_info {
bool keylock; bool keylock;
bool battery_safe; bool battery_safe;
bool redraw_volume; /* true if the volume gauge needs updating */ bool redraw_volume; /* true if the volume gauge needs updating */
#if CONFIG_LED == LED_VIRTUAL
bool led; /* disk LED simulation in the status bar */ bool led; /* disk LED simulation in the status bar */
#endif
#ifdef HAVE_USB_POWER #ifdef HAVE_USB_POWER
bool usb_power; bool usb_power;
#endif #endif
@ -100,9 +99,8 @@ void gui_statusbar_icon_play_state(struct screen * display, int state);
void gui_statusbar_icon_play_mode(struct screen * display, int mode); void gui_statusbar_icon_play_mode(struct screen * display, int mode);
void gui_statusbar_icon_shuffle(struct screen * display); void gui_statusbar_icon_shuffle(struct screen * display);
void gui_statusbar_icon_lock(struct screen * display); void gui_statusbar_icon_lock(struct screen * display);
#if CONFIG_LED == LED_VIRTUAL
void gui_statusbar_led(struct screen * display); void gui_statusbar_led(struct screen * display);
#endif
#ifdef HAVE_RTC #ifdef HAVE_RTC
void gui_statusbar_time(struct screen * display, int hour, int minute); void gui_statusbar_time(struct screen * display, int hour, int minute);

View file

@ -18,6 +18,7 @@
****************************************************************************/ ****************************************************************************/
#include "textarea.h" #include "textarea.h"
#include "font.h"
void gui_textarea_clear(struct screen * display) void gui_textarea_clear(struct screen * display)
{ {
@ -27,6 +28,7 @@ void gui_textarea_clear(struct screen * display)
screen_clear_area(display, 0, y_start, display->width, y_end - y_start); screen_clear_area(display, 0, y_start, display->width, y_end - y_start);
display->stop_scroll(); display->stop_scroll();
screen_set_ymargin(display, y_start); screen_set_ymargin(display, y_start);
display->setfont(FONT_SYSFIXED);
#else #else
display->clear_display(); display->clear_display();
#endif #endif
@ -48,7 +50,7 @@ int gui_textarea_put_message(struct screen * display,
int i; int i;
gui_textarea_clear(display); gui_textarea_clear(display);
for(i=0;i<message->nb_lines && i+ystart<display->nb_lines;i++) for(i=0;i<message->nb_lines && i+ystart<display->nb_lines;i++)
display->puts(0, i+ystart, message->message_lines[i]); display->puts_scroll(0, i+ystart, message->message_lines[i]);
gui_textarea_update(display); gui_textarea_update(display);
return(i); return(i);
} }

View file

@ -39,7 +39,7 @@
#include "tree.h" #include "tree.h"
#include "buffer.h" #include "buffer.h"
#include "settings.h" #include "settings.h"
#include "status.h" #include "statusbar.h"
#include "playlist_viewer.h" #include "playlist_viewer.h"
#include "talk.h" #include "talk.h"
#include "onplay.h" #include "onplay.h"
@ -220,7 +220,7 @@ static bool add_to_playlist(int position, bool queue)
if (global_settings.playlist_shuffle) if (global_settings.playlist_shuffle)
playlist_shuffle(current_tick, -1); playlist_shuffle(current_tick, -1);
playlist_start(0,0); playlist_start(0,0);
status_draw(false); gui_syncstatusbar_draw(&statusbars, false);
onplay_result = ONPLAY_START_PLAY; onplay_result = ONPLAY_START_PLAY;
} }

View file

@ -26,7 +26,7 @@
#include <string.h> #include <string.h>
#include "lcd-player-charset.h" #include "lcd-player-charset.h"
#include "settings.h" #include "settings.h"
#include "status.h" #include "statusbar.h"
#include "talk.h" #include "talk.h"
#include "misc.h" #include "misc.h"
@ -153,7 +153,7 @@ int kbd_input(char* text, int buflen)
lcd_puts(1, 1, temptext); lcd_puts(1, 1, temptext);
lcd_put_cursor(curpos + 1, 1, KEYBOARD_CURSOR); lcd_put_cursor(curpos + 1, 1, KEYBOARD_CURSOR);
status_draw(true); gui_syncstatusbar_draw(&statusbars, true);
} }
/* The default action is to redraw */ /* The default action is to redraw */
@ -251,7 +251,7 @@ int kbd_input(char* text, int buflen)
break; break;
case BUTTON_NONE: case BUTTON_NONE:
status_draw(false); gui_syncstatusbar_draw(&statusbars, false);
redraw = false; redraw = false;
break; break;

View file

@ -73,11 +73,9 @@ const unsigned char bitmap_icons_7x8[][7] =
{0x7f,0x04,0x4e,0x5f,0x44,0x38,0x7f} /* Repeat-AB playmode */ {0x7f,0x04,0x4e,0x5f,0x44,0x38,0x7f} /* Repeat-AB playmode */
}; };
#if CONFIG_LED == LED_VIRTUAL
/* Disk/MMC activity */ /* Disk/MMC activity */
const unsigned char bitmap_icon_disk[12] = const unsigned char bitmap_icon_disk[12] =
{0x15,0x3f,0x7d,0x7B,0x77,0x67,0x79,0x7b,0x57,0x4f,0x47,0x7f}; {0x15,0x3f,0x7d,0x7B,0x77,0x67,0x79,0x7b,0x57,0x4f,0x47,0x7f};
#endif
#if LCD_WIDTH == 112 || LCD_WIDTH == 128 \ #if LCD_WIDTH == 112 || LCD_WIDTH == 128 \
|| (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_WIDTH == 128) || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_WIDTH == 128)
@ -340,130 +338,6 @@ const unsigned char rockbox160x53x2[] = {
#endif #endif
/*
* Print battery icon to status bar
*/
void statusbar_icon_battery(int percent)
{
int fill;
char buffer[5];
unsigned int width, height;
/* fill battery */
fill = percent;
if (fill < 0)
fill = 0;
if (fill > 100)
fill = 100;
#if defined(HAVE_CHARGE_CTRL) && !defined(SIMULATOR) /* Rec v1 target only */
/* show graphical animation when charging instead of numbers */
if ((global_settings.battery_display) &&
(charge_state != 1) &&
(percent > -1)) {
#else /* all others */
if (global_settings.battery_display && (percent > -1)) {
#endif
/* Numeric display */
snprintf(buffer, sizeof(buffer), "%3d", fill);
lcd_setfont(FONT_SYSFIXED);
lcd_getstringsize(buffer, &width, &height);
if (height <= STATUSBAR_HEIGHT)
lcd_putsxy(ICON_BATTERY_X_POS + ICON_BATTERY_WIDTH / 2 -
width/2, STATUSBAR_Y_POS, buffer);
lcd_setfont(FONT_UI);
}
else {
/* draw battery */
lcd_drawrect(ICON_BATTERY_X_POS, STATUSBAR_Y_POS, 17, 7);
lcd_vline(ICON_BATTERY_X_POS + 17, STATUSBAR_Y_POS + 2,
STATUSBAR_Y_POS + 4);
fill = fill * 15 / 100;
lcd_fillrect(ICON_BATTERY_X_POS + 1, STATUSBAR_Y_POS + 1, fill, 5);
}
if (percent == -1) {
lcd_setfont(FONT_SYSFIXED);
lcd_putsxy(ICON_BATTERY_X_POS + ICON_BATTERY_WIDTH / 2 - 4,
STATUSBAR_Y_POS, "?");
lcd_setfont(FONT_UI);
}
}
/*
* Print volume gauge to status bar
*/
bool statusbar_icon_volume(int percent)
{
int i;
int volume;
int vol;
char buffer[4];
unsigned int width, height;
bool needs_redraw = false;
int type = global_settings.volume_type;
static long switch_tick;
static int last_volume = -1; /* -1 means "first update ever" */
volume = percent;
if (volume < 0)
volume = 0;
if (volume > 100)
volume = 100;
if (volume == 0) {
lcd_mono_bitmap(bitmap_icons_7x8[Icon_Mute],
ICON_VOLUME_X_POS + ICON_VOLUME_WIDTH / 2 - 4,
STATUSBAR_Y_POS, 7, STATUSBAR_HEIGHT);
}
else {
/* We want to redraw the icon later on */
if (last_volume != volume && last_volume >= 0) {
switch_tick = current_tick + HZ;
}
/* If the timeout hasn't yet been reached, we show it numerically
and tell the caller that we want to be called again */
if (TIME_BEFORE(current_tick,switch_tick)) {
type = 1;
needs_redraw = true;
}
/* display volume level numerical? */
if (type)
{
snprintf(buffer, sizeof(buffer), "%2d", percent);
lcd_setfont(FONT_SYSFIXED);
lcd_getstringsize(buffer, &width, &height);
if (height <= STATUSBAR_HEIGHT)
lcd_putsxy(ICON_VOLUME_X_POS + ICON_VOLUME_WIDTH / 2 -
width/2, STATUSBAR_Y_POS, buffer);
lcd_setfont(FONT_UI);
} else {
/* display volume bar */
vol = volume * 14 / 100;
for(i=0; i < vol; i++) {
lcd_vline(ICON_VOLUME_X_POS + i, STATUSBAR_Y_POS + 6 - i / 2,
STATUSBAR_Y_POS + 6);
}
}
}
last_volume = volume;
return needs_redraw;
}
/*
* Print play state to status bar
*/
void statusbar_icon_play_state(int state)
{
lcd_mono_bitmap(bitmap_icons_7x8[state], ICON_PLAY_STATE_X_POS,
STATUSBAR_Y_POS, ICON_PLAY_STATE_WIDTH, STATUSBAR_HEIGHT);
}
/* /*
* Print play mode to status bar * Print play mode to status bar
*/ */
@ -481,56 +355,3 @@ void statusbar_icon_shuffle(void)
lcd_mono_bitmap(bitmap_icons_7x8[Icon_Shuffle], ICON_SHUFFLE_X_POS, lcd_mono_bitmap(bitmap_icons_7x8[Icon_Shuffle], ICON_SHUFFLE_X_POS,
STATUSBAR_Y_POS, ICON_SHUFFLE_WIDTH, STATUSBAR_HEIGHT); STATUSBAR_Y_POS, ICON_SHUFFLE_WIDTH, STATUSBAR_HEIGHT);
} }
/*
* Print lock when keys are locked
*/
void statusbar_icon_lock(void)
{
lcd_mono_bitmap(bitmap_icons_5x8[Icon_Lock], LOCK_X_POS,
STATUSBAR_Y_POS, 5, 8);
}
#if CONFIG_LED == LED_VIRTUAL
/*
* no real LED: disk activity in status bar
*/
void statusbar_led(void)
{
lcd_mono_bitmap(bitmap_icon_disk, ICON_DISK_X_POS,
STATUSBAR_Y_POS, ICON_DISK_WIDTH, STATUSBAR_HEIGHT);
}
#endif
#ifdef HAVE_RTC
/*
* Print time to status bar
*/
void statusbar_time(int hour, int minute)
{
unsigned char buffer[6];
unsigned int width, height;
if ( hour >= 0 &&
hour <= 23 &&
minute >= 0 &&
minute <= 59 ) {
if ( global_settings.timeformat ) { /* 12 hour clock */
hour %= 12;
if ( hour == 0 ) {
hour += 12;
}
}
snprintf(buffer, sizeof(buffer), "%02d:%02d", hour, minute);
}
else {
strncpy(buffer, "--:--", sizeof buffer);
}
lcd_setfont(FONT_SYSFIXED);
lcd_getstringsize(buffer, &width, &height);
if (height <= STATUSBAR_HEIGHT)
lcd_putsxy(TIME_X_END - width, STATUSBAR_Y_POS, buffer);
lcd_setfont(FONT_UI);
}
#endif

View file

@ -74,9 +74,7 @@ enum icons_7x8 {
extern const unsigned char bitmap_icons_5x8[1][5]; extern const unsigned char bitmap_icons_5x8[1][5];
extern const unsigned char bitmap_icons_6x8[LastIcon][6]; extern const unsigned char bitmap_icons_6x8[LastIcon][6];
extern const unsigned char bitmap_icons_7x8[Icon_Last][7]; extern const unsigned char bitmap_icons_7x8[Icon_Last][7];
#if CONFIG_LED == LED_VIRTUAL
extern const unsigned char bitmap_icon_disk[]; extern const unsigned char bitmap_icon_disk[];
#endif
#if LCD_WIDTH == 112 || LCD_WIDTH == 128 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_WIDTH == 128) #if LCD_WIDTH == 112 || LCD_WIDTH == 128 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_WIDTH == 128)
extern const unsigned char rockbox112x37[]; extern const unsigned char rockbox112x37[];

View file

@ -26,10 +26,11 @@
#include <string.h> #include <string.h>
#include "font.h" #include "font.h"
#include "screens.h" #include "screens.h"
#include "status.h" #include "statusbar.h"
#include "talk.h" #include "talk.h"
#include "settings.h" #include "settings.h"
#include "misc.h" #include "misc.h"
#include "buttonbar.h"
#define KEYBOARD_MARGIN 3 #define KEYBOARD_MARGIN 3
@ -177,7 +178,11 @@ int kbd_input(char* text, int buflen)
char outline[256]; char outline[256];
struct font* font = font_get(FONT_SYSFIXED); struct font* font = font_get(FONT_SYSFIXED);
int button, lastbutton = 0; int button, lastbutton = 0;
#ifdef HAS_BUTTONBAR
struct gui_buttonbar buttonbar;
gui_buttonbar_init(&buttonbar);
gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) );
#endif
lcd_setfont(FONT_SYSFIXED); lcd_setfont(FONT_SYSFIXED);
font_w = font->maxwidth; font_w = font->maxwidth;
font_h = font->height; font_h = font->height;
@ -229,10 +234,10 @@ int kbd_input(char* text, int buflen)
i = (curpos + 1) * font_w; i = (curpos + 1) * font_w;
lcd_vline(i, main_y, main_y + font_h); lcd_vline(i, main_y, main_y + font_h);
#if CONFIG_KEYPAD == RECORDER_PAD #ifdef HAS_BUTTONBAR
/* draw the status bar */ /* draw the status bar */
buttonbar_set("Shift", "OK", "Del"); gui_buttonbar_set(&buttonbar, "Shift", "OK", "Del");
buttonbar_draw(); gui_buttonbar_draw(&buttonbar);
#endif #endif
#ifdef KBD_MODES #ifdef KBD_MODES
@ -245,8 +250,7 @@ int kbd_input(char* text, int buflen)
lcd_set_drawmode(DRMODE_SOLID); lcd_set_drawmode(DRMODE_SOLID);
} }
status_draw(true); gui_syncstatusbar_draw(&statusbars, true);
lcd_update(); lcd_update();
} }
@ -454,7 +458,7 @@ int kbd_input(char* text, int buflen)
#endif /* !KBD_MODES */ #endif /* !KBD_MODES */
case BUTTON_NONE: case BUTTON_NONE:
status_draw(false); gui_syncstatusbar_draw(&statusbars, false);
redraw = false; redraw = false;
break; break;

View file

@ -56,6 +56,7 @@
#include "textarea.h" #include "textarea.h"
#include "splash.h" #include "splash.h"
#include "yesno.h" #include "yesno.h"
#include "buttonbar.h"
#include "power.h" #include "power.h"
#ifdef CONFIG_TUNER #ifdef CONFIG_TUNER
@ -298,9 +299,13 @@ bool radio_screen(void)
int hours, minutes; int hours, minutes;
bool keep_playing = false; bool keep_playing = false;
bool statusbar = global_settings.statusbar; bool statusbar = global_settings.statusbar;
#ifdef HAS_BUTTONBAR
struct gui_buttonbar buttonbar;
gui_buttonbar_init(&buttonbar);
gui_buttonbar_set_display(&buttonbar, &(screens[SCREEN_MAIN]) );
#endif
/* always display status bar in radio screen for now */ /* always display status bar in radio screen for now */
global_settings.statusbar = true; global_settings.statusbar = true;
FOR_NB_SCREENS(i){ FOR_NB_SCREENS(i){
gui_textarea_clear(&screens[i]); gui_textarea_clear(&screens[i]);
screen_set_xmargin(&screens[i],0); screen_set_xmargin(&screens[i],0);
@ -377,8 +382,8 @@ bool radio_screen(void)
radio_mode = RADIO_PRESET_MODE; radio_mode = RADIO_PRESET_MODE;
#endif #endif
#if CONFIG_KEYPAD == RECORDER_PAD #ifdef HAS_BUTTONBAR
buttonbar_set(str(LANG_BUTTONBAR_MENU), str(LANG_FM_BUTTONBAR_PRESETS), gui_buttonbar_set(&buttonbar, str(LANG_BUTTONBAR_MENU), str(LANG_FM_BUTTONBAR_PRESETS),
str(LANG_FM_BUTTONBAR_RECORD)); str(LANG_FM_BUTTONBAR_RECORD));
#endif #endif
@ -613,8 +618,8 @@ bool radio_screen(void)
gui_textarea_clear(&screens[i]); gui_textarea_clear(&screens[i]);
screen_set_xmargin(&screens[i],0); screen_set_xmargin(&screens[i],0);
} }
#if CONFIG_KEYPAD == RECORDER_PAD #ifdef HAS_BUTTONBAR
buttonbar_set(str(LANG_BUTTONBAR_MENU), gui_buttonbar_set(&buttonbar, str(LANG_BUTTONBAR_MENU),
str(LANG_FM_BUTTONBAR_PRESETS), str(LANG_FM_BUTTONBAR_PRESETS),
str(LANG_FM_BUTTONBAR_RECORD)); str(LANG_FM_BUTTONBAR_RECORD));
#endif #endif
@ -646,8 +651,9 @@ bool radio_screen(void)
gui_textarea_clear(&screens[i]); gui_textarea_clear(&screens[i]);
screen_set_xmargin(&screens[i],0); screen_set_xmargin(&screens[i],0);
} }
#if CONFIG_KEYPAD == RECORDER_PAD #ifdef HAS_BUTTONBAR
buttonbar_set(str(LANG_BUTTONBAR_MENU), gui_buttonbar_set(&buttonbar,
str(LANG_BUTTONBAR_MENU),
str(LANG_FM_BUTTONBAR_PRESETS), str(LANG_FM_BUTTONBAR_PRESETS),
str(LANG_FM_BUTTONBAR_RECORD)); str(LANG_FM_BUTTONBAR_RECORD));
#endif #endif
@ -808,8 +814,8 @@ bool radio_screen(void)
} }
} }
#if CONFIG_KEYPAD == RECORDER_PAD #if HAS_BUTTONBAR
buttonbar_draw(); gui_buttonbar_draw(&buttonbar);
#endif #endif
FOR_NB_SCREENS(i) FOR_NB_SCREENS(i)
gui_textarea_update(&screens[i]); gui_textarea_update(&screens[i]);

View file

@ -45,7 +45,7 @@
#include "icons.h" #include "icons.h"
#include "screens.h" #include "screens.h"
#include "peakmeter.h" #include "peakmeter.h"
#include "status.h" #include "statusbar.h"
#include "menu.h" #include "menu.h"
#include "sound_menu.h" #include "sound_menu.h"
#include "timefuncs.h" #include "timefuncs.h"
@ -831,7 +831,7 @@ bool recording_screen(void)
lcd_puts(0, 6, buf); lcd_puts(0, 6, buf);
} }
status_draw(true); gui_syncstatusbar_draw(&statusbars, true);
peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h); peak_meter_draw(0, 8 + h*2, LCD_WIDTH, h);
lcd_update(); lcd_update();
@ -860,7 +860,7 @@ bool recording_screen(void)
if (audio_stat & AUDIO_STATUS_ERROR) if (audio_stat & AUDIO_STATUS_ERROR)
{ {
gui_syncsplash(0, true, str(LANG_DISK_FULL)); gui_syncsplash(0, true, str(LANG_DISK_FULL));
status_draw(true); gui_syncstatusbar_draw(&statusbars, true);
lcd_update(); lcd_update();
audio_error_clear(); audio_error_clear();

View file

@ -38,6 +38,8 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
#ifdef HAVE_REMOTE_LCD #ifdef HAVE_REMOTE_LCD
case SCREEN_REMOTE: case SCREEN_REMOTE:
screen->depth=LCD_REMOTE_DEPTH; screen->depth=LCD_REMOTE_DEPTH;
screen->has_disk_led=false;
#if 1 /* all remote LCDs are bitmapped so far */ #if 1 /* all remote LCDs are bitmapped so far */
screen->width=LCD_REMOTE_WIDTH; screen->width=LCD_REMOTE_WIDTH;
screen->height=LCD_REMOTE_HEIGHT; screen->height=LCD_REMOTE_HEIGHT;
@ -87,13 +89,17 @@ void screen_init(struct screen * screen, enum screen_type screen_type)
screen->clear_display=&lcd_remote_clear_display; screen->clear_display=&lcd_remote_clear_display;
screen->update=&lcd_remote_update; screen->update=&lcd_remote_update;
screen->puts=&lcd_remote_puts; screen->puts=&lcd_remote_puts;
break; break;
#endif /* HAVE_REMOTE_LCD */ #endif /* HAVE_REMOTE_LCD */
case SCREEN_MAIN: case SCREEN_MAIN:
default: default:
screen->depth=LCD_DEPTH; screen->depth=LCD_DEPTH;
#if CONFIG_LED == LED_VIRTUAL
screen->has_disk_led=false;
#else
screen->has_disk_led=true;
#endif
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
screen->width=LCD_WIDTH; screen->width=LCD_WIDTH;
screen->height=LCD_HEIGHT; screen->height=LCD_HEIGHT;

View file

@ -54,6 +54,7 @@ struct screen
int depth; int depth;
int char_width; int char_width;
int char_height; int char_height;
bool has_disk_led;
#ifdef HAS_BUTTONBAR #ifdef HAS_BUTTONBAR
bool has_buttonbar; bool has_buttonbar;
#endif #endif

View file

@ -48,6 +48,8 @@
#include "abrepeat.h" #include "abrepeat.h"
#include "gwps-common.h" #include "gwps-common.h"
#include "splash.h" #include "splash.h"
#include "statusbar.h"
#if defined(HAVE_LCD_BITMAP) #if defined(HAVE_LCD_BITMAP)
#include "widgets.h" #include "widgets.h"
#endif #endif
@ -108,7 +110,7 @@ void usb_display_info(void)
lcd_mono_bitmap(usb_logo, LCD_WIDTH/2-BMPWIDTH_usb_logo/2, lcd_mono_bitmap(usb_logo, LCD_WIDTH/2-BMPWIDTH_usb_logo/2,
LCD_HEIGHT/2-BMPHEIGHT_usb_logo/2, BMPWIDTH_usb_logo, LCD_HEIGHT/2-BMPHEIGHT_usb_logo/2, BMPWIDTH_usb_logo,
BMPHEIGHT_usb_logo); BMPHEIGHT_usb_logo);
status_draw(true); gui_syncstatusbar_draw(&statusbars, true);
lcd_update(); lcd_update();
#else #else
lcd_double_height(false); lcd_double_height(false);
@ -116,7 +118,7 @@ void usb_display_info(void)
status_set_param(false); status_set_param(false);
status_set_audio(false); status_set_audio(false);
status_set_usb(true); status_set_usb(true);
status_draw(false); gui_syncstatusbar_draw(&statusbars, false);
#endif #endif
} }
@ -138,7 +140,7 @@ void usb_screen(void)
#endif #endif
status_draw(false); gui_syncstatusbar_draw(&statusbars, false);
} }
} }
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
@ -358,7 +360,7 @@ int charging_screen(void)
remote_backlight_set_timeout(global_settings.remote_backlight_timeout); remote_backlight_set_timeout(global_settings.remote_backlight_timeout);
#endif #endif
backlight_set_on_when_charging(global_settings.backlight_on_when_charging); backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
status_draw(true); gui_syncstatusbar_draw(&statusbars, true);
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
logo_lock_patterns(true); logo_lock_patterns(true);
@ -367,7 +369,7 @@ int charging_screen(void)
do do
{ {
status_draw(false); gui_syncstatusbar_draw(&statusbars, false);
charging_display_info(true); charging_display_info(true);
button = button_get_w_tmo(HZ/3); button = button_get_w_tmo(HZ/3);
if (button == BUTTON_ON) if (button == BUTTON_ON)
@ -990,7 +992,7 @@ bool set_time_screen(const char* string, struct tm *tm)
lcd_puts(0, 4, str(LANG_TIME_SET)); lcd_puts(0, 4, str(LANG_TIME_SET));
lcd_puts(0, 5, str(LANG_TIME_REVERT)); lcd_puts(0, 5, str(LANG_TIME_REVERT));
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
status_draw(true); gui_syncstatusbar_draw(&statusbars, true);
#endif #endif
lcd_update(); lcd_update();
@ -1186,7 +1188,7 @@ bool browse_id3(void)
char* body; char* body;
lcd_clear_display(); lcd_clear_display();
status_draw(true); gui_syncstatusbar_draw(&statusbars, true);
line = draw_id3_item(line, top, LANG_ID3_TITLE, id3->title); line = draw_id3_item(line, top, LANG_ID3_TITLE, id3->title);
line = draw_id3_item(line, top, LANG_ID3_ARTIST, id3->artist); line = draw_id3_item(line, top, LANG_ID3_ARTIST, id3->artist);
line = draw_id3_item(line, top, LANG_ID3_ALBUM, id3->album); line = draw_id3_item(line, top, LANG_ID3_ALBUM, id3->album);
@ -1260,7 +1262,7 @@ bool browse_id3(void)
while (!exit && (top == old_top)) while (!exit && (top == old_top))
{ {
status_draw(false); gui_syncstatusbar_draw(&statusbars, false);
lcd_update(); lcd_update();
button = button_get_w_tmo(HZ / 2); button = button_get_w_tmo(HZ / 2);

View file

@ -28,7 +28,7 @@
#include "settings.h" #include "settings.h"
#include "power.h" #include "power.h"
#include "powermgmt.h" #include "powermgmt.h"
#include "status.h" #include "statusbar.h"
#include "debug.h" #include "debug.h"
#include "talk.h" #include "talk.h"
#include "icons.h" #include "icons.h"
@ -155,7 +155,7 @@ bool sleeptimer_screen(void)
} }
} }
status_draw(true); gui_syncstatusbar_draw(&statusbars, true);
lcd_update(); lcd_update();
} }

View file

@ -26,7 +26,7 @@
#include "button.h" #include "button.h"
#include "mp3_playback.h" #include "mp3_playback.h"
#include "settings.h" #include "settings.h"
#include "status.h" #include "statusbar.h"
#include "screens.h" #include "screens.h"
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
#include "icons.h" #include "icons.h"
@ -575,7 +575,7 @@ bool rectrigger(void)
lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
lcd_fillrect(0, stat_height, LCD_WIDTH, LCD_HEIGHT - stat_height); lcd_fillrect(0, stat_height, LCD_WIDTH, LCD_HEIGHT - stat_height);
lcd_set_drawmode(DRMODE_SOLID); lcd_set_drawmode(DRMODE_SOLID);
status_draw(true); gui_syncstatusbar_draw(&statusbars, true);
/* reselect FONT_SYSFONT as status_draw has changed the font */ /* reselect FONT_SYSFONT as status_draw has changed the font */
/*lcd_setfont(FONT_SYSFIXED);*/ /*lcd_setfont(FONT_SYSFIXED);*/

View file

@ -28,6 +28,7 @@
#include "audio.h" #include "audio.h"
#include "gwps.h" #include "gwps.h"
#include "abrepeat.h" #include "abrepeat.h"
#include "statusbar.h"
#ifdef HAVE_RTC #ifdef HAVE_RTC
#include "timefuncs.h" #include "timefuncs.h"
#endif #endif
@ -54,27 +55,6 @@ bool battery_state = true;
int battery_charge_step = 0; int battery_charge_step = 0;
#endif #endif
struct status_info {
int battlevel;
int volume;
int hour;
int minute;
int playmode;
int repeat;
bool inserted;
bool shuffle;
bool keylock;
bool battery_safe;
bool redraw_volume; /* true if the volume gauge needs updating */
#if CONFIG_LED == LED_VIRTUAL
bool led; /* disk LED simulation in the status bar */
#endif
#ifdef HAVE_USB_POWER
bool usb_power;
#endif
};
void status_init(void) void status_init(void)
{ {
ff_mode = 0; ff_mode = 0;
@ -83,7 +63,7 @@ void status_init(void)
void status_set_ffmode(enum playmode mode) void status_set_ffmode(enum playmode mode)
{ {
ff_mode = mode; /* Either STATUS_FASTFORWARD or STATUS_FASTBACKWARD */ ff_mode = mode; /* Either STATUS_FASTFORWARD or STATUS_FASTBACKWARD */
status_draw(false); gui_syncstatusbar_draw(&statusbars, false);
} }
enum playmode status_get_ffmode(void) enum playmode status_get_ffmode(void)
@ -162,257 +142,3 @@ void status_set_usb(bool b)
} }
#endif /* HAVE_LCD_CHARCELLS */ #endif /* HAVE_LCD_CHARCELLS */
void status_draw(bool force_redraw)
{
/* This is static because we use memcmp() below to check for changes, and
the unused bytes (due to struct member alignment) might change if
the struct is allocated on the stack. */
static struct status_info info;
#ifdef HAVE_LCD_BITMAP
static struct status_info lastinfo;
struct tm* tm;
if ( !global_settings.statusbar )
return;
#else
(void)force_redraw; /* players always "redraw" */
#endif
info.volume = sound_val2phys(SOUND_VOLUME, global_settings.volume);
info.inserted = charger_inserted();
info.battlevel = battery_level();
info.battery_safe = battery_level_safe();
#ifdef HAVE_LCD_BITMAP
tm = get_time();
info.hour = tm->tm_hour;
info.minute = tm->tm_min;
info.shuffle = global_settings.playlist_shuffle;
#if CONFIG_KEYPAD == IRIVER_H100_PAD
info.keylock = button_hold();
#else
info.keylock = keys_locked;
#endif
info.repeat = global_settings.repeat_mode;
info.playmode = current_playmode();
#if CONFIG_LED == LED_VIRTUAL
info.led = led_read(HZ/2); /* delay should match polling interval */
#endif
#ifdef HAVE_USB_POWER
info.usb_power = usb_powered();
#endif
/* only redraw if forced to, or info has changed */
if (force_redraw ||
info.inserted ||
!info.battery_safe ||
info.redraw_volume ||
memcmp(&info, &lastinfo, sizeof(struct status_info)))
{
lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
lcd_fillrect(0,0,LCD_WIDTH,8);
lcd_set_drawmode(DRMODE_SOLID);
#else
/* players always "redraw" */
{
#endif
#ifdef HAVE_CHARGING
if (info.inserted) {
battery_state = true;
#if defined(HAVE_CHARGE_CTRL) || CONFIG_BATTERY == BATT_LIION2200
/* zero battery run time if charging */
if (charge_state > 0) {
global_settings.runtime = 0;
lasttime = current_tick;
}
/* animate battery if charging */
if ((charge_state == 1) ||
(charge_state == 2)) {
#else
global_settings.runtime = 0;
lasttime = current_tick;
{
#endif
/* animate in three steps (34% per step for a better look) */
info.battlevel = battery_charge_step * 34;
if (info.battlevel > 100)
info.battlevel = 100;
if(TIME_AFTER(current_tick, switch_tick)) {
battery_charge_step=(battery_charge_step+1)%4;
switch_tick = current_tick + HZ;
}
}
}
else
#endif /* HAVE_CHARGING */
{
if (info.battery_safe)
battery_state = true;
else {
/* blink battery if level is low */
if(TIME_AFTER(current_tick, switch_tick) &&
(info.battlevel > -1)) {
switch_tick = current_tick+HZ;
battery_state =! battery_state;
}
}
}
#ifdef HAVE_LCD_BITMAP
if (battery_state)
statusbar_icon_battery(info.battlevel);
/* draw power plug if charging */
if (info.inserted)
lcd_mono_bitmap(bitmap_icons_7x8[Icon_Plug], ICON_PLUG_X_POS,
STATUSBAR_Y_POS, ICON_PLUG_WIDTH, STATUSBAR_HEIGHT);
#ifdef HAVE_USB_POWER
else if (info.usb_power)
lcd_mono_bitmap(bitmap_icons_7x8[Icon_USBPlug], ICON_PLUG_X_POS,
STATUSBAR_Y_POS, ICON_PLUG_WIDTH, STATUSBAR_HEIGHT);
#endif
info.redraw_volume = statusbar_icon_volume(info.volume);
statusbar_icon_play_state(current_playmode() + Icon_Play);
switch (info.repeat) {
#ifdef AB_REPEAT_ENABLE
case REPEAT_AB:
statusbar_icon_play_mode(Icon_RepeatAB);
break;
#endif
case REPEAT_ONE:
statusbar_icon_play_mode(Icon_RepeatOne);
break;
case REPEAT_ALL:
case REPEAT_SHUFFLE:
statusbar_icon_play_mode(Icon_Repeat);
break;
}
if (info.shuffle)
statusbar_icon_shuffle();
if (info.keylock)
statusbar_icon_lock();
#ifdef HAVE_RTC
statusbar_time(info.hour, info.minute);
#endif
#if CONFIG_LED == LED_VIRTUAL
if (info.led)
statusbar_led();
#endif
lcd_update_rect(0, 0, LCD_WIDTH, STATUSBAR_HEIGHT);
lastinfo = info;
#endif
}
#if defined(HAVE_LCD_CHARCELLS)
if (info.battlevel > -1)
lcd_icon(ICON_BATTERY, battery_state);
lcd_icon(ICON_BATTERY_1, info.battlevel > 25);
lcd_icon(ICON_BATTERY_2, info.battlevel > 50);
lcd_icon(ICON_BATTERY_3, info.battlevel > 75);
lcd_icon(ICON_VOLUME, true);
lcd_icon(ICON_VOLUME_1, info.volume > 10);
lcd_icon(ICON_VOLUME_2, info.volume > 30);
lcd_icon(ICON_VOLUME_3, info.volume > 50);
lcd_icon(ICON_VOLUME_4, info.volume > 70);
lcd_icon(ICON_VOLUME_5, info.volume > 90);
lcd_icon(ICON_PLAY, current_playmode() == STATUS_PLAY);
lcd_icon(ICON_PAUSE, current_playmode() == STATUS_PAUSE);
lcd_icon(ICON_REPEAT, global_settings.repeat_mode != REPEAT_OFF);
lcd_icon(ICON_1, global_settings.repeat_mode == REPEAT_ONE);
lcd_icon(ICON_RECORD, record);
lcd_icon(ICON_AUDIO, audio);
lcd_icon(ICON_PARAM, param);
lcd_icon(ICON_USB, usb);
#endif
}
#if defined(HAVE_LCD_BITMAP) && (CONFIG_KEYPAD == RECORDER_PAD)
static void draw_buttonbar_btn(int num, const char* caption)
{
int xpos, ypos, button_width, text_width;
int fw, fh;
lcd_setfont(FONT_SYSFIXED);
lcd_getstringsize("M", &fw, &fh);
button_width = LCD_WIDTH/3;
xpos = num * button_width;
ypos = LCD_HEIGHT - fh;
if(caption)
{
/* center the text */
text_width = fw * strlen(caption);
lcd_putsxy(xpos + (button_width - text_width)/2, ypos, caption);
}
lcd_set_drawmode(DRMODE_COMPLEMENT);
lcd_fillrect(xpos, ypos, button_width - 1, fh);
lcd_set_drawmode(DRMODE_SOLID);
}
static char stored_caption1[8];
static char stored_caption2[8];
static char stored_caption3[8];
void buttonbar_set(const char* caption1, const char *caption2,
const char *caption3)
{
buttonbar_unset();
if(caption1)
{
strncpy(stored_caption1, caption1, 7);
stored_caption1[7] = 0;
}
if(caption2)
{
strncpy(stored_caption2, caption2, 7);
stored_caption2[7] = 0;
}
if(caption3)
{
strncpy(stored_caption3, caption3, 7);
stored_caption3[7] = 0;
}
}
void buttonbar_unset(void)
{
stored_caption1[0] = 0;
stored_caption2[0] = 0;
stored_caption3[0] = 0;
}
void buttonbar_draw(void)
{
lcd_set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
lcd_fillrect(0, LCD_HEIGHT-8, LCD_WIDTH, 8);
lcd_set_drawmode(DRMODE_SOLID);
draw_buttonbar_btn(0, stored_caption1);
draw_buttonbar_btn(1, stored_caption2);
draw_buttonbar_btn(2, stored_caption3);
}
bool buttonbar_isset(void)
{
/* If all buttons are unset, the button bar is considered disabled */
return (global_settings.buttonbar &&
((stored_caption1[0] != 0) ||
(stored_caption2[0] != 0) ||
(stored_caption3[0] != 0)));
}
#endif

View file

@ -52,27 +52,14 @@ void status_set_ffmode(enum playmode mode);
enum playmode status_get_ffmode(void); enum playmode status_get_ffmode(void);
int current_playmode(void); int current_playmode(void);
#ifdef HAVE_LCD_BITMAP #ifdef SIMULATOR
bool statusbar(bool state); #include <time.h>
#if CONFIG_KEYPAD == RECORDER_PAD #endif
void buttonbar_set(const char* caption1, const char* caption2, #ifdef HAVE_LCD_CHARCELLS
const char* caption3);
void buttonbar_unset(void);
bool buttonbar_isset(void);
void buttonbar_draw(void);
#define BUTTONBAR_HEIGHT 8
#endif /* CONFIG_KEYPAD == RECORDER_PAD */
#endif /* HAVE_LCD_BITMAP */
void status_draw(bool force_redraw);
#if defined(HAVE_LCD_CHARCELLS)
void status_set_record(bool b); void status_set_record(bool b);
void status_set_audio(bool b); void status_set_audio(bool b);
void status_set_param(bool b); void status_set_param(bool b);
void status_set_usb(bool b); void status_set_usb(bool b);
#endif #endif /* HAVE_LCD_CHARCELLS */
#ifdef SIMULATOR #endif /* _STATUS_H */
#include <time.h>
#endif
#endif

View file

@ -65,9 +65,7 @@ drivers/lcd-ipod.c
drivers/lcd-h300.c drivers/lcd-h300.c
#endif #endif
drivers/power.c drivers/power.c
#ifdef CONFIG_LED
drivers/led.c drivers/led.c
#endif
#ifndef SIMULATOR #ifndef SIMULATOR
drivers/adc.c drivers/adc.c
#ifdef HAVE_MMC #ifdef HAVE_MMC

View file

@ -23,44 +23,50 @@
#include "system.h" #include "system.h"
#include "kernel.h" #include "kernel.h"
static bool disk_led_status;
static long last_on; /* timestamp of switching off */
void disk_led_on(void)
{
disk_led_status=true;
#if CONFIG_LED == LED_REAL #if CONFIG_LED == LED_REAL
#ifdef GMINI_ARCH
P2 |= 1;
#else
or_b(0x40, &PBDRL);
#endif
#endif
}
void disk_led_off(void)
{
if(disk_led_status)
{
last_on = current_tick;/* remember for off delay */
disk_led_status=false;
#if CONFIG_LED == LED_REAL
#ifdef GMINI_ARCH
P2 &= ~1;
#else
and_b(~0x40, &PBDRL);
#endif
#endif
}
}
void led(bool on) void led(bool on)
{ {
if ( on ) if ( on )
#ifdef GMINI_ARCH disk_led_on();
P2 |= 1;
else else
P2 &= ~1; disk_led_off();
#else
{
or_b(0x40, &PBDRL);
}
else
{
and_b(~0x40, &PBDRL);
}
#endif
} }
#elif CONFIG_LED == LED_VIRTUAL bool led_read(int delayticks)
static bool current;
static long last_on; /* timestamp of switching off */
void led(bool on)
{
if (current && !on) /* switching off */
{
last_on = current_tick; /* remember for off delay */
}
current = on;
}
bool led_read(int delayticks) /* read by status bar update */
{ {
/* reading "off" is delayed by user-supplied monoflop value */ /* reading "off" is delayed by user-supplied monoflop value */
return (current || TIME_BEFORE(current_tick, last_on+delayticks)); return (disk_led_status ||
TIME_BEFORE(current_tick, last_on+delayticks));
} }
#endif /* CONFIG_LED */

View file

@ -23,8 +23,6 @@
#include <stdbool.h> #include <stdbool.h>
extern void led( bool on ); extern void led( bool on );
#if CONFIG_LED == LED_VIRTUAL extern bool led_read(int delayticks);
extern bool led_read(int delayticks); /* read for status bar */
#endif
#endif #endif