summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJörg Hohensohn <hohensoh@rockbox.org>2003-07-17 20:29:51 +0000
committerJörg Hohensohn <hohensoh@rockbox.org>2003-07-17 20:29:51 +0000
commit5dd17b1857b5de2a0250ef79898d2009583b6278 (patch)
tree9797afe8303647d2a4ed862d06bd05ca43d04a7f
parent782e2370e8022b0654edd6d1dbff67b10e6eeceb (diff)
downloadrockbox-5dd17b1857b5de2a0250ef79898d2009583b6278.tar.gz
rockbox-5dd17b1857b5de2a0250ef79898d2009583b6278.zip
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
-rw-r--r--apps/main.c16
-rw-r--r--apps/screens.c56
-rw-r--r--apps/screens.h2
3 files changed, 71 insertions, 3 deletions
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 @@
51#include "playlist.h" 51#include "playlist.h"
52#include "buffer.h" 52#include "buffer.h"
53#include "rolo.h" 53#include "rolo.h"
54#include "screens.h"
55#include "power.h"
54 56
55char appsversion[]=APPSVERSION; 57char appsversion[]=APPSVERSION;
56 58
@@ -98,7 +100,8 @@ void init(void)
98{ 100{
99 int rc, i; 101 int rc, i;
100 struct partinfo* pinfo; 102 struct partinfo* pinfo;
101 bool coldstart; /* starting from Flash */ 103 /* if nobody initialized ATA before, I consider this a cold start */
104 bool coldstart = (PACR2 & 0x4000) != 0; /* starting from Flash */
102 105
103 system_init(); 106 system_init();
104 kernel_init(); 107 kernel_init();
@@ -133,8 +136,14 @@ void init(void)
133 136
134 button_init(); 137 button_init();
135 138
136 /* if nobody initialized ATA before, I consider this a cold start */ 139 if (coldstart && charger_inserted())
137 coldstart = (PACR2 & 0x4000) != 0; 140 {
141 rc = charging_screen(); /* display a "charging" screen */
142 if (rc == 1 || rc == 2) /* charger removed or "Off/Stop" pressed */
143 power_off();
144 /* "On" pressed or USB connected: proceed */
145 ide_power_enable(true);
146 }
138 147
139 rc = ata_init(); 148 rc = ata_init();
140 if(rc) 149 if(rc)
@@ -222,3 +231,4 @@ int main(void)
222 return 0; 231 return 0;
223} 232}
224#endif 233#endif
234
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 @@
32#include "playlist.h" 32#include "playlist.h"
33#include "sprintf.h" 33#include "sprintf.h"
34#include "kernel.h" 34#include "kernel.h"
35#include "power.h"
35 36
36#ifdef HAVE_LCD_BITMAP 37#ifdef HAVE_LCD_BITMAP
37#define BMPHEIGHT_usb_logo 32 38#define BMPHEIGHT_usb_logo 32
@@ -116,6 +117,60 @@ void usb_screen(void)
116#endif 117#endif
117} 118}
118 119
120
121/* blocks while charging, returns on event:
122 1 if charger cable was removed
123 2 if Off/Stop key was pressed
124 3 if On key was pressed
125 4 if USB was connected */
126int charging_screen(void)
127{
128 int button;
129 int rc = 0;
130#ifdef HAVE_RECORDER_KEYPAD
131 const int offbutton = BUTTON_OFF;
132#else
133 const int offbutton = BUTTON_STOP;
134#endif
135
136 ide_power_enable(false); /* power down the disk, else would be spinning */
137
138 backlight_on();
139 lcd_clear_display();
140 status_draw(true);
141
142#ifdef HAVE_LCD_BITMAP
143 lcd_puts(0, 3, "[Rockbox charging]"); /* ToDo: show some logo instead */
144 lcd_update();
145#else
146 status_set_playmode(STATUS_STOP);
147 lcd_puts(0, 1, "[charging]");
148#endif
149
150 charger_enable(true);
151
152 do
153 {
154 status_draw(false);
155 button = button_get_w_tmo(HZ/2);
156 if (button == BUTTON_ON)
157 rc = 3;
158 else if (button == offbutton)
159 rc = 2;
160 else
161 {
162 if (usb_detect())
163 rc = 4;
164 else if (!charger_inserted())
165 rc = 1;
166 }
167 } while (!rc);
168
169 return rc;
170}
171
172
173
119#ifdef HAVE_RECORDER_KEYPAD 174#ifdef HAVE_RECORDER_KEYPAD
120/* returns: 175/* returns:
121 0 if no key was pressed 176 0 if no key was pressed
@@ -643,3 +698,4 @@ void splash(int ticks, /* how long */
643 sleep(ticks); 698 sleep(ticks);
644 } 699 }
645} 700}
701
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 @@
21 21
22void usb_display_info(void); 22void usb_display_info(void);
23void usb_screen(void); 23void usb_screen(void);
24int charging_screen(void);
24 25
25#ifdef HAVE_RECORDER_KEYPAD 26#ifdef HAVE_RECORDER_KEYPAD
26int on_screen(void); 27int on_screen(void);
@@ -36,3 +37,4 @@ void splash(int ticks, /* how long */
36 ...); 37 ...);
37 38
38#endif 39#endif
40