Only redraw the status line when info actually changed.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3588 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Björn Stenberg 2003-04-23 11:26:25 +00:00
parent 10fd7b6c3b
commit 942bc9449e
12 changed files with 93 additions and 65 deletions

View file

@ -167,7 +167,7 @@ static void menu_draw(int m)
LCD_HEIGHT - SCROLLBAR_Y, menus[m].itemcount, menus[m].top, LCD_HEIGHT - SCROLLBAR_Y, menus[m].itemcount, menus[m].top,
menus[m].top + menu_lines, VERTICAL); menus[m].top + menu_lines, VERTICAL);
#endif #endif
status_draw(); status_draw(true);
lcd_update(); lcd_update();
} }
@ -332,7 +332,7 @@ int menu_show(int m)
return MENU_ATTACHED_USB; return MENU_ATTACHED_USB;
} }
status_draw(); status_draw(false);
} }
return MENU_SELECTED_EXIT; return MENU_SELECTED_EXIT;
} }

View file

@ -138,14 +138,6 @@ unsigned char rockbox112x37[]={
}; };
/*
* Wipe statusbar
*/
void statusbar_wipe(void)
{
lcd_clearrect(0,0,LCD_WIDTH,8);
}
/* /*
* Print battery icon to status bar * Print battery icon to status bar
*/ */

View file

@ -416,7 +416,7 @@ bool recording_screen(void)
global_settings.rec_quality); global_settings.rec_quality);
lcd_puts(0, 6, buf); lcd_puts(0, 6, buf);
status_draw(); status_draw(false);
lcd_update(); lcd_update();
} }

View file

@ -85,14 +85,14 @@ void usb_display_info(void)
BMPWIDTH_usb_logo, 8, false); BMPWIDTH_usb_logo, 8, false);
lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*3, 6, 40, lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*3, 6, 40,
BMPWIDTH_usb_logo, 8, false); BMPWIDTH_usb_logo, 8, false);
status_draw(); status_draw(true);
lcd_update(); lcd_update();
#else #else
lcd_puts(0, 0, "[USB Mode]"); lcd_puts(0, 0, "[USB Mode]");
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(); status_draw(false);
#endif #endif
} }
@ -101,9 +101,10 @@ void usb_screen(void)
#ifndef SIMULATOR #ifndef SIMULATOR
backlight_on(); backlight_on();
usb_acknowledge(SYS_USB_CONNECTED_ACK); usb_acknowledge(SYS_USB_CONNECTED_ACK);
usb_display_info();
while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) { while(usb_wait_for_disconnect_w_tmo(&button_queue, HZ)) {
if(usb_inserted()) { if(usb_inserted()) {
usb_display_info(); status_draw(false);
} }
} }
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS

View file

@ -1609,7 +1609,7 @@ bool set_int(char* string,
snprintf(str,sizeof str,"%d %s ", *variable, unit); snprintf(str,sizeof str,"%d %s ", *variable, unit);
lcd_puts(0, 1, str); lcd_puts(0, 1, str);
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
status_draw(); status_draw(true);
#endif #endif
lcd_update(); lcd_update();
@ -1699,7 +1699,7 @@ bool set_option(char* string, int* variable, char* options[],
while ( !done ) { while ( !done ) {
lcd_puts(0, 1, options[*variable]); lcd_puts(0, 1, options[*variable]);
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
status_draw(); status_draw(true);
#endif #endif
lcd_update(); lcd_update();
@ -1932,7 +1932,7 @@ bool set_time(char* string, int timedate[])
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(); status_draw(true);
#endif #endif
lcd_update(); lcd_update();

View file

@ -147,7 +147,7 @@ bool sleeptimer_screen(void)
lcd_puts(0, 1, str(LANG_OFF)); lcd_puts(0, 1, str(LANG_OFF));
} }
status_draw(); status_draw(true);
lcd_update(); lcd_update();
} }

View file

@ -83,7 +83,7 @@ bool set_sound(char* string,
} }
} }
lcd_puts(0,1,str); lcd_puts(0,1,str);
status_draw(); status_draw(true);
lcd_update(); lcd_update();
changed = false; changed = false;

View file

