|
Rockbox mail archiveSubject: Re: Charging screen, Re: An other battery issue with flashed rockboxRe: Charging screen, Re: An other battery issue with flashed rockbox
From: Nix <nix_at_esperi.demon.co.uk>
Date: Sat, 19 Jul 2003 00:57:19 +0100 On Fri, 18 Jul 2003, Henrik Backe yowled: > Also you could examine Mike Holden's USB battery info patch > at http://www.mikeholden.org/~rockbox/patches/battery.diff > It does not apply correctly any more, but I don't think it will take to much > work to > get it to work. A few days ago I posted one that worked (well, that worked as of a few days ago). Here it is again: diff -durN rockbox-devel-orig/apps/debug_menu.c rockbox-devel-battery/apps/debug_menu.c --- rockbox-devel-orig/apps/debug_menu.c 2003-05-26 14:01:50.000000000 +0100 +++ rockbox-devel-battery/apps/debug_menu.c 2003-07-05 23:45:39.000000000 +0100 _at__at_ -799,9 +799,9 _at__at_ snprintf(buf, 30, "Charger: %s", charger_inserted() ? "present" : "absent"); lcd_puts(0, 3, buf); -#ifdef HAVE_CHARGE_CTRL +#ifdef HAVE_CHARGE_DETECT snprintf(buf, 30, "Charging: %s", - charger_enabled ? "yes" : "no"); + charger_is_enabled() ? "yes" : "no"); lcd_puts(0, 4, buf); #endif y = ( power_history[POWER_HISTORY_LEN-1] * 100 _at__at_ -845,7 +845,7 _at__at_ lcd_clear_display(); #ifdef HAVE_CHARGE_CTRL - snprintf(buf, 30, "charge_state: %d", charge_state); + snprintf(buf, 30, "charge_state: %d", charger_status()); lcd_puts(0, 0, buf); snprintf(buf, 30, "Cycle time: %d m", powermgmt_last_cycle_startstop_min); diff -durN rockbox-devel-orig/apps/main_menu.c rockbox-devel-battery/apps/main_menu.c --- rockbox-devel-orig/apps/main_menu.c 2003-07-05 20:33:40.000000000 +0100 +++ rockbox-devel-battery/apps/main_menu.c 2003-07-05 23:45:39.000000000 +0100 _at__at_ -190,11 +190,11 _at__at_ lcd_puts(0, y++, s); #ifdef HAVE_CHARGE_CTRL - if (charge_state == 1) + if (charger_status() == 1) snprintf(s, sizeof(s), str(LANG_BATTERY_CHARGE)); - else if (charge_state == 2) + else if (charger_status() == 2) snprintf(s, sizeof(s), str(LANG_BATTERY_TOPOFF_CHARGE)); - else if (charge_state == 3) + else if (charger_status() == 3) snprintf(s, sizeof(s), str(LANG_BATTERY_TRICKLE_CHARGE)); else #endif diff -durN rockbox-devel-orig/apps/recorder/icons.c rockbox-devel-battery/apps/recorder/icons.c --- rockbox-devel-orig/apps/recorder/icons.c 2003-07-05 20:35:22.000000000 +0100 +++ rockbox-devel-battery/apps/recorder/icons.c 2003-07-05 23:45:39.000000000 +0100 _at__at_ -27,6 +27,7 _at__at_ #include "settings.h" #include "icons.h" +#include "usb.h" unsigned char slider_bar[] = { _at__at_ -159,12 +160,13 _at__at_ #ifdef SIMULATOR if (global_settings.battery_type) { #else -#ifdef HAVE_CHARGE_CTRL /* Recorder */ +#ifdef HAVE_CHARGE_DETECT /* Recorder & FM */ /* show graphical animation when charging instead of numbers */ - if ((global_settings.battery_type) && (charge_state != 1)) { -#else /* FM */ + if (((global_settings.battery_type) && (charger_status() != 1)) || + usb_inserted()) { +#else if (global_settings.battery_type) { -#endif /* HAVE_CHARGE_CTRL */ +#endif /* HAVE_CHARGE_DETECT */ #endif /* Numeric display */ snprintf(buffer, sizeof(buffer), "%3d", percent); diff -durN rockbox-devel-orig/apps/screens.c rockbox-devel-battery/apps/screens.c --- rockbox-devel-orig/apps/screens.c 2003-07-05 20:34:02.000000000 +0100 +++ rockbox-devel-battery/apps/screens.c 2003-07-05 23:46:15.000000000 +0100 _at__at_ -32,6 +32,7 _at__at_ #include "playlist.h" #include "sprintf.h" #include "kernel.h" +#include "powermgmt.h" #ifdef HAVE_LCD_BITMAP #define BMPHEIGHT_usb_logo 32 _at__at_ -74,9 +75,20 _at__at_ void usb_display_info(void) { - lcd_clear_display(); + unsigned char buffer[7]; +#ifdef HAVE_LCD_BITMAP + unsigned int width, height; +#endif + int runtime = battery_time(); + int hour = runtime / 60; + int minute = runtime % 60; + + snprintf(buffer, sizeof(buffer), "%2dh%02dm", hour, minute); #ifdef HAVE_LCD_BITMAP + lcd_getstringsize(buffer, &width, &height); + lcd_clear_display(); + /* lcd_bitmap() only supports 16 pixels height! */ lcd_bitmap(usb_logo, 6, 16, BMPWIDTH_usb_logo, 8, false); _at__at_ -87,9 +99,11 _at__at_ lcd_bitmap(usb_logo+BMPWIDTH_usb_logo*3, 6, 40, BMPWIDTH_usb_logo, 8, false); status_draw(true); + lcd_putsxy(0, LCD_HEIGHT - height, buffer); lcd_update(); #else lcd_puts(0, 0, "[USB Mode]"); + lcd_puts(0, 1, buffer); status_set_param(false); status_set_audio(false); status_set_usb(true); diff -durN rockbox-devel-orig/apps/status.c rockbox-devel-battery/apps/status.c --- rockbox-devel-orig/apps/status.c 2003-06-08 23:02:17.000000000 +0100 +++ rockbox-devel-battery/apps/status.c 2003-07-05 23:45:39.000000000 +0100 _at__at_ -33,6 +33,7 _at__at_ #include "icons.h" #endif #include "powermgmt.h" +#include "usb.h" static enum playmode current_mode = STATUS_STOP; _at__at_ -135,22 +136,27 _at__at_ if (info.inserted) { battery_state = true; plug_state = true; -#ifdef HAVE_CHARGE_CTRL +#ifdef HAVE_CHARGE_DETECT /* zero battery run time if charging */ - if (charge_state > 0) + if (charger_status() > 0) global_settings.runtime = 0; /* animate battery if charging */ - if (charge_state == 1) { + if (charger_status() == 1) { #else { #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 (!usb_inserted()) { + /* 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; + if (usb_inserted()) { + plug_state = battery_charge_step%2; + } switch_tick = current_tick + HZ; } } _at__at_ -171,19 +177,21 _at__at_ #ifdef HAVE_LCD_BITMAP if (battery_state) statusbar_icon_battery(info.battlevel, plug_state); - statusbar_icon_volume(info.volume); - statusbar_icon_play_state(current_mode + Icon_Play); - switch (info.repeat) { - case REPEAT_ONE: - statusbar_icon_play_mode(Icon_RepeatOne); - break; + if (!usb_inserted()) { + statusbar_icon_volume(info.volume); + statusbar_icon_play_state(current_mode + Icon_Play); + switch (info.repeat) { + case REPEAT_ONE: + statusbar_icon_play_mode(Icon_RepeatOne); + break; - case REPEAT_ALL: - statusbar_icon_play_mode(Icon_Repeat); - break; + case REPEAT_ALL: + statusbar_icon_play_mode(Icon_Repeat); + break; + } + if (info.shuffle) + statusbar_icon_shuffle(); } - if (info.shuffle) - statusbar_icon_shuffle(); if (info.keylock) statusbar_icon_lock(); #ifdef HAVE_RTC diff -durN rockbox-devel-orig/apps/tree.c rockbox-devel-battery/apps/tree.c --- rockbox-devel-orig/apps/tree.c 2003-07-05 20:34:10.000000000 +0100 +++ rockbox-devel-battery/apps/tree.c 2003-07-05 23:45:39.000000000 +0100 _at__at_ -1183,6 +1183,7 _at__at_ case SYS_USB_CONNECTED: status_set_playmode(STATUS_STOP); usb_screen(); + status_draw(true); reload_root = true; break; diff -durN rockbox-devel-orig/firmware/drivers/power.c rockbox-devel-battery/firmware/drivers/power.c --- rockbox-devel-orig/firmware/drivers/power.c 2003-07-05 20:36:12.000000000 +0100 +++ rockbox-devel-battery/firmware/drivers/power.c 2003-07-05 23:45:39.000000000 +0100 _at__at_ -29,6 +29,22 _at__at_ #ifndef SIMULATOR +bool charger_is_enabled(void) +{ +#ifdef HAVE_CHARGE_CTRL + /* Recorder */ + return charger_enabled; +#else +#ifdef HAVE_FMADC + /* FM */ + return adc_read(ADC_EXT_POWER) > 0x0C0; +#else + /* Player */ + return 0; +#endif /* HAVE_FMADC */ +#endif /* HAVE_CHARGE_CTRL */ +} + bool charger_inserted(void) { #ifdef HAVE_CHARGE_CTRL diff -durN rockbox-devel-orig/firmware/export/config-fmrecorder.h rockbox-devel-battery/firmware/export/config-fmrecorder.h --- rockbox-devel-orig/firmware/export/config-fmrecorder.h 2003-05-05 23:04:36.000000000 +0100 +++ rockbox-devel-battery/firmware/export/config-fmrecorder.h 2003-07-05 23:45:39.000000000 +0100 _at__at_ -16,6 +16,9 _at__at_ /* Define this if you have a FM Recorder key system */ #define HAVE_FMADC 1 +/* Define this if you have charging detection */ +#define HAVE_CHARGE_DETECT + /* Define this if you have a LiIon battery */ #define HAVE_LIION diff -durN rockbox-devel-orig/firmware/export/config-recorder.h rockbox-devel-battery/firmware/export/config-recorder.h --- rockbox-devel-orig/firmware/export/config-recorder.h 2003-05-05 23:41:56.000000000 +0100 +++ rockbox-devel-battery/firmware/export/config-recorder.h 2003-07-05 23:45:39.000000000 +0100 _at__at_ -16,6 +16,9 _at__at_ /* Define this if you have charging control */ #define HAVE_CHARGE_CTRL +/* Define this if you have charging detection */ +#define HAVE_CHARGE_DETECT + /* Define this if you have ATA power-off control */ #define HAVE_ATA_POWER_OFF diff -durN rockbox-devel-orig/firmware/export/power.h rockbox-devel-battery/firmware/export/power.h --- rockbox-devel-orig/firmware/export/power.h 2003-02-07 10:07:49.000000000 +0000 +++ rockbox-devel-battery/firmware/export/power.h 2003-07-05 23:45:39.000000000 +0100 _at__at_ -19,10 +19,7 _at__at_ #ifndef _POWER_H_ #define _POWER_H_ -#ifdef HAVE_CHARGE_CTRL -extern bool charger_enabled; -#endif - +bool charger_is_enabled(void); bool charger_inserted(void); void charger_enable(bool on); void ide_power_enable(bool on); diff -durN rockbox-devel-orig/firmware/export/powermgmt.h rockbox-devel-battery/firmware/export/powermgmt.h --- rockbox-devel-orig/firmware/export/powermgmt.h 2003-05-05 23:40:58.000000000 +0100 +++ rockbox-devel-battery/firmware/export/powermgmt.h 2003-07-05 23:45:39.000000000 +0100 _at__at_ -68,7 +68,6 _at__at_ extern int battery_lazyness[20]; /* how does the battery react when plugging in/out the charger */ void enable_trickle_charge(bool on); extern int trickle_sec; /* trickle charge: How many seconds per minute are we charging actually? */ -extern int charge_state; /* tells what the charger is doing (for info display): 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */ #endif /* HAVE_CHARGE_CTRL */ _at__at_ -84,6 +83,12 _at__at_ #endif /* SIMULATOR */ +/* Returns charging status */ +/* FM, 0: not charging, 1: charging */ +/* Recorder, 0: decharging/charger off, 1: charge, 2: top-off, 3: trickle */ +/* Player, always returns 0 */ +int charger_status(void); + /* Returns battery level in percent */ int battery_level(void); int battery_time(void); /* minutes */ diff -durN rockbox-devel-orig/firmware/powermgmt.c rockbox-devel-battery/firmware/powermgmt.c --- rockbox-devel-orig/firmware/powermgmt.c 2003-06-11 23:29:51.000000000 +0100 +++ rockbox-devel-battery/firmware/powermgmt.c 2003-07-05 23:45:39.000000000 +0100 _at__at_ -40,6 +40,11 _at__at_ #ifdef SIMULATOR +int charger_status(void) +{ + return 0; +} + int battery_level(void) { return 75; _at__at_ -146,6 +151,22 _at__at_ unsigned short power_history[POWER_HISTORY_LEN]; +int charger_status(void) +{ +#ifdef HAVE_CHARGE_CTRL + /* Recorder */ + return charge_state; +#else +#ifdef HAVE_FMADC + /* FM */ + return adc_read(ADC_EXT_POWER) > 0x0C0; +#else + /* Player */ + return 0; +#endif /* HAVE_FMADC */ +#endif /* HAVE_CHARGE_CTRL */ +} + int battery_time(void) { return powermgmt_est_runningtime_min; _at__at_ -598,7 +619,7 _at__at_ /* the charger is enabled here only in one case: if it was turned on at boot time (power_init) */ /* turn it off now */ - if (charger_enabled) + if (charger_is_enabled()) charger_enable(false); } diff -durN rockbox-devel-orig/firmware/usb.c rockbox-devel-battery/firmware/usb.c --- rockbox-devel-orig/firmware/usb.c 2003-07-05 20:35:49.000000000 +0100 +++ rockbox-devel-battery/firmware/usb.c 2003-07-05 23:45:39.000000000 +0100 _at__at_ -348,4 +348,9 _at__at_ { } +bool usb_inserted(void) +{ + return 0; +} + #endif -- `We cannot get a new line down the pipe due to a blockage and we cannot dig up the road to clear the blockage because it is covered with the wrong type of tarmac.' --- British Telecom, via Mark LowesReceived on 2003-07-19 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |