diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/status.c | 190 |
1 files changed, 59 insertions, 131 deletions
diff --git a/apps/status.c b/apps/status.c index 9773bc6356..7217568f60 100644 --- a/apps/status.c +++ b/apps/status.c | |||
@@ -36,14 +36,10 @@ | |||
36 | 36 | ||
37 | static enum playmode current_mode = STATUS_STOP; | 37 | static enum playmode current_mode = STATUS_STOP; |
38 | 38 | ||
39 | #if defined(HAVE_LCD_CHARCELLS) || defined(HAVE_CHARGE_CTRL) | ||
40 | static long switch_tick; | 39 | static long switch_tick; |
41 | static int battery_charge_step = 0; | 40 | static int battery_charge_step = 0; |
42 | #ifdef HAVE_CHARGE_CTRL | ||
43 | static bool plug_state; | 41 | static bool plug_state; |
44 | static bool battery_state; | 42 | static bool battery_state; |
45 | #endif | ||
46 | #endif | ||
47 | 43 | ||
48 | struct status_info { | 44 | struct status_info { |
49 | int battlevel; | 45 | int battlevel; |
@@ -111,137 +107,46 @@ void status_draw(bool force_redraw) | |||
111 | (void)force_redraw; /* players always "redraw" */ | 107 | (void)force_redraw; /* players always "redraw" */ |
112 | #endif | 108 | #endif |
113 | 109 | ||
114 | info.battlevel = battery_level(); | ||
115 | info.volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume); | 110 | info.volume = mpeg_val2phys(SOUND_VOLUME, global_settings.volume); |
116 | info.inserted = charger_inserted(); | 111 | info.inserted = charger_inserted(); |
112 | info.battlevel = battery_level(); | ||
113 | info.battery_safe = battery_level_safe(); | ||
117 | 114 | ||
118 | #if defined(HAVE_LCD_CHARCELLS) | ||
119 | lcd_icon(ICON_VOLUME, true); | ||
120 | if(info.volume > 10) | ||
121 | lcd_icon(ICON_VOLUME_1, true); | ||
122 | else | ||
123 | lcd_icon(ICON_VOLUME_1, false); | ||
124 | if(info.volume > 30) | ||
125 | lcd_icon(ICON_VOLUME_2, true); | ||
126 | else | ||
127 | lcd_icon(ICON_VOLUME_2, false); | ||
128 | if(info.volume > 50) | ||
129 | lcd_icon(ICON_VOLUME_3, true); | ||
130 | else | ||
131 | lcd_icon(ICON_VOLUME_3, false); | ||
132 | if(info.volume > 70) | ||
133 | lcd_icon(ICON_VOLUME_4, true); | ||
134 | else | ||
135 | lcd_icon(ICON_VOLUME_4, false); | ||
136 | if(info.volume > 90) | ||
137 | lcd_icon(ICON_VOLUME_5, true); | ||
138 | else | ||
139 | lcd_icon(ICON_VOLUME_5, false); | ||
140 | |||
141 | switch(current_mode) | ||
142 | { | ||
143 | case STATUS_PLAY: | ||
144 | lcd_icon(ICON_PLAY, true); | ||
145 | lcd_icon(ICON_PAUSE, false); | ||
146 | break; | ||
147 | |||
148 | case STATUS_STOP: | ||
149 | lcd_icon(ICON_PLAY, false); | ||
150 | lcd_icon(ICON_PAUSE, false); | ||
151 | break; | ||
152 | |||
153 | case STATUS_PAUSE: | ||
154 | lcd_icon(ICON_PLAY, false); | ||
155 | lcd_icon(ICON_PAUSE, true); | ||
156 | break; | ||
157 | |||
158 | default: | ||
159 | break; | ||
160 | } | ||
161 | if(info.inserted) | ||
162 | { | ||
163 | global_settings.runtime = 0; | ||
164 | if(TIME_AFTER(current_tick, switch_tick)) | ||
165 | { | ||
166 | lcd_icon(ICON_BATTERY, true); | ||
167 | lcd_icon(ICON_BATTERY_1, false); | ||
168 | lcd_icon(ICON_BATTERY_2, false); | ||
169 | lcd_icon(ICON_BATTERY_3, false); | ||
170 | switch(battery_charge_step) | ||
171 | { | ||
172 | case 0: | ||
173 | battery_charge_step++; | ||
174 | break; | ||
175 | case 1: | ||
176 | lcd_icon(ICON_BATTERY_1, true); | ||
177 | battery_charge_step++; | ||
178 | break; | ||
179 | case 2: | ||
180 | lcd_icon(ICON_BATTERY_1, true); | ||
181 | lcd_icon(ICON_BATTERY_2, true); | ||
182 | battery_charge_step++; | ||
183 | break; | ||
184 | case 3: | ||
185 | lcd_icon(ICON_BATTERY_1, true); | ||
186 | lcd_icon(ICON_BATTERY_2, true); | ||
187 | lcd_icon(ICON_BATTERY_3, true); | ||
188 | battery_charge_step = 0; | ||
189 | break; | ||
190 | default: | ||
191 | battery_charge_step = 0; | ||
192 | break; | ||
193 | } | ||
194 | switch_tick = current_tick + (HZ/2); | ||
195 | } | ||
196 | } else { | ||
197 | lcd_icon(ICON_BATTERY, true); | ||
198 | if(info.battlevel > 25) | ||
199 | lcd_icon(ICON_BATTERY_1, true); | ||
200 | else | ||
201 | lcd_icon(ICON_BATTERY_1, false); | ||
202 | if(info.battlevel > 50) | ||
203 | lcd_icon(ICON_BATTERY_2, true); | ||
204 | else | ||
205 | lcd_icon(ICON_BATTERY_2, false); | ||
206 | if(info.battlevel > 75) | ||
207 | lcd_icon(ICON_BATTERY_3, true); | ||
208 | else | ||
209 | lcd_icon(ICON_BATTERY_3, false); | ||
210 | } | ||
211 | |||
212 | lcd_icon(ICON_REPEAT, global_settings.repeat_mode != REPEAT_OFF); | ||
213 | lcd_icon(ICON_1, global_settings.repeat_mode == REPEAT_ONE); | ||
214 | |||
215 | lcd_icon(ICON_RECORD, record); | ||
216 | lcd_icon(ICON_AUDIO, audio); | ||
217 | lcd_icon(ICON_PARAM, param); | ||
218 | lcd_icon(ICON_USB, usb); | ||
219 | |||
220 | #endif | ||
221 | #ifdef HAVE_LCD_BITMAP | 115 | #ifdef HAVE_LCD_BITMAP |
222 | |||
223 | tm = get_time(); | 116 | tm = get_time(); |
224 | info.hour = tm->tm_hour; | 117 | info.hour = tm->tm_hour; |
225 | info.minute = tm->tm_min; | 118 | info.minute = tm->tm_min; |
226 | info.shuffle = global_settings.playlist_shuffle; | 119 | info.shuffle = global_settings.playlist_shuffle; |
227 | info.keylock = keys_locked; | 120 | info.keylock = keys_locked; |
228 | info.battery_safe = battery_level_safe(); | ||
229 | info.repeat = global_settings.repeat_mode; | 121 | info.repeat = global_settings.repeat_mode; |
230 | 122 | ||
123 | /* only redraw if forced to, or info has changed */ | ||
231 | if (force_redraw || | 124 | if (force_redraw || |
232 | info.inserted || | 125 | info.inserted || |
233 | !info.battery_safe || | 126 | !info.battery_safe || |
234 | memcmp(&info, &lastinfo, sizeof(struct status_info))) { | 127 | memcmp(&info, &lastinfo, sizeof(struct status_info))) |
128 | { | ||
235 | lcd_clearrect(0,0,LCD_WIDTH,8); | 129 | lcd_clearrect(0,0,LCD_WIDTH,8); |
236 | 130 | #else | |
237 | #ifdef HAVE_CHARGE_CTRL /* Recorder */ | 131 | /* players always "redraw" */ |
238 | if(info.inserted) { | 132 | { |
133 | #endif | ||
134 | |||
135 | if (info.inserted) { | ||
239 | battery_state = true; | 136 | battery_state = true; |
240 | plug_state = true; | 137 | plug_state = true; |
241 | if (charge_state > 0) /* charge || top off || trickle */ | 138 | #ifdef HAVE_CHARGE_CTRL |
139 | /* zero battery run time if charging */ | ||
140 | if (charge_state > 0) | ||
242 | global_settings.runtime = 0; | 141 | global_settings.runtime = 0; |
243 | if (charge_state == 1) { /* animate battery if charging */ | 142 | |
244 | info.battlevel = battery_charge_step * 34; /* 34 for a better look */ | 143 | /* animate battery if charging */ |
144 | if (charge_state == 1) { | ||
145 | #else | ||
146 | { | ||
147 | #endif | ||
148 | /* animate in three steps (34% per step for a better look) */ | ||
149 | info.battlevel = battery_charge_step * 34; | ||
245 | if (info.battlevel > 100) | 150 | if (info.battlevel > 100) |
246 | info.battlevel = 100; | 151 | info.battlevel = 100; |
247 | if(TIME_AFTER(current_tick, switch_tick)) { | 152 | if(TIME_AFTER(current_tick, switch_tick)) { |
@@ -252,23 +157,20 @@ void status_draw(bool force_redraw) | |||
252 | } | 157 | } |
253 | else { | 158 | else { |
254 | plug_state=false; | 159 | plug_state=false; |
255 | if(!info.battery_safe) | 160 | if (info.battery_safe) |
256 | battery_state = true; | 161 | battery_state = true; |
257 | else /* blink battery if level is low */ | 162 | else { |
163 | /* blink battery if level is low */ | ||
258 | if(TIME_AFTER(current_tick, switch_tick)) { | 164 | if(TIME_AFTER(current_tick, switch_tick)) { |
259 | switch_tick = current_tick+HZ; | 165 | switch_tick = current_tick+HZ; |
260 | battery_state =! battery_state; | 166 | battery_state =! battery_state; |
261 | } | 167 | } |
168 | } | ||
262 | } | 169 | } |
263 | 170 | ||
264 | statusbar_icon_battery(info.battlevel, plug_state); | 171 | #ifdef HAVE_LCD_BITMAP |
265 | #else | 172 | if (battery_state) |
266 | #ifdef HAVE_FMADC /* FM */ | 173 | statusbar_icon_battery(info.battlevel, plug_state); |
267 | statusbar_icon_battery(info.battlevel, charger_inserted()); | ||
268 | #else /* Player */ | ||
269 | statusbar_icon_battery(info.battlevel, false); | ||
270 | #endif /* HAVE_FMADC */ | ||
271 | #endif /* HAVE_CHARGE_CTRL */ | ||
272 | statusbar_icon_volume(info.volume); | 174 | statusbar_icon_volume(info.volume); |
273 | statusbar_icon_play_state(current_mode + Icon_Play); | 175 | statusbar_icon_play_state(current_mode + Icon_Play); |
274 | switch (info.repeat) { | 176 | switch (info.repeat) { |
@@ -280,17 +182,43 @@ void status_draw(bool force_redraw) | |||
280 | statusbar_icon_play_mode(Icon_Repeat); | 182 | statusbar_icon_play_mode(Icon_Repeat); |
281 | break; | 183 | break; |
282 | } | 184 | } |
283 | if(info.shuffle) | 185 | if (info.shuffle) |
284 | statusbar_icon_shuffle(); | 186 | statusbar_icon_shuffle(); |
285 | if (info.keylock) | 187 | if (info.keylock) |
286 | statusbar_icon_lock(); | 188 | statusbar_icon_lock(); |
287 | #ifdef HAVE_RTC | 189 | #ifdef HAVE_RTC |
288 | statusbar_time(info.hour, info.minute); | 190 | statusbar_time(info.hour, info.minute); |
289 | #endif | 191 | #endif |
290 | |||
291 | lcd_update_rect(0, 0, LCD_WIDTH, STATUSBAR_HEIGHT); | 192 | lcd_update_rect(0, 0, LCD_WIDTH, STATUSBAR_HEIGHT); |
193 | lastinfo = info; | ||
194 | #endif | ||
292 | } | 195 | } |
293 | 196 | ||
294 | lastinfo = info; | 197 | |
198 | #if defined(HAVE_LCD_CHARCELLS) | ||
199 | lcd_icon(ICON_BATTERY, battery_state); | ||
200 | lcd_icon(ICON_BATTERY_1, info.battlevel > 25); | ||
201 | lcd_icon(ICON_BATTERY_2, info.battlevel > 50); | ||
202 | lcd_icon(ICON_BATTERY_3, info.battlevel > 75); | ||
203 | |||
204 | lcd_icon(ICON_VOLUME, true); | ||
205 | lcd_icon(ICON_VOLUME_1, info.volume > 10); | ||
206 | lcd_icon(ICON_VOLUME_2, info.volume > 30); | ||
207 | lcd_icon(ICON_VOLUME_3, info.volume > 50); | ||
208 | lcd_icon(ICON_VOLUME_4, info.volume > 70); | ||
209 | lcd_icon(ICON_VOLUME_5, info.volume > 90); | ||
210 | |||
211 | lcd_icon(ICON_PLAY, current_mode == STATUS_PLAY); | ||
212 | lcd_icon(ICON_PAUSE, current_mode == STATUS_PAUSE); | ||
213 | |||
214 | lcd_icon(ICON_REPEAT, global_settings.repeat_mode != REPEAT_OFF); | ||
215 | lcd_icon(ICON_1, global_settings.repeat_mode == REPEAT_ONE); | ||
216 | |||
217 | lcd_icon(ICON_RECORD, record); | ||
218 | lcd_icon(ICON_AUDIO, audio); | ||
219 | lcd_icon(ICON_PARAM, param); | ||
220 | lcd_icon(ICON_USB, usb); | ||
295 | #endif | 221 | #endif |
222 | |||
296 | } | 223 | } |
224 | |||