diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/screens.c | 83 |
1 files changed, 79 insertions, 4 deletions
diff --git a/apps/screens.c b/apps/screens.c index df9c19eda5..93713b0587 100644 --- a/apps/screens.c +++ b/apps/screens.c | |||
@@ -33,6 +33,9 @@ | |||
33 | #include "sprintf.h" | 33 | #include "sprintf.h" |
34 | #include "kernel.h" | 34 | #include "kernel.h" |
35 | #include "power.h" | 35 | #include "power.h" |
36 | #include "system.h" | ||
37 | #include "powermgmt.h" | ||
38 | #include "adc.h" | ||
36 | 39 | ||
37 | #ifdef HAVE_LCD_BITMAP | 40 | #ifdef HAVE_LCD_BITMAP |
38 | #define BMPHEIGHT_usb_logo 32 | 41 | #define BMPHEIGHT_usb_logo 32 |
@@ -118,6 +121,78 @@ void usb_screen(void) | |||
118 | } | 121 | } |
119 | 122 | ||
120 | 123 | ||
124 | #ifdef HAVE_LCD_BITMAP | ||
125 | void charging_display_info(bool animate) | ||
126 | { | ||
127 | unsigned char charging_logo[36]; | ||
128 | const int pox_x = (LCD_WIDTH - sizeof(charging_logo)) / 2; | ||
129 | const int pox_y = 24; | ||
130 | static unsigned phase = 3; | ||
131 | unsigned i; | ||
132 | int battery_voltage; | ||
133 | int batt_int, batt_frac; | ||
134 | char buf[32]; | ||
135 | |||
136 | battery_voltage = (adc_read(ADC_UNREG_POWER) * BATTERY_SCALE_FACTOR) / 10000; | ||
137 | batt_int = battery_voltage / 100; | ||
138 | batt_frac = battery_voltage % 100; | ||
139 | |||
140 | snprintf(buf, 32, " Batt: %d.%02dV %d%% ", batt_int, batt_frac, | ||
141 | battery_level()); | ||
142 | lcd_puts(0, 6, buf); | ||
143 | |||
144 | #ifdef HAVE_CHARGE_CTRL | ||
145 | snprintf(buf, 30, " Charging: %s", charger_enabled ? "yes" : "no"); | ||
146 | lcd_puts(0, 2, buf); | ||
147 | if (!charger_enabled) | ||
148 | animate = false; | ||
149 | #endif | ||
150 | |||
151 | |||
152 | /* middle part */ | ||
153 | memset(charging_logo+3, 0x00, 32); | ||
154 | charging_logo[0] = 0x3C; | ||
155 | charging_logo[1] = 0x24; | ||
156 | charging_logo[2] = charging_logo[35] = 0xFF; | ||
157 | |||
158 | if (!animate) | ||
159 | { /* draw the outline */ | ||
160 | /* middle part */ | ||
161 | lcd_bitmap(charging_logo, pox_x, pox_y + 8, sizeof(charging_logo), 8, true); | ||
162 | /* upper line */ | ||
163 | charging_logo[0] = charging_logo[1] = 0x00; | ||
164 | memset(charging_logo+2, 0x80, 34); | ||
165 | lcd_bitmap(charging_logo, pox_x, pox_y, sizeof(charging_logo), 8, false); | ||
166 | /* lower line */ | ||
167 | memset(charging_logo+2, 0x01, 34); | ||
168 | lcd_bitmap(charging_logo, pox_x, pox_y + 16, sizeof(charging_logo), 8, false); | ||
169 | } | ||
170 | else | ||
171 | { /* animate the middle part */ | ||
172 | for (i = 3; i<MIN(sizeof(charging_logo)-1, phase); i++) | ||
173 | { | ||
174 | if ((i-phase) % 8 == 0) | ||
175 | { /* draw a "bubble" here */ | ||
176 | unsigned bitpos; | ||
177 | bitpos = (phase + i/8) % 15; /* "bounce" effect */ | ||
178 | if (bitpos > 7) | ||
179 | bitpos = 14 - bitpos; | ||
180 | charging_logo[i] = 0x01 << bitpos; | ||
181 | } | ||
182 | } | ||
183 | lcd_bitmap(charging_logo, pox_x, pox_y + 8, sizeof(charging_logo), 8, true); | ||
184 | phase++; | ||
185 | } | ||
186 | lcd_update(); | ||
187 | } | ||
188 | #else | ||
189 | void charging_display_info(bool animate) | ||
190 | { | ||
191 | (void)animate; | ||
192 | } | ||
193 | #endif | ||
194 | |||
195 | |||
121 | /* blocks while charging, returns on event: | 196 | /* blocks while charging, returns on event: |
122 | 1 if charger cable was removed | 197 | 1 if charger cable was removed |
123 | 2 if Off/Stop key was pressed | 198 | 2 if Off/Stop key was pressed |
@@ -140,8 +215,7 @@ int charging_screen(void) | |||
140 | status_draw(true); | 215 | status_draw(true); |
141 | 216 | ||
142 | #ifdef HAVE_LCD_BITMAP | 217 | #ifdef HAVE_LCD_BITMAP |
143 | lcd_puts(0, 3, "[Rockbox charging]"); /* ToDo: show some logo instead */ | 218 | charging_display_info(false); |
144 | lcd_update(); | ||
145 | #else | 219 | #else |
146 | status_set_playmode(STATUS_STOP); | 220 | status_set_playmode(STATUS_STOP); |
147 | lcd_puts(0, 1, "[charging]"); | 221 | lcd_puts(0, 1, "[charging]"); |
@@ -152,8 +226,9 @@ int charging_screen(void) | |||
152 | do | 226 | do |
153 | { | 227 | { |
154 | status_draw(false); | 228 | status_draw(false); |
155 | button = button_get_w_tmo(HZ/2); | 229 | charging_display_info(true); |
156 | if (button == BUTTON_ON) | 230 | button = button_get_w_tmo(HZ/3); |
231 | if (button == (BUTTON_ON | BUTTON_REL)) | ||
157 | rc = 3; | 232 | rc = 3; |
158 | else if (button == offbutton) | 233 | else if (button == offbutton) |
159 | rc = 2; | 234 | rc = 2; |