@ -16,6 +16,7 @@
* KIND, either express or implied. * KIND, either express or implied.
* *
****************************************************************************/ ****************************************************************************/
#include "string.h"
#include "lcd.h" #include "lcd.h"
#include "debug.h" #include "debug.h"
#include "kernel.h" #include "kernel.h"
@ -44,6 +45,19 @@ static bool battery_state;
#endif #endif
#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;
};
void status_init(void) void status_init(void)
{ {
status_set_playmode(STATUS_STOP); status_set_playmode(STATUS_STOP);
@ -52,7 +66,7 @@ void status_init(void)
void status_set_playmode(enum playmode mode) void status_set_playmode(enum playmode mode)
{ {
current_mode = mode; current_mode = mode;
status_draw(); status_draw(false);
} }
#if defined(HAVE_LCD_CHARCELLS) #if defined(HAVE_LCD_CHARCELLS)
@ -83,36 +97,43 @@ void status_set_usb(bool b)
#endif /* HAVE_LCD_CHARCELLS */ #endif /* HAVE_LCD_CHARCELLS */
void status_draw(void) void status_draw(bool force_redraw)
{ {
int battlevel = battery_level(); struct status_info info;
int volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume);
#if defined(HAVE_LCD_BITMAP) && defined(HAVE_RTC) #ifdef HAVE_LCD_BITMAP
static struct status_info lastinfo;
struct tm* tm; struct tm* tm;
#endif
if ( !global_settings.statusbar ) if ( !global_settings.statusbar )
return; return;
#else
(void)force_redraw; /* players always "redraw" */
#endif
info.battlevel = battery_level();
info.volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume);
info.inserted = charger_inserted();
#if defined(HAVE_LCD_CHARCELLS) #if defined(HAVE_LCD_CHARCELLS)
lcd_icon(ICON_VOLUME, true); lcd_icon(ICON_VOLUME, true);
if(volume > 10) if(info.volume > 10)
lcd_icon(ICON_VOLUME_1, true); lcd_icon(ICON_VOLUME_1, true);
else else
lcd_icon(ICON_VOLUME_1, false); lcd_icon(ICON_VOLUME_1, false);
if(volume > 30) if(info.volume > 30)
lcd_icon(ICON_VOLUME_2, true); lcd_icon(ICON_VOLUME_2, true);
else else
lcd_icon(ICON_VOLUME_2, false); lcd_icon(ICON_VOLUME_2, false);
if(volume > 50) if(info.volume > 50)
lcd_icon(ICON_VOLUME_3, true); lcd_icon(ICON_VOLUME_3, true);
else else
lcd_icon(ICON_VOLUME_3, false); lcd_icon(ICON_VOLUME_3, false);
if(volume > 70) if(info.volume > 70)
lcd_icon(ICON_VOLUME_4, true); lcd_icon(ICON_VOLUME_4, true);
else else
lcd_icon(ICON_VOLUME_4, false); lcd_icon(ICON_VOLUME_4, false);
if(volume > 90) if(info.volume > 90)
lcd_icon(ICON_VOLUME_5, true); lcd_icon(ICON_VOLUME_5, true);
else else
lcd_icon(ICON_VOLUME_5, false); lcd_icon(ICON_VOLUME_5, false);
@ -137,7 +158,7 @@ void status_draw(void)
default: default:
break; break;
} }
if(charger_inserted()) if(info.inserted)
{ {
global_settings.runtime = 0; global_settings.runtime = 0;
if(TIME_AFTER(current_tick, switch_tick)) if(TIME_AFTER(current_tick, switch_tick))
@ -174,15 +195,15 @@ void status_draw(void)
} }
} else { } else {
lcd_icon(ICON_BATTERY, true); lcd_icon(ICON_BATTERY, true);
if(battlevel > 25) if(info.battlevel > 25)
lcd_icon(ICON_BATTERY_1, true); lcd_icon(ICON_BATTERY_1, true);
else else
lcd_icon(ICON_BATTERY_1, false); lcd_icon(ICON_BATTERY_1, false);
if(battlevel > 50) if(info.battlevel > 50)
lcd_icon(ICON_BATTERY_2, true); lcd_icon(ICON_BATTERY_2, true);
else else
lcd_icon(ICON_BATTERY_2, false); lcd_icon(ICON_BATTERY_2, false);
if(battlevel > 75) if(info.battlevel > 75)
lcd_icon(ICON_BATTERY_3, true); lcd_icon(ICON_BATTERY_3, true);
else else
lcd_icon(ICON_BATTERY_3, false); lcd_icon(ICON_BATTERY_3, false);
@ -198,17 +219,31 @@ void status_draw(void)
#endif #endif
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
if (global_settings.statusbar) {
statusbar_wipe(); tm = get_time();
info.hour = tm->tm_hour;
info.minute = tm->tm_min;
info.shuffle = global_settings.playlist_shuffle;
info.keylock = keys_locked;
info.battery_safe = battery_level_safe();
info.repeat = global_settings.repeat_mode;
if (force_redraw ||
info.inserted ||
!info.battery_safe ||
memcmp(&info, &lastinfo, sizeof(struct status_info))) {
lcd_clearrect(0,0,LCD_WIDTH,8);
#ifdef HAVE_CHARGE_CTRL /* Recorder */ #ifdef HAVE_CHARGE_CTRL /* Recorder */
if(charger_inserted()) { if(info.inserted) {
battery_state = true; battery_state = true;
plug_state = true; plug_state = true;
if (charge_state > 0) /* charge || top off || trickle */ if (charge_state > 0) /* charge || top off || trickle */
global_settings.runtime = 0; global_settings.runtime = 0;
if (charge_state == 1) { /* animate battery if charging */ if (charge_state == 1) { /* animate battery if charging */
battlevel = battery_charge_step * 34; /* 34 for a better look */ info.battlevel = battery_charge_step * 34; /* 34 for a better look */
battlevel = battlevel > 100 ? 100 : battlevel; if (info.battlevel > 100)
info.battlevel = 100;
if(TIME_AFTER(current_tick, switch_tick)) { if(TIME_AFTER(current_tick, switch_tick)) {
battery_charge_step=(battery_charge_step+1)%4; battery_charge_step=(battery_charge_step+1)%4;
switch_tick = current_tick + HZ; switch_tick = current_tick + HZ;
@ -217,7 +252,7 @@ void status_draw(void)
} }
else { else {
plug_state=false; plug_state=false;
if(battery_level_safe()) if(!info.battery_safe)
battery_state = true; battery_state = true;
else /* blink battery if level is low */ else /* blink battery if level is low */
if(TIME_AFTER(current_tick, switch_tick)) { if(TIME_AFTER(current_tick, switch_tick)) {
@ -226,18 +261,17 @@ void status_draw(void)
} }
} }
if (battery_state) statusbar_icon_battery(info.battlevel, plug_state);
statusbar_icon_battery(battlevel, plug_state);
#else #else
#ifdef HAVE_FMADC /* FM */ #ifdef HAVE_FMADC /* FM */
statusbar_icon_battery(battlevel, charger_inserted()); statusbar_icon_battery(info.battlevel, charger_inserted());
#else /* Player */ #else /* Player */
statusbar_icon_battery(battlevel, false); statusbar_icon_battery(info.battlevel, false);
#endif /* HAVE_FMADC */ #endif /* HAVE_FMADC */
#endif /* HAVE_CHARGE_CTRL */ #endif /* HAVE_CHARGE_CTRL */
statusbar_icon_volume(volume); statusbar_icon_volume(info.volume);
statusbar_icon_play_state(current_mode + Icon_Play); statusbar_icon_play_state(current_mode + Icon_Play);
switch (global_settings.repeat_mode) { switch (info.repeat) {
case REPEAT_ONE: case REPEAT_ONE:
statusbar_icon_play_mode(Icon_RepeatOne); statusbar_icon_play_mode(Icon_RepeatOne);
break; break;
@ -246,16 +280,17 @@ void status_draw(void)
statusbar_icon_play_mode(Icon_Repeat); statusbar_icon_play_mode(Icon_Repeat);
break; break;
} }
if(global_settings.playlist_shuffle) if(info.shuffle)
statusbar_icon_shuffle(); statusbar_icon_shuffle();
if (keys_locked) if (info.keylock)
statusbar_icon_lock(); statusbar_icon_lock();
#ifdef HAVE_RTC #ifdef HAVE_RTC
tm = get_time(); statusbar_time(info.hour, info.minute);
statusbar_time(tm->tm_hour, tm->tm_min);
#endif #endif
lcd_update_rect(0, 0, LCD_WIDTH, STATUSBAR_HEIGHT); lcd_update_rect(0, 0, LCD_WIDTH, STATUSBAR_HEIGHT);
} }
lastinfo = info;
#endif #endif
} }

View file

@ -35,7 +35,7 @@ void status_set_playmode(enum playmode mode);
#ifdef HAVE_LCD_BITMAP #ifdef HAVE_LCD_BITMAP
bool statusbar(bool state); bool statusbar(bool state);
#endif #endif
void status_draw(void); void status_draw(bool force_redraw);
#if defined(HAVE_LCD_CHARCELLS) #if defined(HAVE_LCD_CHARCELLS)
void status_set_record(bool b); void status_set_record(bool b);

View file

@ -494,7 +494,7 @@ static int showdir(char *path, int start)
LCD_HEIGHT - SCROLLBAR_Y, filesindir, start, LCD_HEIGHT - SCROLLBAR_Y, filesindir, start,
start + tree_max_on_screen, VERTICAL); start + tree_max_on_screen, VERTICAL);
#endif #endif
status_draw(); status_draw(false);
return filesindir; return filesindir;
} }
@ -511,7 +511,7 @@ bool ask_resume(void)
lcd_clear_display(); lcd_clear_display();
lcd_puts(0,0,str(LANG_RESUME_ASK)); lcd_puts(0,0,str(LANG_RESUME_ASK));
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
status_draw(); status_draw(false);
lcd_puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER)); lcd_puts(0,1,str(LANG_RESUME_CONFIRM_PLAYER));
#else #else
lcd_puts(0,1,str(LANG_RESUME_CONFIRM_RECORDER)); lcd_puts(0,1,str(LANG_RESUME_CONFIRM_RECORDER));
@ -621,7 +621,7 @@ void start_resume(void)
} }
status_set_playmode(STATUS_PLAY); status_set_playmode(STATUS_PLAY);
status_draw(); status_draw(true);
wps_show(); wps_show();
} }
} }
@ -839,7 +839,7 @@ bool dirbrowse(char *root)
case BUTTON_OFF: case BUTTON_OFF:
mpeg_stop(); mpeg_stop();
status_set_playmode(STATUS_STOP); status_set_playmode(STATUS_STOP);
status_draw(); status_draw(false);
restore = true; restore = true;
break; break;
@ -996,7 +996,7 @@ bool dirbrowse(char *root)
} }
status_set_playmode(STATUS_PLAY); status_set_playmode(STATUS_PLAY);
status_draw(); status_draw(false);
lcd_stop_scroll(); lcd_stop_scroll();
if ( wps_show() == SYS_USB_CONNECTED ) { if ( wps_show() == SYS_USB_CONNECTED ) {
reload_root = true; reload_root = true;
@ -1136,7 +1136,7 @@ bool dirbrowse(char *root)
break; break;
case BUTTON_NONE: case BUTTON_NONE:
status_draw(); status_draw(false);
break; break;
} }

