1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) Robert E. Hak (2002), Linus Nielsen Feltzing (2002)
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 #include "string.h" /* for memcmp oO*/
30 #if CONFIG_CODEC == SWCODEC
34 #include "powermgmt.h"
37 #include "screen_access.h"
39 #include "status.h" /* needed for battery_state global var */
40 #include "action.h" /* for keys_locked */
41 #include "statusbar.h"
44 #include "recording.h"
45 #include "pcm_record.h"
47 #include "appevents.h"
48 #include "timefuncs.h"
50 /* FIXME: should be removed from icon.h to avoid redefinition,
51 but still needed for compatibility with old system */
52 #define ICONS_SPACING 2
53 #define STATUSBAR_BATTERY_X_POS 0*ICONS_SPACING
54 #define STATUSBAR_BATTERY_WIDTH 18
55 #define STATUSBAR_PLUG_X_POS STATUSBAR_X_POS + \
56 STATUSBAR_BATTERY_WIDTH + \
58 #define STATUSBAR_PLUG_WIDTH 7
59 #define STATUSBAR_VOLUME_X_POS STATUSBAR_X_POS + \
60 STATUSBAR_BATTERY_WIDTH + \
61 STATUSBAR_PLUG_WIDTH + \
63 #define STATUSBAR_VOLUME_WIDTH 16
64 #define STATUSBAR_ENCODER_X_POS STATUSBAR_X_POS + \
65 STATUSBAR_BATTERY_WIDTH + \
66 STATUSBAR_PLUG_WIDTH + \
68 #define STATUSBAR_ENCODER_WIDTH 18
69 #define STATUSBAR_PLAY_STATE_X_POS STATUSBAR_X_POS + \
70 STATUSBAR_BATTERY_WIDTH + \
71 STATUSBAR_PLUG_WIDTH + \
72 STATUSBAR_VOLUME_WIDTH + \
74 #define STATUSBAR_PLAY_STATE_WIDTH 7
75 #define STATUSBAR_PLAY_MODE_X_POS STATUSBAR_X_POS + \
76 STATUSBAR_BATTERY_WIDTH + \
77 STATUSBAR_PLUG_WIDTH + \
78 STATUSBAR_VOLUME_WIDTH + \
79 STATUSBAR_PLAY_STATE_WIDTH + \
81 #define STATUSBAR_PLAY_MODE_WIDTH 7
82 #define STATUSBAR_RECFREQ_X_POS STATUSBAR_X_POS + \
83 STATUSBAR_BATTERY_WIDTH + \
84 STATUSBAR_PLUG_WIDTH + \
85 STATUSBAR_VOLUME_WIDTH + \
86 STATUSBAR_PLAY_STATE_WIDTH + \
88 #define STATUSBAR_RECFREQ_WIDTH 12
89 #define STATUSBAR_RECCHANNELS_X_POS STATUSBAR_X_POS + \
90 STATUSBAR_BATTERY_WIDTH + \
91 STATUSBAR_PLUG_WIDTH + \
92 STATUSBAR_VOLUME_WIDTH + \
93 STATUSBAR_PLAY_STATE_WIDTH + \
94 STATUSBAR_RECFREQ_WIDTH + \
96 #define STATUSBAR_RECCHANNELS_WIDTH 5
97 #define STATUSBAR_SHUFFLE_X_POS STATUSBAR_X_POS + \
98 STATUSBAR_BATTERY_WIDTH + \
99 STATUSBAR_PLUG_WIDTH + \
100 STATUSBAR_VOLUME_WIDTH + \
101 STATUSBAR_PLAY_STATE_WIDTH + \
102 STATUSBAR_PLAY_MODE_WIDTH + \
104 #define STATUSBAR_SHUFFLE_WIDTH 7
105 #define STATUSBAR_LOCKM_X_POS STATUSBAR_X_POS + \
106 STATUSBAR_BATTERY_WIDTH + \
107 STATUSBAR_PLUG_WIDTH + \
108 STATUSBAR_VOLUME_WIDTH + \
109 STATUSBAR_PLAY_STATE_WIDTH + \
110 STATUSBAR_PLAY_MODE_WIDTH + \
111 STATUSBAR_SHUFFLE_WIDTH + \
113 #define STATUSBAR_LOCKM_WIDTH 5
114 #define STATUSBAR_LOCKR_X_POS STATUSBAR_X_POS + \
115 STATUSBAR_BATTERY_WIDTH + \
116 STATUSBAR_PLUG_WIDTH + \
117 STATUSBAR_VOLUME_WIDTH + \
118 STATUSBAR_PLAY_STATE_WIDTH + \
119 STATUSBAR_PLAY_MODE_WIDTH + \
120 STATUSBAR_SHUFFLE_WIDTH + \
121 STATUSBAR_LOCKM_WIDTH + \
123 #define STATUSBAR_LOCKR_WIDTH 5
125 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
126 #define STATUSBAR_DISK_WIDTH 12
127 #define STATUSBAR_DISK_X_POS(statusbar_width) statusbar_width - \
130 #define STATUSBAR_DISK_WIDTH 0
132 #define STATUSBAR_TIME_X_END(statusbar_width) statusbar_width - 1 - \
134 struct gui_syncstatusbar statusbars
;
137 #ifdef HAVE_LCD_BITMAP
138 static void gui_statusbar_icon_battery(struct screen
* display
, int percent
,
139 int batt_charge_step
);
140 static bool gui_statusbar_icon_volume(struct gui_statusbar
* bar
, int volume
);
141 static void gui_statusbar_icon_play_state(struct screen
* display
, int state
);
142 static void gui_statusbar_icon_play_mode(struct screen
* display
, int mode
);
143 static void gui_statusbar_icon_shuffle(struct screen
* display
);
144 static void gui_statusbar_icon_lock(struct screen
* display
);
145 #ifdef HAS_REMOTE_BUTTON_HOLD
146 static void gui_statusbar_icon_lock_remote(struct screen
* display
);
148 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
149 static void gui_statusbar_led(struct screen
* display
);
151 #ifdef HAVE_RECORDING
152 static void gui_statusbar_icon_recording_info(struct screen
* display
);
155 static void gui_statusbar_time(struct screen
* display
, struct tm
*time
);
163 * Initializes a status bar
164 * - bar : the bar to initialize
166 static void gui_statusbar_init(struct gui_statusbar
* bar
)
168 bar
->redraw_volume
= true;
169 bar
->volume_icon_switch_tick
= bar
->battery_icon_switch_tick
= current_tick
;
170 memset((void*)&(bar
->lastinfo
), 0, sizeof(struct status_info
));
172 bar
->last_tm_min
= 0;
176 #define GET_RECT(vp, vals,display) do { \
177 viewport_set_fullscreen(&(vp), (display)->screen_type); \
178 (vp).flags &= ~VP_FLAG_ALIGN_RIGHT; \
179 (vp).height = STATUSBAR_HEIGHT; \
180 (vp).x = STATUSBAR_X_POS; \
181 if ((vals) != STATUSBAR_BOTTOM) \
184 (vp).y = (display)->lcdheight - STATUSBAR_HEIGHT; \
187 void gui_statusbar_draw(struct gui_statusbar
* bar
, bool force_redraw
, struct viewport
*vp
)
189 struct screen
* display
= bar
->display
;
194 #ifdef HAVE_LCD_CHARCELLS
196 (void)force_redraw
; /* The Player always has "redraw" */
198 #endif /* HAVE_LCD_CHARCELLS */
200 bar
->info
.battlevel
= battery_level();
201 #ifdef HAVE_USB_POWER
202 bar
->info
.usb_inserted
= usb_inserted();
205 bar
->info
.inserted
= (charger_input_state
== CHARGER
);
206 if (bar
->info
.inserted
)
208 bar
->info
.battery_state
= true;
210 #if CONFIG_CHARGING >= CHARGING_MONITOR
212 /* zero battery run time if charging */
213 if (charge_state
> DISCHARGING
)
214 lasttime
= current_tick
;
216 /* animate battery if charging */
217 if ((charge_state
== DISCHARGING
) || (charge_state
== TRICKLE
))
219 bar
->info
.batt_charge_step
= -1;
223 #else /* CONFIG_CHARGING < CHARGING_MONITOR */
224 lasttime
= current_tick
;
226 #endif /* CONFIG_CHARGING < CHARGING_MONITOR */
227 /* animate in (max.) 4 steps, starting near the current charge level */
228 if (TIME_AFTER(current_tick
, bar
->battery_icon_switch_tick
))
230 if (++bar
->info
.batt_charge_step
> 3)
231 bar
->info
.batt_charge_step
= bar
->info
.battlevel
/ 34;
232 bar
->battery_icon_switch_tick
= current_tick
+ HZ
;
237 #endif /* CONFIG_CHARGING */
239 bar
->info
.batt_charge_step
= -1;
240 if (battery_level_safe())
241 bar
->info
.battery_state
= true;
243 /* blink battery if level is low */
244 if (TIME_AFTER(current_tick
, bar
->battery_icon_switch_tick
) &&
245 (bar
->info
.battlevel
> -1))
247 bar
->info
.battery_state
= !bar
->info
.battery_state
;
248 bar
->battery_icon_switch_tick
= current_tick
+ HZ
;
252 bar
->info
.volume
= global_settings
.volume
;
253 #ifdef HAVE_LCD_BITMAP
254 bar
->info
.shuffle
= global_settings
.playlist_shuffle
;
255 #ifdef HAS_BUTTON_HOLD
256 bar
->info
.keylock
= button_hold();
258 bar
->info
.keylock
= is_keys_locked();
259 #endif /* HAS_BUTTON_HOLD */
260 #ifdef HAS_REMOTE_BUTTON_HOLD
261 bar
->info
.keylockremote
= remote_button_hold();
263 bar
->info
.repeat
= global_settings
.repeat_mode
;
264 bar
->info
.playmode
= current_playmode();
266 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
267 if(!display
->has_disk_led
)
268 bar
->info
.led
= led_read(HZ
/2); /* delay should match polling interval */
271 bar
->time
= get_time();
272 #endif /* CONFIG_RTC */
274 /* only redraw if forced to, or info has changed */
275 if (force_redraw
|| bar
->redraw_volume
||
277 (bar
->time
->tm_min
!= bar
->last_tm_min
) ||
279 memcmp(&(bar
->info
), &(bar
->lastinfo
), sizeof(struct status_info
)))
283 struct viewport viewport
;
284 GET_RECT(viewport
,statusbar_position(display
->screen_type
),display
);
285 display
->set_viewport(&viewport
);
289 display
->set_viewport(vp
);
291 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
292 display
->fillrect(0, 0, display
->getwidth(), STATUSBAR_HEIGHT
);
293 display
->set_drawmode(DRMODE_SOLID
);
295 if (bar
->info
.battery_state
)
296 gui_statusbar_icon_battery(display
, bar
->info
.battlevel
,
297 bar
->info
.batt_charge_step
);
298 #ifdef HAVE_USB_POWER
299 if (bar
->info
.usb_inserted
)
300 display
->mono_bitmap(bitmap_icons_7x8
[Icon_USBPlug
],
301 STATUSBAR_PLUG_X_POS
,
302 STATUSBAR_Y_POS
, STATUSBAR_PLUG_WIDTH
,
304 #endif /* HAVE_USB_POWER */
306 #ifdef HAVE_USB_POWER
309 /* draw power plug if charging */
310 if (bar
->info
.inserted
)
311 display
->mono_bitmap(bitmap_icons_7x8
[Icon_Plug
],
312 STATUSBAR_PLUG_X_POS
,
313 STATUSBAR_Y_POS
, STATUSBAR_PLUG_WIDTH
,
315 #endif /* CONFIG_CHARGING */
316 #ifdef HAVE_RECORDING
317 /* turn off volume display in recording screen */
318 bool recscreen_on
= in_recording_screen();
321 bar
->redraw_volume
= gui_statusbar_icon_volume(bar
, bar
->info
.volume
);
322 gui_statusbar_icon_play_state(display
, current_playmode() + Icon_Play
);
324 #ifdef HAVE_RECORDING
325 /* If in recording screen, replace repeat mode, volume
326 and shuffle icons with recording info */
328 gui_statusbar_icon_recording_info(display
);
332 switch (bar
->info
.repeat
) {
333 #ifdef AB_REPEAT_ENABLE
335 gui_statusbar_icon_play_mode(display
, Icon_RepeatAB
);
337 #endif /* AB_REPEAT_ENABLE == 1 */
340 gui_statusbar_icon_play_mode(display
, Icon_RepeatOne
);
345 gui_statusbar_icon_play_mode(display
, Icon_Repeat
);
348 if (bar
->info
.shuffle
)
349 gui_statusbar_icon_shuffle(display
);
351 if (bar
->info
.keylock
)
352 gui_statusbar_icon_lock(display
);
353 #ifdef HAS_REMOTE_BUTTON_HOLD
354 if (bar
->info
.keylockremote
)
355 gui_statusbar_icon_lock_remote(display
);
358 gui_statusbar_time(display
, bar
->time
);
359 bar
->last_tm_min
= bar
->time
->tm_min
;
360 #endif /* CONFIG_RTC */
361 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
362 if(!display
->has_disk_led
&& bar
->info
.led
)
363 gui_statusbar_led(display
);
365 display
->update_viewport();
366 display
->set_viewport(NULL
);
367 bar
->lastinfo
= bar
->info
;
369 #endif /* HAVE_LCD_BITMAP */
372 #ifdef HAVE_LCD_CHARCELLS
373 display
->icon(ICON_BATTERY
, bar
->info
.battery_state
);
375 if (bar
->info
.batt_charge_step
> -1)
376 val
= bar
->info
.batt_charge_step
;
378 val
= (bar
->info
.battlevel
* 3 + 50) / 100;
379 display
->icon(ICON_BATTERY_1
, val
>= 1);
380 display
->icon(ICON_BATTERY_2
, val
>= 2);
381 display
->icon(ICON_BATTERY_3
, val
>= 3);
383 val
= 10 * (bar
->info
.volume
- sound_min(SOUND_VOLUME
))
384 / (sound_max(SOUND_VOLUME
) - sound_min(SOUND_VOLUME
));
385 display
->icon(ICON_VOLUME
, true);
386 display
->icon(ICON_VOLUME_1
, val
>= 1);
387 display
->icon(ICON_VOLUME_2
, val
>= 3);
388 display
->icon(ICON_VOLUME_3
, val
>= 5);
389 display
->icon(ICON_VOLUME_4
, val
>= 7);
390 display
->icon(ICON_VOLUME_5
, val
>= 9);
392 display
->icon(ICON_PLAY
, current_playmode() == STATUS_PLAY
);
393 display
->icon(ICON_PAUSE
, current_playmode() == STATUS_PAUSE
);
395 display
->icon(ICON_REPEAT
, global_settings
.repeat_mode
!= REPEAT_OFF
);
396 display
->icon(ICON_1
, global_settings
.repeat_mode
== REPEAT_ONE
);
398 display
->icon(ICON_RECORD
, record
);
399 display
->icon(ICON_AUDIO
, audio
);
400 display
->icon(ICON_PARAM
, param
);
401 display
->icon(ICON_USB
, usb
);
402 #endif /* HAVE_LCD_CHARCELLS */
405 #ifdef HAVE_LCD_BITMAP
408 * Print battery icon to status bar
410 static void gui_statusbar_icon_battery(struct screen
* display
, int percent
,
411 int batt_charge_step
)
415 unsigned int width
, height
;
417 unsigned int prevfg
= 0;
421 if (batt_charge_step
>= 0)
423 fill
= percent
* (STATUSBAR_BATTERY_WIDTH
-3) / 100;
424 endfill
= 34 * batt_charge_step
* (STATUSBAR_BATTERY_WIDTH
-3) / 100;
428 (void)batt_charge_step
;
431 fill
= endfill
= (percent
* (STATUSBAR_BATTERY_WIDTH
-3) + 50) / 100;
434 #if CONFIG_CHARGING == CHARGING_MONITOR && !defined(SIMULATOR)
435 /* Certain charge controlled targets */
436 /* show graphical animation when charging instead of numbers */
437 if ((global_settings
.battery_display
) &&
438 (charge_state
!= CHARGING
) &&
440 #else /* all others */
441 if (global_settings
.battery_display
&& (percent
> -1)) {
443 /* Numeric display */
444 display
->setfont(FONT_SYSFIXED
);
445 snprintf(buffer
, sizeof(buffer
), "%3d", percent
);
446 display
->getstringsize(buffer
, &width
, &height
);
447 if (height
<= STATUSBAR_HEIGHT
)
448 display
->putsxy(STATUSBAR_BATTERY_X_POS
449 + STATUSBAR_BATTERY_WIDTH
/ 2
450 - width
/2, STATUSBAR_Y_POS
, buffer
);
451 display
->setfont(FONT_UI
);
456 display
->drawrect(STATUSBAR_BATTERY_X_POS
, STATUSBAR_Y_POS
, 17, 7);
457 display
->vline(STATUSBAR_BATTERY_X_POS
+ 17, STATUSBAR_Y_POS
+ 2,
458 STATUSBAR_Y_POS
+ 4);
460 display
->fillrect(STATUSBAR_BATTERY_X_POS
+ 1, STATUSBAR_Y_POS
+ 1,
463 if (display
->depth
> 1)
465 prevfg
= display
->get_foreground();
466 display
->set_foreground(LCD_DARKGRAY
);
469 display
->fillrect(STATUSBAR_BATTERY_X_POS
+ 1 + fill
,
470 STATUSBAR_Y_POS
+ 1, endfill
- fill
, 5);
472 if (display
->depth
> 1)
473 display
->set_foreground(prevfg
);
478 display
->setfont(FONT_SYSFIXED
);
479 display
->putsxy(STATUSBAR_BATTERY_X_POS
+ STATUSBAR_BATTERY_WIDTH
/ 2
480 - 4, STATUSBAR_Y_POS
, "?");
481 display
->setfont(FONT_UI
);
486 * Print volume gauge to status bar
488 static bool gui_statusbar_icon_volume(struct gui_statusbar
* bar
, int volume
)
493 unsigned int width
, height
;
494 bool needs_redraw
= false;
495 int type
= global_settings
.volume_type
;
496 struct screen
* display
=bar
->display
;
497 const int minvol
= sound_min(SOUND_VOLUME
);
498 const int maxvol
= sound_max(SOUND_VOLUME
);
505 if (volume
== minvol
) {
506 display
->mono_bitmap(bitmap_icons_7x8
[Icon_Mute
],
507 STATUSBAR_VOLUME_X_POS
+ STATUSBAR_VOLUME_WIDTH
/ 2 - 4,
508 STATUSBAR_Y_POS
, 7, STATUSBAR_HEIGHT
);
511 /* We want to redraw the icon later on */
512 if (bar
->last_volume
!= volume
&& bar
->last_volume
>= minvol
) {
513 bar
->volume_icon_switch_tick
= current_tick
+ HZ
;
516 /* If the timeout hasn't yet been reached, we show it numerically
517 and tell the caller that we want to be called again */
518 if (TIME_BEFORE(current_tick
,bar
->volume_icon_switch_tick
)) {
523 /* display volume level numerical? */
526 display
->setfont(FONT_SYSFIXED
);
527 snprintf(buffer
, sizeof(buffer
), "%2d", volume
);
528 display
->getstringsize(buffer
, &width
, &height
);
529 if (height
<= STATUSBAR_HEIGHT
)
531 display
->putsxy(STATUSBAR_VOLUME_X_POS
532 + STATUSBAR_VOLUME_WIDTH
/ 2
533 - width
/2, STATUSBAR_Y_POS
, buffer
);
535 display
->setfont(FONT_UI
);
537 /* display volume bar */
538 vol
= (volume
- minvol
) * 14 / (maxvol
- minvol
);
539 for(i
=0; i
< vol
; i
++) {
540 display
->vline(STATUSBAR_VOLUME_X_POS
+ i
,
541 STATUSBAR_Y_POS
+ 6 - i
/ 2,
542 STATUSBAR_Y_POS
+ 6);
546 bar
->last_volume
= volume
;
552 * Print play state to status bar
554 static void gui_statusbar_icon_play_state(struct screen
* display
, int state
)
556 display
->mono_bitmap(bitmap_icons_7x8
[state
], STATUSBAR_PLAY_STATE_X_POS
,
557 STATUSBAR_Y_POS
, STATUSBAR_PLAY_STATE_WIDTH
,
562 * Print play mode to status bar
564 static void gui_statusbar_icon_play_mode(struct screen
* display
, int mode
)
566 display
->mono_bitmap(bitmap_icons_7x8
[mode
], STATUSBAR_PLAY_MODE_X_POS
,
567 STATUSBAR_Y_POS
, STATUSBAR_PLAY_MODE_WIDTH
,
572 * Print shuffle mode to status bar
574 static void gui_statusbar_icon_shuffle(struct screen
* display
)
576 display
->mono_bitmap(bitmap_icons_7x8
[Icon_Shuffle
],
577 STATUSBAR_SHUFFLE_X_POS
, STATUSBAR_Y_POS
,
578 STATUSBAR_SHUFFLE_WIDTH
, STATUSBAR_HEIGHT
);
582 * Print lock when keys are locked
584 static void gui_statusbar_icon_lock(struct screen
* display
)
586 display
->mono_bitmap(bitmap_icons_5x8
[Icon_Lock_Main
],
587 STATUSBAR_LOCKM_X_POS
, STATUSBAR_Y_POS
,
588 STATUSBAR_LOCKM_WIDTH
, STATUSBAR_HEIGHT
);
591 #ifdef HAS_REMOTE_BUTTON_HOLD
593 * Print remote lock when remote hold is enabled
595 static void gui_statusbar_icon_lock_remote(struct screen
* display
)
597 display
->mono_bitmap(bitmap_icons_5x8
[Icon_Lock_Remote
],
598 STATUSBAR_LOCKR_X_POS
, STATUSBAR_Y_POS
,
599 STATUSBAR_LOCKR_WIDTH
, STATUSBAR_HEIGHT
);
603 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
605 * no real LED: disk activity in status bar
607 static void gui_statusbar_led(struct screen
* display
)
609 display
->mono_bitmap(bitmap_icon_disk
,
610 STATUSBAR_DISK_X_POS(display
->getwidth()),
611 STATUSBAR_Y_POS
, STATUSBAR_DISK_WIDTH
,
618 * Print time to status bar
620 static void gui_statusbar_time(struct screen
* display
, struct tm
*time
)
622 unsigned char buffer
[6];
623 const unsigned char *p
= buffer
;
624 unsigned int width
, height
;
626 if ( valid_time(time
) ) {
627 hour
= time
->tm_hour
;
628 minute
= time
->tm_min
;
629 if ( global_settings
.timeformat
) { /* 12 hour clock */
635 snprintf(buffer
, sizeof(buffer
), "%02d:%02d", hour
, minute
);
640 display
->setfont(FONT_SYSFIXED
);
641 display
->getstringsize(p
, &width
, &height
);
642 if (height
<= STATUSBAR_HEIGHT
) {
643 display
->putsxy(STATUSBAR_TIME_X_END(display
->getwidth()) - width
,
646 display
->setfont(FONT_UI
);
650 #ifdef HAVE_RECORDING
651 #if CONFIG_CODEC == SWCODEC
653 * Write a number to the display using bitmaps and return new position
655 static int write_bitmap_number(struct screen
* display
, int value
,
659 snprintf(buf
, sizeof(buf
), "%d", value
);
661 for (ptr
= buf
; *ptr
!= '\0'; ptr
++, x
+= BM_GLYPH_WIDTH
)
662 display
->mono_bitmap(bitmap_glyphs_4x8
[*ptr
- '0'], x
, y
,
663 BM_GLYPH_WIDTH
, STATUSBAR_HEIGHT
);
668 * Write format info bitmaps - right justified
670 static void gui_statusbar_write_format_info(struct screen
* display
)
672 /* Can't fit info for sw codec targets in statusbar using FONT_SYSFIXED
674 int rec_format
= global_settings
.rec_format
;
675 unsigned bitrk
= 0; /* compiler warns about unitialized use !! */
676 int xpos
= STATUSBAR_ENCODER_X_POS
;
677 int width
= STATUSBAR_ENCODER_WIDTH
;
678 const unsigned char *bm
= bitmap_formats_18x8
[rec_format
];
680 if (rec_format
== REC_FORMAT_MPA_L3
)
682 /* Special handling for mp3 */
683 bitrk
= global_settings
.mp3_enc_config
.bitrate
;
684 bitrk
= mp3_enc_bitr
[bitrk
];
686 width
= BM_MPA_L3_M_WIDTH
;
688 /* Slide 'M' to right if fewer than three digits used */
690 bitrk
= 999; /* neurotic safety check if corrupted */
694 xpos
+= BM_GLYPH_WIDTH
;
696 xpos
+= BM_GLYPH_WIDTH
;
701 /* Show bitmap - clipping right edge if needed */
702 display
->mono_bitmap_part(bm
, 0, 0, STATUSBAR_ENCODER_WIDTH
,
703 xpos
, STATUSBAR_Y_POS
, width
, STATUSBAR_HEIGHT
);
705 if (rec_format
== REC_FORMAT_MPA_L3
)
707 xpos
+= BM_MPA_L3_M_WIDTH
; /* to right of 'M' */
708 write_bitmap_number(display
, bitrk
, xpos
, STATUSBAR_Y_POS
);
713 * Write sample rate using bitmaps - left justified
715 static void gui_statusbar_write_samplerate_info(struct screen
* display
)
717 unsigned long samprk
;
723 #ifdef HAVE_SPDIF_REC
724 if (global_settings
.rec_source
== AUDIO_SRC_SPDIF
)
725 /* Use rate in use, not current measured rate if it changed */
726 samprk
= pcm_rec_sample_rate();
729 samprk
= rec_freq_sampr
[global_settings
.rec_frequency
];
730 #endif /* SIMULATOR */
734 samprk
= 99; /* Limit to 3 glyphs */
736 xpos
= write_bitmap_number(display
, (unsigned)samprk
,
737 STATUSBAR_RECFREQ_X_POS
, STATUSBAR_Y_POS
);
740 display
->mono_bitmap(bitmap_glyphs_4x8
[Glyph_4x8_k
], xpos
,
741 STATUSBAR_Y_POS
, BM_GLYPH_WIDTH
,
744 #endif /* CONFIG_CODEC == SWCODEC */
746 static void gui_statusbar_icon_recording_info(struct screen
* display
)
748 #if CONFIG_CODEC != SWCODEC
750 const char *p
= buffer
;
752 display
->setfont(FONT_SYSFIXED
);
753 #endif /* CONFIG_CODEC != SWCODEC */
755 /* Display Codec info in statusbar */
756 #if CONFIG_CODEC == SWCODEC
757 gui_statusbar_write_format_info(display
);
759 display
->mono_bitmap(bitmap_icons_5x8
[Icon_q
],
760 STATUSBAR_ENCODER_X_POS
+ 8, STATUSBAR_Y_POS
,
761 5, STATUSBAR_HEIGHT
);
763 snprintf(buffer
, sizeof(buffer
), "%d", global_settings
.rec_quality
);
764 display
->getstringsize(buffer
, &width
, &height
);
765 if (height
<= STATUSBAR_HEIGHT
)
766 display
->putsxy(STATUSBAR_ENCODER_X_POS
+ 13, STATUSBAR_Y_POS
, buffer
);
767 #endif /* CONFIG_CODEC == SWCODEC */
769 /* Display Samplerate info in statusbar */
770 #if CONFIG_CODEC == SWCODEC
771 /* SWCODEC targets use bitmaps for glyphs */
772 gui_statusbar_write_samplerate_info(display
);
774 /* hwcodec targets have sysfont characters */
775 #ifdef HAVE_SPDIF_REC
776 if (global_settings
.rec_source
== AUDIO_SRC_SPDIF
)
778 /* Can't measure S/PDIF sample rate on Archos/Sim yet */
782 #endif /* HAVE_SPDIF_IN */
784 static const char * const freq_strings
[] =
785 {"44", "48", "32", "22", "24", "16"};
786 p
= freq_strings
[global_settings
.rec_frequency
];
789 display
->getstringsize(p
, &width
, &height
);
791 if (height
<= STATUSBAR_HEIGHT
)
792 display
->putsxy(STATUSBAR_RECFREQ_X_POS
, STATUSBAR_Y_POS
, p
);
794 display
->setfont(FONT_UI
);
795 #endif /* CONFIG_CODEC == SWCODEC */
797 /* Display Channel status in status bar */
798 if(global_settings
.rec_channels
)
800 display
->mono_bitmap(bitmap_icons_5x8
[Icon_Mono
],
801 STATUSBAR_RECCHANNELS_X_POS
, STATUSBAR_Y_POS
,
802 STATUSBAR_RECCHANNELS_WIDTH
, STATUSBAR_HEIGHT
);
806 display
->mono_bitmap(bitmap_icons_5x8
[Icon_Stereo
],
807 STATUSBAR_RECCHANNELS_X_POS
, STATUSBAR_Y_POS
,
808 STATUSBAR_RECCHANNELS_WIDTH
, STATUSBAR_HEIGHT
);
811 #endif /* HAVE_RECORDING */
813 #endif /* HAVE_LCD_BITMAP */
815 void gui_syncstatusbar_init(struct gui_syncstatusbar
* bars
)
819 gui_statusbar_init( &(bars
->statusbars
[i
]) );
820 gui_statusbar_set_screen( &(bars
->statusbars
[i
]), &(screens
[i
]) );
824 void gui_syncstatusbar_draw(struct gui_syncstatusbar
* bars
,
827 #ifdef HAVE_LCD_BITMAP
828 if(!global_settings
.statusbar
)
830 #endif /* HAVE_LCD_BITMAP */
833 gui_statusbar_draw( &(bars
->statusbars
[i
]), force_redraw
, NULL
);
838 #ifdef HAVE_REMOTE_LCD
839 enum statusbar_values
statusbar_position(int screen
)
841 if (screen
== SCREEN_REMOTE
)
842 return global_settings
.remote_statusbar
;
843 return global_settings
.statusbar
;