mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-13 07:02:31 -05:00
Work-in-progress rework of charging status reading & display: * Changed several charging related HAVE_* macros into one multi-value CONFIG_CHARGING. * Always use proper macros for charging states. * Battery symbol charging animation now starts from current level on all targets with charging. Two-colour animation kept for non-b&w targets. Round down fill level while charging as before, but round to nearest pixel value for discharging on all targets. * Charging anim fixed on player. * Some code cleanup.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10080 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
8c9e22580e
commit
0dd1f8ec11
43 changed files with 300 additions and 350 deletions
|
|
@ -1334,8 +1334,8 @@ bool view_battery(void)
|
|||
snprintf(buf, 30, "External: %d.%02d V", y / 100, y % 100);
|
||||
lcd_puts(0, 2, buf);
|
||||
#endif
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef HAVE_CHARGE_CTRL
|
||||
#ifdef CONFIG_CHARGING
|
||||
#if CONFIG_CHARGING == CHARGING_CONTROL
|
||||
snprintf(buf, 30, "Chgr: %s %s",
|
||||
charger_inserted() ? "present" : "absent",
|
||||
charger_enabled ? "on" : "off");
|
||||
|
|
@ -1345,8 +1345,8 @@ bool view_battery(void)
|
|||
snprintf(buf, 30, "long delta: %d", long_delta);
|
||||
lcd_puts(0, 6, buf);
|
||||
lcd_puts(0, 7, power_message);
|
||||
#else /* !HAVE_CHARGE_CTRL */
|
||||
#if defined IPOD_NANO || defined IPOD_VIDEO
|
||||
#else /* CONFIG_CHARGING != CHARGING_CONTROL */
|
||||
#if defined IPOD_NANO || defined IPOD_VIDEO
|
||||
int usb_pwr = (GPIOL_INPUT_VAL & 0x10)?true:false;
|
||||
int ext_pwr = (GPIOL_INPUT_VAL & 0x08)?false:true;
|
||||
int dock = (GPIOA_INPUT_VAL & 0x10)?true:false;
|
||||
|
|
@ -1373,8 +1373,8 @@ bool view_battery(void)
|
|||
charger_inserted() ? "present" : "absent");
|
||||
lcd_puts(0, 3, buf);
|
||||
#endif
|
||||
#endif /* !HAVE_CHARGE_CTRL */
|
||||
#endif /* HAVE_CHARGING */
|
||||
#endif /* CONFIG_CHARGING != CHARGING_CONTROL */
|
||||
#endif /* CONFIG_CHARGING */
|
||||
break;
|
||||
|
||||
case 2: /* voltage deltas: */
|
||||
|
|
@ -1393,7 +1393,7 @@ bool view_battery(void)
|
|||
case 3: /* remaining time estimation: */
|
||||
lcd_clear_display();
|
||||
|
||||
#ifdef HAVE_CHARGE_CTRL
|
||||
#if CONFIG_CHARGING == CHARGING_CONTROL
|
||||
snprintf(buf, 30, "charge_state: %d", charge_state);
|
||||
lcd_puts(0, 0, buf);
|
||||
|
||||
|
|
@ -1408,7 +1408,7 @@ bool view_battery(void)
|
|||
|
||||
snprintf(buf, 30, "Trickle sec: %d/60", trickle_sec);
|
||||
lcd_puts(0, 4, buf);
|
||||
#endif /* HAVE_CHARGE_CTRL */
|
||||
#endif /* CONFIG_CHARGING == CHARGING_CONTROL */
|
||||
|
||||
snprintf(buf, 30, "Last PwrHist: %d.%02d V",
|
||||
power_history[0] / 100,
|
||||
|
|
@ -1465,7 +1465,7 @@ static bool view_runtime(void)
|
|||
#endif
|
||||
|
||||
if (state & 1) {
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
if (charger_inserted()
|
||||
#ifdef HAVE_USB_POWER
|
||||
|| usb_powered()
|
||||
|
|
|
|||
|
|
@ -823,7 +823,7 @@ static char* get_tag(struct wps_data* wps_data,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
case 'p': /* External power plugged in? */
|
||||
{
|
||||
if(charger_input_state==CHARGER)
|
||||
|
|
@ -832,9 +832,7 @@ static char* get_tag(struct wps_data* wps_data,
|
|||
return NULL;
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_CHARGE_CTRL) || \
|
||||
defined (HAVE_CHARGE_STATE) || \
|
||||
CONFIG_BATTERY == BATT_LIION2200
|
||||
#if CONFIG_CHARGING >= CHARGING_MONITOR
|
||||
case 'c': /* Charging */
|
||||
{
|
||||
if (charge_state == CHARGING || charge_state == TOPOFF) {
|
||||
|
|
|
|||
|
|
@ -107,37 +107,73 @@ struct gui_syncstatusbar statusbars;
|
|||
|
||||
void gui_statusbar_init(struct gui_statusbar * bar)
|
||||
{
|
||||
bar->last_volume = -1000; /* -1000 means "first update ever" */
|
||||
bar->battery_icon_switch_tick = 0;
|
||||
bar->animated_level = 0;
|
||||
bar->redraw_volume = true;
|
||||
bar->volume_icon_switch_tick = bar->battery_icon_switch_tick = current_tick;
|
||||
}
|
||||
|
||||
void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
|
||||
{
|
||||
struct screen * display = bar->display;
|
||||
#ifdef CONFIG_RTC
|
||||
struct tm* tm; /* For Time */
|
||||
#endif /* CONFIG_RTC */
|
||||
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
int vol;
|
||||
int val;
|
||||
(void)force_redraw; /* players always "redraw" */
|
||||
#endif /* HAVE_LCD_CHARCELLS */
|
||||
|
||||
bar->info.volume = sound_val2phys(SOUND_VOLUME, global_settings.volume);
|
||||
#ifdef HAVE_CHARGING
|
||||
bar->info.inserted = (charger_input_state == CHARGER);
|
||||
#endif
|
||||
bar->info.battlevel = battery_level();
|
||||
bar->info.battery_safe = battery_level_safe();
|
||||
#ifdef HAVE_USB_POWER
|
||||
bar->info.usb_power = usb_powered();
|
||||
#endif
|
||||
#ifdef CONFIG_CHARGING
|
||||
bar->info.inserted = (charger_input_state == CHARGER);
|
||||
if (bar->info.inserted)
|
||||
{
|
||||
bar->info.battery_state = true;
|
||||
|
||||
#if CONFIG_CHARGING >= CHARGING_MONITOR
|
||||
|
||||
/* zero battery run time if charging */
|
||||
if (charge_state > DISCHARGING)
|
||||
lasttime = current_tick;
|
||||
|
||||
/* animate battery if charging */
|
||||
if ((charge_state == DISCHARGING) || (charge_state == TRICKLE))
|
||||
{
|
||||
bar->info.batt_charge_step = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
#else
|
||||
lasttime = current_tick;
|
||||
{
|
||||
#endif
|
||||
/* animate in (max.) 4 steps, starting near the current charge level */
|
||||
if (TIME_AFTER(current_tick, bar->battery_icon_switch_tick))
|
||||
{
|
||||
if (++bar->info.batt_charge_step > 3)
|
||||
bar->info.batt_charge_step = bar->info.battlevel / 34;
|
||||
bar->battery_icon_switch_tick = current_tick + HZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
bar->info.batt_charge_step = -1;
|
||||
if (battery_level_safe())
|
||||
bar->info.battery_state = true;
|
||||
else
|
||||
/* blink battery if level is low */
|
||||
if (TIME_AFTER(current_tick, bar->battery_icon_switch_tick) &&
|
||||
(bar->info.battlevel > -1))
|
||||
{
|
||||
bar->info.battery_state = !bar->info.battery_state;
|
||||
bar->battery_icon_switch_tick = current_tick + HZ;
|
||||
}
|
||||
}
|
||||
|
||||
bar->info.volume = sound_val2phys(SOUND_VOLUME, global_settings.volume);
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#ifdef CONFIG_RTC
|
||||
tm = get_time();
|
||||
bar->info.hour = tm->tm_hour;
|
||||
bar->info.minute = tm->tm_min;
|
||||
#endif /* CONFIG_RTC */
|
||||
|
||||
bar->info.shuffle = global_settings.playlist_shuffle;
|
||||
#ifdef HAS_BUTTON_HOLD
|
||||
bar->info.keylock = button_hold();
|
||||
|
|
@ -149,24 +185,25 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
|
|||
#endif
|
||||
bar->info.repeat = global_settings.repeat_mode;
|
||||
bar->info.playmode = current_playmode();
|
||||
|
||||
#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
|
||||
if(!display->has_disk_led)
|
||||
bar->info.led = led_read(HZ/2); /* delay should match polling interval */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_USB_POWER
|
||||
bar->info.usb_power = usb_powered();
|
||||
#endif /* HAVE_USB_POWER */
|
||||
#ifdef CONFIG_RTC
|
||||
{
|
||||
struct tm* tm = get_time();
|
||||
bar->info.hour = tm->tm_hour;
|
||||
bar->info.minute = tm->tm_min;
|
||||
}
|
||||
#endif /* CONFIG_RTC */
|
||||
|
||||
/* only redraw if forced to, or info has changed */
|
||||
if (force_redraw ||
|
||||
bar->info.inserted ||
|
||||
!bar->info.battery_safe ||
|
||||
bar->info.redraw_volume ||
|
||||
if (force_redraw || bar->redraw_volume ||
|
||||
memcmp(&(bar->info), &(bar->lastinfo), sizeof(struct status_info)))
|
||||
{
|
||||
display->set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID);
|
||||
display->fillrect(0,0,display->width,8);
|
||||
display->fillrect(0, 0, display->width, STATUSBAR_HEIGHT);
|
||||
display->set_drawmode(DRMODE_SOLID);
|
||||
|
||||
#else
|
||||
|
|
@ -175,65 +212,10 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
|
|||
{
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
if (bar->info.inserted) {
|
||||
battery_state = true;
|
||||
#if defined(HAVE_CHARGE_CTRL) || \
|
||||
defined(HAVE_CHARGE_STATE) || \
|
||||
CONFIG_BATTERY == BATT_LIION2200
|
||||
/* zero battery run time if charging */
|
||||
if (charge_state > DISCHARGING) {
|
||||
lasttime = current_tick;
|
||||
}
|
||||
|
||||
/* animate battery if charging */
|
||||
if ((charge_state == CHARGING)
|
||||
#ifdef HAVE_CHARGE_CTRL
|
||||
|| (charge_state == TOPOFF)
|
||||
#endif
|
||||
) {
|
||||
#else
|
||||
lasttime = current_tick;
|
||||
{
|
||||
#endif
|
||||
/* animate in three steps (34% per step for a better look) */
|
||||
#ifndef HAVE_CHARGE_STATE
|
||||
bar->info.battlevel = 0;
|
||||
#endif
|
||||
if(TIME_AFTER(current_tick, bar->battery_icon_switch_tick)) {
|
||||
if (bar->animated_level == 100)
|
||||
{
|
||||
bar->animated_level = bar->info.battlevel;
|
||||
}
|
||||
else
|
||||
{
|
||||
bar->animated_level += 34;
|
||||
if (bar->animated_level > 100)
|
||||
bar->animated_level = 100;
|
||||
}
|
||||
bar->battery_icon_switch_tick = current_tick + HZ;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* HAVE_CHARGING */
|
||||
{
|
||||
bar->animated_level = 0;
|
||||
if (bar->info.battery_safe)
|
||||
battery_state = true;
|
||||
else {
|
||||
/* blink battery if level is low */
|
||||
if(TIME_AFTER(current_tick, bar->battery_icon_switch_tick) &&
|
||||
(bar->info.battlevel > -1)) {
|
||||
bar->battery_icon_switch_tick = current_tick+HZ;
|
||||
battery_state = !battery_state;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
if (battery_state)
|
||||
if (bar->info.battery_state)
|
||||
gui_statusbar_icon_battery(display, bar->info.battlevel,
|
||||
bar->animated_level);
|
||||
bar->info.batt_charge_step);
|
||||
#ifdef HAVE_USB_POWER
|
||||
if (bar->info.usb_power)
|
||||
display->mono_bitmap(bitmap_icons_7x8[Icon_USBPlug],
|
||||
|
|
@ -243,14 +225,15 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
|
|||
else
|
||||
#endif /* HAVE_USB_POWER */
|
||||
/* draw power plug if charging */
|
||||
#ifdef CONFIG_CHARGING
|
||||
if (bar->info.inserted)
|
||||
display->mono_bitmap(bitmap_icons_7x8[Icon_Plug],
|
||||
STATUSBAR_PLUG_X_POS,
|
||||
STATUSBAR_Y_POS, STATUSBAR_PLUG_WIDTH,
|
||||
STATUSBAR_HEIGHT);
|
||||
#endif
|
||||
|
||||
bar->info.redraw_volume = gui_statusbar_icon_volume(bar,
|
||||
bar->info.volume);
|
||||
bar->redraw_volume = gui_statusbar_icon_volume(bar, bar->info.volume);
|
||||
gui_statusbar_icon_play_state(display, current_playmode() +
|
||||
Icon_Play);
|
||||
|
||||
|
|
@ -292,20 +275,24 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
|
|||
|
||||
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
if (bar->info.battlevel > -1)
|
||||
display->icon(ICON_BATTERY, battery_state);
|
||||
display->icon(ICON_BATTERY_1, bar->info.battlevel > 25);
|
||||
display->icon(ICON_BATTERY_2, bar->info.battlevel > 50);
|
||||
display->icon(ICON_BATTERY_3, bar->info.battlevel > 75);
|
||||
display->icon(ICON_BATTERY, bar->info.battery_state);
|
||||
|
||||
if (bar->info.batt_charge_step > -1)
|
||||
val = bar->info.batt_charge_step;
|
||||
else
|
||||
val = (bar->info.battlevel * 3 + 50) / 100;
|
||||
display->icon(ICON_BATTERY_1, val >= 1);
|
||||
display->icon(ICON_BATTERY_2, val >= 2);
|
||||
display->icon(ICON_BATTERY_3, val >= 3);
|
||||
|
||||
vol = 100 * (bar->info.volume - sound_min(SOUND_VOLUME))
|
||||
val = 10 * (bar->info.volume - sound_min(SOUND_VOLUME))
|
||||
/ (sound_max(SOUND_VOLUME) - sound_min(SOUND_VOLUME));
|
||||
display->icon(ICON_VOLUME, true);
|
||||
display->icon(ICON_VOLUME_1, vol > 10);
|
||||
display->icon(ICON_VOLUME_2, vol > 30);
|
||||
display->icon(ICON_VOLUME_3, vol > 50);
|
||||
display->icon(ICON_VOLUME_4, vol > 70);
|
||||
display->icon(ICON_VOLUME_5, vol > 90);
|
||||
display->icon(ICON_VOLUME_1, val >= 1);
|
||||
display->icon(ICON_VOLUME_2, val >= 3);
|
||||
display->icon(ICON_VOLUME_3, val >= 5);
|
||||
display->icon(ICON_VOLUME_4, val >= 7);
|
||||
display->icon(ICON_VOLUME_5, val >= 9);
|
||||
|
||||
display->icon(ICON_PLAY, current_playmode() == STATUS_PLAY);
|
||||
display->icon(ICON_PAUSE, current_playmode() == STATUS_PAUSE);
|
||||
|
|
@ -326,40 +313,41 @@ void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw)
|
|||
* Print battery icon to status bar
|
||||
*/
|
||||
void gui_statusbar_icon_battery(struct screen * display, int percent,
|
||||
int animated_percent)
|
||||
int batt_charge_step)
|
||||
{
|
||||
int fill, endfill;
|
||||
char buffer[5];
|
||||
unsigned int width, height;
|
||||
#if LCD_DEPTH > 1
|
||||
unsigned int prevfg = LCD_DEFAULT_FG;
|
||||
unsigned int prevfg = 0;
|
||||
#endif
|
||||
|
||||
/* fill battery */
|
||||
fill = percent;
|
||||
if (fill < 0)
|
||||
fill = 0;
|
||||
if (fill > 100)
|
||||
fill = 100;
|
||||
#ifdef CONFIG_CHARGING
|
||||
if (batt_charge_step >= 0)
|
||||
{
|
||||
fill = percent * (STATUSBAR_BATTERY_WIDTH-3) / 100;
|
||||
endfill = 34 * batt_charge_step * (STATUSBAR_BATTERY_WIDTH-3) / 100;
|
||||
}
|
||||
else
|
||||
#else
|
||||
(void)batt_charge_step;
|
||||
#endif
|
||||
{
|
||||
fill = endfill = (percent * (STATUSBAR_BATTERY_WIDTH-3) + 50) / 100;
|
||||
}
|
||||
|
||||
endfill = animated_percent;
|
||||
if (endfill < 0)
|
||||
endfill = 0;
|
||||
if (endfill > 100)
|
||||
endfill = 100;
|
||||
|
||||
#if (defined(HAVE_CHARGE_CTRL) || defined(HAVE_CHARGE_STATE)) && \
|
||||
!defined(SIMULATOR) /* Certain charge controlled targets */
|
||||
#if CONFIG_CHARGING == CHARGING_MONITOR && !defined(SIMULATOR)
|
||||
/* Certain charge controlled targets */
|
||||
/* show graphical animation when charging instead of numbers */
|
||||
if ((global_settings.battery_display) &&
|
||||
(charge_state != 1) &&
|
||||
(charge_state != CHARGING) &&
|
||||
(percent > -1)) {
|
||||
#else /* all others */
|
||||
if (global_settings.battery_display && (percent > -1)) {
|
||||
#endif
|
||||
/* Numeric display */
|
||||
display->setfont(FONT_SYSFIXED);
|
||||
snprintf(buffer, sizeof(buffer), "%3d", fill);
|
||||
snprintf(buffer, sizeof(buffer), "%3d", percent);
|
||||
display->getstringsize(buffer, &width, &height);
|
||||
if (height <= STATUSBAR_HEIGHT)
|
||||
display->putsxy(STATUSBAR_BATTERY_X_POS
|
||||
|
|
@ -374,7 +362,6 @@ void gui_statusbar_icon_battery(struct screen * display, int percent,
|
|||
display->vline(STATUSBAR_BATTERY_X_POS + 17, STATUSBAR_Y_POS + 2,
|
||||
STATUSBAR_Y_POS + 4);
|
||||
|
||||
fill = fill * 15 / 100;
|
||||
display->fillrect(STATUSBAR_BATTERY_X_POS + 1, STATUSBAR_Y_POS + 1,
|
||||
fill, 5);
|
||||
#if LCD_DEPTH > 1
|
||||
|
|
@ -384,9 +371,8 @@ void gui_statusbar_icon_battery(struct screen * display, int percent,
|
|||
display->set_foreground(LCD_DARKGRAY);
|
||||
}
|
||||
#endif
|
||||
endfill = endfill * 15 / 100 - fill;
|
||||
display->fillrect(STATUSBAR_BATTERY_X_POS + 1 + fill,
|
||||
STATUSBAR_Y_POS + 1, endfill, 5);
|
||||
display->fillrect(STATUSBAR_BATTERY_X_POS + 1 + fill,
|
||||
STATUSBAR_Y_POS + 1, endfill - fill, 5);
|
||||
#if LCD_DEPTH > 1
|
||||
if (display->depth > 1)
|
||||
display->set_foreground(prevfg);
|
||||
|
|
@ -507,6 +493,7 @@ void gui_statusbar_icon_lock(struct screen * display)
|
|||
STATUSBAR_LOCKM_WIDTH, STATUSBAR_HEIGHT);
|
||||
}
|
||||
|
||||
#ifdef HAS_REMOTE_BUTTON_HOLD
|
||||
/*
|
||||
* Print remote lock when remote hold is enabled
|
||||
*/
|
||||
|
|
@ -516,6 +503,7 @@ void gui_statusbar_icon_lock_remote(struct screen * display)
|
|||
STATUSBAR_LOCKR_X_POS, STATUSBAR_Y_POS,
|
||||
STATUSBAR_LOCKR_WIDTH, STATUSBAR_HEIGHT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -31,38 +31,40 @@
|
|||
|
||||
struct status_info {
|
||||
int battlevel;
|
||||
int batt_charge_step;
|
||||
int volume;
|
||||
int playmode;
|
||||
int repeat;
|
||||
#ifdef CONFIG_RTC
|
||||
int hour;
|
||||
int minute;
|
||||
#endif
|
||||
int playmode;
|
||||
int repeat;
|
||||
|
||||
#ifdef CONFIG_CHARGING
|
||||
bool inserted;
|
||||
#endif
|
||||
#ifdef HAVE_USB_POWER
|
||||
bool usb_power;
|
||||
#endif
|
||||
bool battery_state;
|
||||
bool shuffle;
|
||||
bool keylock;
|
||||
#ifdef HAS_REMOTE_BUTTON_HOLD
|
||||
bool keylockremote;
|
||||
#endif
|
||||
bool battery_safe;
|
||||
bool redraw_volume; /* true if the volume gauge needs updating */
|
||||
#if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
|
||||
bool led; /* disk LED simulation in the status bar */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_USB_POWER
|
||||
bool usb_power;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct gui_statusbar
|
||||
{
|
||||
/* Volume icon stuffs */
|
||||
long battery_icon_switch_tick;
|
||||
|
||||
long volume_icon_switch_tick;
|
||||
int last_volume;
|
||||
|
||||
long battery_icon_switch_tick;
|
||||
int animated_level;
|
||||
bool redraw_volume; /* true if the volume gauge needs updating */
|
||||
|
||||
struct status_info info;
|
||||
struct status_info lastinfo;
|
||||
|
|
@ -95,7 +97,7 @@ extern void gui_statusbar_init(struct gui_statusbar * bar);
|
|||
*/
|
||||
extern void gui_statusbar_draw(struct gui_statusbar * bar, bool force_redraw);
|
||||
|
||||
void gui_statusbar_icon_battery(struct screen * display, int percent, int animated_percent);
|
||||
void gui_statusbar_icon_battery(struct screen * display, int percent, int batt_charge_step);
|
||||
bool gui_statusbar_icon_volume(struct gui_statusbar * bar, int volume);
|
||||
void gui_statusbar_icon_play_state(struct screen * display, int state);
|
||||
void gui_statusbar_icon_play_mode(struct screen * display, int mode);
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ void init(void)
|
|||
{
|
||||
int rc;
|
||||
bool mounted = false;
|
||||
#if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034)
|
||||
#if defined(CONFIG_CHARGING) && (CONFIG_CPU == SH7034)
|
||||
/* if nobody initialized ATA before, I consider this a cold start */
|
||||
bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */
|
||||
#endif
|
||||
|
|
@ -295,7 +295,7 @@ void init(void)
|
|||
screen_access_init();
|
||||
gui_syncstatusbar_init(&statusbars);
|
||||
|
||||
#if defined(HAVE_CHARGING) && (CONFIG_CPU == SH7034)
|
||||
#if defined(CONFIG_CHARGING) && (CONFIG_CPU == SH7034)
|
||||
if (coldstart && charger_inserted()
|
||||
&& !global_settings.car_adapter_mode
|
||||
#ifdef ATA_POWER_PLAYERSTYLE
|
||||
|
|
@ -433,7 +433,7 @@ void init(void)
|
|||
}
|
||||
#endif /* #ifdef AUTOROCK */
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
car_adapter_mode_init();
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,12 +169,12 @@ bool show_info(void)
|
|||
#endif
|
||||
lcd_puts_scroll(0, y++, (unsigned char *)s);
|
||||
|
||||
#ifdef HAVE_CHARGE_CTRL
|
||||
if (charge_state == 1)
|
||||
#if CONFIG_CHARGING == CHARGING_CONTROL
|
||||
if (charge_state == CHARGING)
|
||||
snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_CHARGE));
|
||||
else if (charge_state == 2)
|
||||
else if (charge_state == TOPOFF)
|
||||
snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_TOPOFF_CHARGE));
|
||||
else if (charge_state == 3)
|
||||
else if (charge_state == TRICKLE)
|
||||
snprintf(s, sizeof(s), (char *)str(LANG_BATTERY_TRICKLE_CHARGE));
|
||||
else
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -491,7 +491,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
|
|||
return false;
|
||||
}
|
||||
|
||||
#if defined(HAVE_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|
||||
#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|
||||
if(!charger_inserted())
|
||||
#endif
|
||||
{
|
||||
|
|
@ -509,7 +509,7 @@ static bool clean_shutdown(void (*callback)(void *), void *parameter)
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
static bool waiting_to_resume_play = false;
|
||||
static long play_resume_tick;
|
||||
|
||||
|
|
@ -584,7 +584,7 @@ long default_event_handler_ex(long event, void (*callback)(void *), void *parame
|
|||
if (!clean_shutdown(callback, parameter))
|
||||
return SYS_POWEROFF;
|
||||
break;
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
case SYS_CHARGER_CONNECTED:
|
||||
car_adapter_mode_processing(true);
|
||||
return SYS_CHARGER_CONNECTED;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@
|
|||
#include "dsp.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
#include "power.h"
|
||||
#endif
|
||||
|
||||
|
|
@ -359,9 +359,9 @@ static const struct plugin_api rockbox_api = {
|
|||
#ifndef SIMULATOR
|
||||
battery_voltage,
|
||||
#endif
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
charger_inserted,
|
||||
# ifdef HAVE_CHARGE_STATE
|
||||
# if CONFIG_CHARGING == CHARGING_MONITOR
|
||||
charging_state,
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -421,9 +421,9 @@ struct plugin_api {
|
|||
#ifndef SIMULATOR
|
||||
unsigned int (*battery_voltage)(void);
|
||||
#endif
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
bool (*charger_inserted)(void);
|
||||
# ifdef HAVE_CHARGE_STATE
|
||||
# if CONFIG_CHARGING == CHARGING_MONITOR
|
||||
bool (*charging_state)(void);
|
||||
# endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -128,14 +128,14 @@ void exit_tsr(void)
|
|||
/* use long for aligning */
|
||||
unsigned long thread_stack[THREAD_STACK_SIZE/sizeof(long)];
|
||||
|
||||
#if defined(HAVE_CHARGING) || defined(HAVE_USB_POWER)
|
||||
#if defined(CONFIG_CHARGING) || defined(HAVE_USB_POWER)
|
||||
unsigned int charge_state(void)
|
||||
{
|
||||
unsigned int ret = 0;
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
if(rb->charger_inserted())
|
||||
ret = BIT_CHARGER;
|
||||
#ifdef HAVE_CHARGE_STATE
|
||||
#if CONFIG_CHARGING == CHARGING_MONITOR
|
||||
if(rb->charging_state())
|
||||
ret |= BIT_CHARGING;
|
||||
#endif
|
||||
|
|
@ -154,7 +154,7 @@ void thread(void)
|
|||
int fd, buffelements, tick = 1, i = 0, skipped = 0, exit = 0;
|
||||
int fst = 0, lst = 0; /* first and last skipped tick */
|
||||
unsigned int last_voltage = 0;
|
||||
#if defined(HAVE_CHARGING) || defined(HAVE_USB_POWER)
|
||||
#if defined(CONFIG_CHARGING) || defined(HAVE_USB_POWER)
|
||||
unsigned int last_state = 0;
|
||||
#endif
|
||||
long sleep_time;
|
||||
|
|
@ -202,9 +202,9 @@ void thread(void)
|
|||
rb->fdprintf(fd,
|
||||
"%02d:%02d:%02d, %05d, %03d%%, "
|
||||
"%02d:%02d, %04d, %04d"
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
", %c"
|
||||
#ifdef HAVE_CHARGE_STATE
|
||||
#if CONFIG_CHARGING == CHARGING_MONITOR
|
||||
", %c"
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -215,7 +215,7 @@ void thread(void)
|
|||
|
||||
HMS(secs), secs, bat[j].level,
|
||||
bat[j].eta / 60, bat[j].eta % 60,
|
||||
#if defined(HAVE_CHARGING) || defined(HAVE_USB_POWER)
|
||||
#if defined(CONFIG_CHARGING) || defined(HAVE_USB_POWER)
|
||||
(bat[j].voltage &
|
||||
(~(BIT_CHARGER|BIT_CHARGING|BIT_USB_POWER)))
|
||||
*10,
|
||||
|
|
@ -223,9 +223,9 @@ void thread(void)
|
|||
bat[j].voltage * 10,
|
||||
#endif
|
||||
temp + 1 + (j-i)
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
,(bat[j].voltage & BIT_CHARGER)?'A':'-'
|
||||
#ifdef HAVE_CHARGE_STATE
|
||||
#if CONFIG_CHARGING == CHARGING_MONITOR
|
||||
,(bat[j].voltage & BIT_CHARGING)?'C':'-'
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -260,7 +260,7 @@ void thread(void)
|
|||
timeflag = true;
|
||||
|
||||
if(last_voltage != (current_voltage=rb->battery_voltage())
|
||||
#if defined(HAVE_CHARGING) || defined(HAVE_USB_POWER)
|
||||
#if defined(CONFIG_CHARGING) || defined(HAVE_USB_POWER)
|
||||
|| last_state != charge_state()
|
||||
#endif
|
||||
)
|
||||
|
|
@ -280,7 +280,7 @@ void thread(void)
|
|||
bat[i].level = rb->battery_level();
|
||||
bat[i].eta = rb->battery_time();
|
||||
last_voltage = bat[i].voltage = current_voltage;
|
||||
#if defined(HAVE_CHARGING) || defined(HAVE_USB_POWER)
|
||||
#if defined(CONFIG_CHARGING) || defined(HAVE_USB_POWER)
|
||||
bat[i].voltage |= last_state = charge_state();
|
||||
#endif
|
||||
i++;
|
||||
|
|
@ -421,10 +421,10 @@ int main(void)
|
|||
"Battery type: %d mAh Buffer Entries: %d\n"
|
||||
" Time:, Seconds:, Level:, Time Left:, Voltage[mV]:,"
|
||||
" M/DA:"
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
", C:"
|
||||
#endif
|
||||
#ifdef HAVE_CHARGE_STATE
|
||||
#if CONFIG_CHARGING == CHARGING_MONITOR
|
||||
", S:"
|
||||
#endif
|
||||
#ifdef HAVE_USB_POWER
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ unsigned short adc_read(int channel)
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|
||||
#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
void charging_display_info(bool animate)
|
||||
|
|
@ -178,16 +178,16 @@ void charging_display_info(bool animate)
|
|||
lcd_puts(0, 7, buf);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARGE_CTRL
|
||||
#if CONFIG_CHARGING == CHARGING_CONTROL
|
||||
|
||||
snprintf(buf, 32, "Charge mode:");
|
||||
lcd_puts(0, 2, buf);
|
||||
|
||||
if (charge_state == 1)
|
||||
if (charge_state == CHARGING)
|
||||
snprintf(buf, 32, str(LANG_BATTERY_CHARGE));
|
||||
else if (charge_state == 2)
|
||||
else if (charge_state == TOPOFF)
|
||||
snprintf(buf, 32, str(LANG_BATTERY_TOPOFF_CHARGE));
|
||||
else if (charge_state == 3)
|
||||
else if (charge_state == TRICKLE)
|
||||
snprintf(buf, 32, str(LANG_BATTERY_TRICKLE_CHARGE));
|
||||
else
|
||||
snprintf(buf, 32, "not charging");
|
||||
|
|
@ -195,7 +195,7 @@ void charging_display_info(bool animate)
|
|||
lcd_puts(0, 3, buf);
|
||||
if (!charger_enabled)
|
||||
animate = false;
|
||||
#endif /* HAVE_CHARGE_CTRL */
|
||||
#endif /* CONFIG_CHARGING == CHARGING_CONTROL */
|
||||
|
||||
|
||||
/* middle part */
|
||||
|
|
@ -351,7 +351,7 @@ int charging_screen(void)
|
|||
#endif
|
||||
return rc;
|
||||
}
|
||||
#endif /* HAVE_CHARGING && !HAVE_POWEROFF_WHILE_CHARGING */
|
||||
#endif /* CONFIG_CHARGING && !HAVE_POWEROFF_WHILE_CHARGING */
|
||||
|
||||
#if (CONFIG_KEYPAD != PLAYER_PAD)
|
||||
/* returns:
|
||||
|
|
@ -660,7 +660,7 @@ bool quick_screen_f3(int button_enter)
|
|||
#endif /* BUTTON_F3 */
|
||||
#endif /* CONFIG_KEYPAD in (RECORDER_PAD |IRIVER_H100_PAD | IRIVER_H300_PAD) */
|
||||
|
||||
#if defined(HAVE_CHARGING) || defined(SIMULATOR)
|
||||
#if defined(CONFIG_CHARGING) || defined(SIMULATOR)
|
||||
void charging_splash(void)
|
||||
{
|
||||
gui_syncsplash(2*HZ, true, (unsigned char *)str(LANG_BATTERY_CHARGE));
|
||||
|
|
|
|||
|
|
@ -243,7 +243,7 @@ static const struct bit_entry rtc_bits[] =
|
|||
{6, S_O(contrast), 40, "contrast", NULL },
|
||||
#ifdef CONFIG_BACKLIGHT
|
||||
{5, S_O(backlight_timeout), 5, "backlight timeout", backlight_times_conf },
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
{5, S_O(backlight_timeout_plugged), 11, "backlight timeout plugged",
|
||||
backlight_times_conf },
|
||||
#endif
|
||||
|
|
@ -276,7 +276,7 @@ static const struct bit_entry rtc_bits[] =
|
|||
{12, S_O(battery_capacity), BATTERY_CAPACITY_DEFAULT, "battery capacity",
|
||||
NULL }, /* 1500...3200 for NiMH, 2200...3200 for LiIon,
|
||||
500...1500 for Alkaline */
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
{1, S_O(car_adapter_mode), false, "car adapter mode", off_on },
|
||||
#endif
|
||||
/* tuner */
|
||||
|
|
@ -296,7 +296,7 @@ static const struct bit_entry rtc_bits[] =
|
|||
{1, S_O(remote_flip_display), false, "remote flip display", off_on },
|
||||
{5, S_O(remote_backlight_timeout), 5, "remote backlight timeout",
|
||||
backlight_times_conf },
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
{5, S_O(remote_backlight_timeout_plugged), 11,
|
||||
"remote backlight timeout plugged", backlight_times_conf },
|
||||
#endif
|
||||
|
|
@ -1018,13 +1018,13 @@ void settings_apply(void)
|
|||
lcd_remote_emireduce(global_settings.remote_reduce_ticking);
|
||||
#endif
|
||||
remote_backlight_set_timeout(global_settings.remote_backlight_timeout);
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged);
|
||||
#endif
|
||||
#endif
|
||||
#ifdef CONFIG_BACKLIGHT
|
||||
backlight_set_timeout(global_settings.backlight_timeout);
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged);
|
||||
#endif
|
||||
#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ void dac_line_in(bool enable);
|
|||
#include "backdrop.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
static bool car_adapter_mode(void)
|
||||
{
|
||||
return set_bool( str(LANG_CAR_ADAPTER_MODE),
|
||||
|
|
@ -177,7 +177,7 @@ static bool caption_backlight(void)
|
|||
&global_settings.caption_backlight);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
static bool backlight_timer_plugged(void)
|
||||
{
|
||||
return set_option((char *)str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
|
||||
|
|
@ -248,7 +248,7 @@ static bool remote_backlight_timer(void)
|
|||
remote_backlight_set_timeout );
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
static bool remote_backlight_timer_plugged(void)
|
||||
{
|
||||
return set_option((char *)str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
|
||||
|
|
@ -1715,7 +1715,7 @@ static bool lcd_settings_menu(void)
|
|||
static const struct menu_item items[] = {
|
||||
#ifdef CONFIG_BACKLIGHT
|
||||
{ ID2P(LANG_BACKLIGHT), backlight_timer },
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
{ ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_timer_plugged },
|
||||
#endif
|
||||
{ ID2P(LANG_CAPTION_BACKLIGHT), caption_backlight },
|
||||
|
|
@ -1763,7 +1763,7 @@ static bool lcd_remote_settings_menu(void)
|
|||
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_BACKLIGHT), remote_backlight_timer },
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
{ ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING),
|
||||
remote_backlight_timer_plugged },
|
||||
#endif
|
||||
|
|
@ -1860,9 +1860,7 @@ static bool battery_settings_menu(void)
|
|||
{ ID2P(LANG_BATTERY_TYPE), battery_type },
|
||||
#endif
|
||||
#else
|
||||
#ifndef HAVE_CHARGE_CTRL
|
||||
{ "Dummy", NULL }, /* to have an entry at all, in the simulator */
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
@ -1975,7 +1973,7 @@ static bool system_settings_menu(void)
|
|||
#if CONFIG_CODEC == MAS3507D
|
||||
{ ID2P(LANG_LINE_IN), line_in },
|
||||
#endif
|
||||
#ifdef HAVE_CHARGING
|
||||
#ifdef CONFIG_CHARGING
|
||||
{ ID2P(LANG_CAR_ADAPTER_MODE), car_adapter_mode },
|
||||
#endif
|
||||
};
|
||||
|
|
|
|||
|
|
@ -49,12 +49,6 @@
|
|||
|
||||
enum playmode ff_mode;
|
||||
|
||||
long switch_tick;
|
||||
bool battery_state = true;
|
||||
#ifdef HAVE_CHARGING
|
||||
int battery_charge_step = 0;
|
||||
#endif
|
||||
|
||||
void status_init(void)
|
||||
{
|
||||
ff_mode = 0;
|
||||
|
|
|
|||
|
|
@ -21,12 +21,6 @@
|
|||
|
||||
extern enum playmode ff_mode;
|
||||
|
||||
extern long switch_tick;
|
||||
extern bool battery_state;
|
||||
#ifdef HAVE_CHARGING
|
||||
extern int battery_charge_step;
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_LCD_CHARCELLS)
|
||||
extern bool record;
|
||||
extern bool audio;
|
||||
|
|
|
|||
|
|
@ -644,7 +644,7 @@ static bool dirbrowse(void)
|
|||
if (!global_settings.party_mode)
|
||||
audio_stop();
|
||||
}
|
||||
#if defined(HAVE_CHARGING) && \
|
||||
#if defined(CONFIG_CHARGING) && \
|
||||
(CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
|
||||
else {
|
||||
if (!charger_inserted()) {
|
||||
|
|
@ -658,7 +658,7 @@ static bool dirbrowse(void)
|
|||
#endif
|
||||
}
|
||||
break;
|
||||
#if defined(HAVE_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|
||||
#if defined(CONFIG_CHARGING) && !defined(HAVE_POWEROFF_WHILE_CHARGING)
|
||||
case TREE_OFF | BUTTON_REPEAT:
|
||||
if (charger_inserted()) {
|
||||
charging_splash();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue