summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-12-21 18:10:36 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-12-21 18:10:36 +0000
commit5667682dd204a07c52f057506fd2eef05bf63f2e (patch)
treea5f4f3cb22751362a9ed7774698ca55d27819d16 /apps
parentc3c15cce88481a2504eb492ba06b6a691d8e998d (diff)
downloadrockbox-5667682dd204a07c52f057506fd2eef05bf63f2e.zip
rockbox-5667682dd204a07c52f057506fd2eef05bf63f2e.tar.gz
rockbox-5667682dd204a07c52f057506fd2eef05bf63f2e.tar.bz2
rockbox-5667682dd204a07c52f057506fd2eef05bf63f2e.tar.xz
Gigabeat S: Implement charging and power control to charge from AC or USB. Hold MENU while plugging USB cable to charge from USB without connecting. Under Windows, plugging USB for charging only but not connecting still needs to be properly handled (driver popup issue) but it will charge when connected normally-- no issue under Linux. Some accomodating changes made to powermgmt.c will soon be made nicer.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19547 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c84
1 files changed, 78 insertions, 6 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 0db0e5a..beee39a 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -1649,15 +1649,87 @@ static bool view_battery(void)
charger_inserted() ? "present" : "absent");
lcd_puts(0, 3, buf);
#if defined TOSHIBA_GIGABEAT_S
+ int line = 4;
+ unsigned int st;
+
+ static const unsigned char * const chrgstate_strings[] =
+ {
+ "Disabled",
+ "Error",
+ "Discharging",
+ "Precharge",
+ "Constant Voltage",
+ "Constant Current",
+ "<unknown>",
+ };
+
+ st = power_input_status() &
+ (POWER_INPUT_CHARGER | POWER_INPUT_BATTERY);
+ snprintf(buf, 30, "%s%s",
+ (st & POWER_INPUT_MAIN_CHARGER) ? " Main" : "",
+ (st & POWER_INPUT_USB_CHARGER) ? " USB" : "");
+ lcd_puts(0, line++, buf);
+
+ snprintf(buf, 30, "IUSB Max: %d", usb_allowed_current());
+ lcd_puts(0, line++, buf);
+
+ y = ARRAYLEN(chrgstate_strings) - 1;
+
+ switch (charge_state)
+ {
+ case CHARGE_STATE_DISABLED: y--;
+ case CHARGE_STATE_ERROR: y--;
+ case DISCHARGING: y--;
+ case TRICKLE: y--;
+ case TOPOFF: y--;
+ case CHARGING: y--;
+ default:;
+ }
+
+ snprintf(buf, 30, "State: %s", chrgstate_strings[y]);
+ lcd_puts(0, line++, buf);
+
+ snprintf(buf, 30, "Battery Switch: %s",
+ (st & POWER_INPUT_BATTERY) ? "On" : "Off");
+ lcd_puts(0, line++, buf);
+
+ y = chrgraw_adc_voltage();
+ snprintf(buf, 30, "CHRGRAW: %d.%03d V",
+ y / 1000, y % 1000);
+ lcd_puts(0, line++, buf);
+
+ y = application_supply_adc_voltage();
+ snprintf(buf, 30, "BP : %d.%03d V",
+ y / 1000, y % 1000);
+ lcd_puts(0, line++, buf);
+
y = battery_adc_charge_current();
- x = y < 0 ? '-' : ' ';
- y = abs(y);
- snprintf(buf, 30, "I Charge:%c%d.%03d A", (char)x, y / 1000, y % 1000);
- lcd_puts(0, 4, buf);
+ if (y < 0) x = '-', y = -y;
+ else x = ' ';
+ snprintf(buf, 30, "CHRGISN:%c%d mA", x, y);
+ lcd_puts(0, line++, buf);
+
+ y = cccv_regulator_dissipation();
+ snprintf(buf, 30, "P CCCV : %d mW", y);
+ lcd_puts(0, line++, buf);
+
+ y = battery_charge_current();
+ if (y < 0) x = '-', y = -y;
+ else x = ' ';
+ snprintf(buf, 30, "I Charge:%c%d mA", x, y);
+ lcd_puts(0, line++, buf);
y = battery_adc_temp();
- snprintf(buf, 30, "T Battery: %dC (%dF)", y, (9*y + 160) / 5);
- lcd_puts(0, 5, buf);
+
+ if (y != INT_MIN) {
+ snprintf(buf, 30, "T Battery: %dC (%dF)", y,
+ (9*y + 160) / 5);
+ } else {
+ /* Conversion disabled */
+ snprintf(buf, 30, "T Battery: ?");
+ }
+
+ lcd_puts(0, line++, buf);
#endif /* defined TOSHIBA_GIGABEAT_S */
#endif /* defined IPOD_NANO || defined IPOD_VIDEO */
#endif /* CONFIG_CHARGING != CHARGING_CONTROL */