From 5dd17b1857b5de2a0250ef79898d2009583b6278 Mon Sep 17 00:00:00 2001 From: Jörg Hohensohn Date: Thu, 17 Jul 2003 20:29:51 +0000 Subject: A very basic charging screen, probably buggy, the pro's would make it much nicer, but it's a starting point. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3841 a1c6a512-1295-4272-9138-f99709370657 --- apps/main.c | 16 +++++++++++++--- apps/screens.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ apps/screens.h | 2 ++ 3 files changed, 71 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/main.c b/apps/main.c index 820c9c3088..c01e2d84e8 100644 --- a/apps/main.c +++ b/apps/main.c @@ -51,6 +51,8 @@ #include "playlist.h" #include "buffer.h" #include "rolo.h" +#include "screens.h" +#include "power.h" char appsversion[]=APPSVERSION; @@ -98,7 +100,8 @@ void init(void) { int rc, i; struct partinfo* pinfo; - bool coldstart; /* starting from Flash */ + /* if nobody initialized ATA before, I consider this a cold start */ + bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */ system_init(); kernel_init(); @@ -133,8 +136,14 @@ void init(void) button_init(); - /* if nobody initialized ATA before, I consider this a cold start */ - coldstart = (PACR2 & 0x4000) != 0; + if (coldstart && charger_inserted()) + { + rc = charging_screen(); /* display a "charging" screen */ + if (rc == 1 || rc == 2) /* charger removed or "Off/Stop" pressed */ + power_off(); + /* "On" pressed or USB connected: proceed */ + ide_power_enable(true); + } rc = ata_init(); if(rc) @@ -222,3 +231,4 @@ int main(void) return 0; } #endif + diff --git a/apps/screens.c b/apps/screens.c index eb31eff5cf..df9c19eda5 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -32,6 +32,7 @@ #include "playlist.h" #include "sprintf.h" #include "kernel.h" +#include "power.h" #ifdef HAVE_LCD_BITMAP #define BMPHEIGHT_usb_logo 32 @@ -116,6 +117,60 @@ void usb_screen(void) #endif } + +/* blocks while charging, returns on event: + 1 if charger cable was removed + 2 if Off/Stop key was pressed + 3 if On key was pressed + 4 if USB was connected */ +int charging_screen(void) +{ + int button; + int rc = 0; +#ifdef HAVE_RECORDER_KEYPAD + const int offbutton = BUTTON_OFF; +#else + const int offbutton = BUTTON_STOP; +#endif + + ide_power_enable(false); /* power down the disk, else would be spinning */ + + backlight_on(); + lcd_clear_display(); + status_draw(true); + +#ifdef HAVE_LCD_BITMAP + lcd_puts(0, 3, "[Rockbox charging]"); /* ToDo: show some logo instead */ + lcd_update(); +#else + status_set_playmode(STATUS_STOP); + lcd_puts(0, 1, "[charging]"); +#endif + + charger_enable(true); + + do + { + status_draw(false); + button = button_get_w_tmo(HZ/2); + if (button == BUTTON_ON) + rc = 3; + else if (button == offbutton) + rc = 2; + else + { + if (usb_detect()) + rc = 4; + else if (!charger_inserted()) + rc = 1; + } + } while (!rc); + + return rc; +} + + + #ifdef HAVE_RECORDER_KEYPAD /* returns: 0 if no key was pressed @@ -643,3 +698,4 @@ void splash(int ticks, /* how long */ sleep(ticks); } } + diff --git a/apps/screens.h b/apps/screens.h index 2e3ebf778d..4a35d410f1 100644 --- a/apps/screens.h +++ b/apps/screens.h @@ -21,6 +21,7 @@ void usb_display_info(void); void usb_screen(void); +int charging_screen(void); #ifdef HAVE_RECORDER_KEYPAD int on_screen(void); @@ -36,3 +37,4 @@ void splash(int ticks, /* how long */ ...); #endif + -- cgit v1.2.3