View file

@ -801,7 +801,7 @@ bool wps_display(struct mp3entry* id3)
#endif #endif
global_settings.resume_index = -1; global_settings.resume_index = -1;
status_set_playmode(STATUS_STOP); status_set_playmode(STATUS_STOP);
status_draw(); status_draw(true);
sleep(HZ); sleep(HZ);
return true; return true;
} }
@ -827,7 +827,7 @@ bool wps_display(struct mp3entry* id3)
} }
yield(); yield();
wps_refresh(id3, 0, WPS_REFRESH_ALL); wps_refresh(id3, 0, WPS_REFRESH_ALL);
status_draw(); status_draw(true);
lcd_update(); lcd_update();
return false; return false;
} }

View file

@ -103,7 +103,7 @@ void player_change_volume(int button)
if (!exit) if (!exit)
button = button_get(true); button = button_get(true);
} }
status_draw(); status_draw(false);
wps_refresh(id3,0, WPS_REFRESH_ALL); wps_refresh(id3,0, WPS_REFRESH_ALL);
} }
#endif #endif
@ -443,7 +443,7 @@ static bool update(void)
if (id3) if (id3)
wps_refresh(id3, 0, WPS_REFRESH_NON_STATIC); wps_refresh(id3, 0, WPS_REFRESH_NON_STATIC);
status_draw(); status_draw(false);
/* save resume data */ /* save resume data */
if ( id3 && if ( id3 &&
@ -488,7 +488,7 @@ static bool keylock(void)
#endif #endif
return false; return false;
} }
status_draw(); status_draw(false);
while (button_get(false)); /* clear button queue */ while (button_get(false)); /* clear button queue */
while (!exit) { while (!exit) {
@ -560,7 +560,7 @@ static bool menu(void)
#ifdef HAVE_LCD_CHARCELLS #ifdef HAVE_LCD_CHARCELLS
status_set_param(true); status_set_param(true);
status_draw(); status_draw(false);
#endif #endif
while (!exit) { while (!exit) {
@ -896,7 +896,7 @@ int wps_show(void)
if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME)) if(global_settings.volume > mpeg_sound_max(SOUND_VOLUME))
global_settings.volume = mpeg_sound_max(SOUND_VOLUME); global_settings.volume = mpeg_sound_max(SOUND_VOLUME);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume); mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
status_draw(); status_draw(false);
settings_save(); settings_save();
break; break;
@ -910,7 +910,7 @@ int wps_show(void)
if(global_settings.volume < mpeg_sound_min(SOUND_VOLUME)) if(global_settings.volume < mpeg_sound_min(SOUND_VOLUME))
global_settings.volume = mpeg_sound_min(SOUND_VOLUME); global_settings.volume = mpeg_sound_min(SOUND_VOLUME);
mpeg_sound_set(SOUND_VOLUME, global_settings.volume); mpeg_sound_set(SOUND_VOLUME, global_settings.volume);
status_draw(); status_draw(false);
settings_save(); settings_save();
break; break;