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 ****************************************************************************/
22 #include "screen_access.h"
25 #include "string.h" /* for memcmp oO*/
30 #if CONFIG_CODEC == SWCODEC
34 #include "powermgmt.h"
38 #include "status.h" /* needed for battery_state global var */
39 #include "action.h" /* for keys_locked */
40 #include "statusbar.h"
43 #include "recording.h"
44 #include "pcm_record.h"
46 #include "appevents.h"
47 #include "timefuncs.h"
49 /* FIXME: should be removed from icon.h to avoid redefinition,
50 but still needed for compatibility with old system */
51 #define ICONS_SPACING 2
52 #define STATUSBAR_BATTERY_X_POS 0*ICONS_SPACING
53 #define STATUSBAR_BATTERY_WIDTH 18
54 #define STATUSBAR_PLUG_X_POS STATUSBAR_X_POS + \
55 STATUSBAR_BATTERY_WIDTH + \
57 #define STATUSBAR_PLUG_WIDTH 7
58 #define STATUSBAR_VOLUME_X_POS STATUSBAR_X_POS + \
59 STATUSBAR_BATTERY_WIDTH + \
60 STATUSBAR_PLUG_WIDTH + \
62 #define STATUSBAR_VOLUME_WIDTH 16
63 #define STATUSBAR_ENCODER_X_POS STATUSBAR_X_POS + \
64 STATUSBAR_BATTERY_WIDTH + \
65 STATUSBAR_PLUG_WIDTH + \
67 #define STATUSBAR_ENCODER_WIDTH 18
68 #define STATUSBAR_PLAY_STATE_X_POS STATUSBAR_X_POS + \
69 STATUSBAR_BATTERY_WIDTH + \
70 STATUSBAR_PLUG_WIDTH + \
71 STATUSBAR_VOLUME_WIDTH + \
73 #define STATUSBAR_PLAY_STATE_WIDTH 7
74 #define STATUSBAR_PLAY_MODE_X_POS STATUSBAR_X_POS + \
75 STATUSBAR_BATTERY_WIDTH + \
76 STATUSBAR_PLUG_WIDTH + \
77 STATUSBAR_VOLUME_WIDTH + \
78 STATUSBAR_PLAY_STATE_WIDTH + \
80 #define STATUSBAR_PLAY_MODE_WIDTH 7
81 #define STATUSBAR_RECFREQ_X_POS STATUSBAR_X_POS + \
82 STATUSBAR_BATTERY_WIDTH + \
83 STATUSBAR_PLUG_WIDTH + \
84 STATUSBAR_VOLUME_WIDTH + \
85 STATUSBAR_PLAY_STATE_WIDTH + \
87 #define STATUSBAR_RECFREQ_WIDTH 12
88 #define STATUSBAR_RECCHANNELS_X_POS STATUSBAR_X_POS + \
89 STATUSBAR_BATTERY_WIDTH + \
90 STATUSBAR_PLUG_WIDTH + \
91 STATUSBAR_VOLUME_WIDTH + \
92 STATUSBAR_PLAY_STATE_WIDTH + \
93 STATUSBAR_RECFREQ_WIDTH + \
95 #define STATUSBAR_RECCHANNELS_WIDTH 5
96 #define STATUSBAR_SHUFFLE_X_POS STATUSBAR_X_POS + \
97 STATUSBAR_BATTERY_WIDTH + \
98 STATUSBAR_PLUG_WIDTH + \
99 STATUSBAR_VOLUME_WIDTH + \
100 STATUSBAR_PLAY_STATE_WIDTH + \
101 STATUSBAR_PLAY_MODE_WIDTH + \
103 #define STATUSBAR_SHUFFLE_WIDTH 7
104 #define STATUSBAR_LOCKM_X_POS STATUSBAR_X_POS + \
105 STATUSBAR_BATTERY_WIDTH + \
106 STATUSBAR_PLUG_WIDTH + \
107 STATUSBAR_VOLUME_WIDTH + \
108 STATUSBAR_PLAY_STATE_WIDTH + \
109 STATUSBAR_PLAY_MODE_WIDTH + \
110 STATUSBAR_SHUFFLE_WIDTH + \
112 #define STATUSBAR_LOCKM_WIDTH 5
113 #define STATUSBAR_LOCKR_X_POS STATUSBAR_X_POS + \
114 STATUSBAR_BATTERY_WIDTH + \
115 STATUSBAR_PLUG_WIDTH + \
116 STATUSBAR_VOLUME_WIDTH + \
117 STATUSBAR_PLAY_STATE_WIDTH + \
118 STATUSBAR_PLAY_MODE_WIDTH + \
119 STATUSBAR_SHUFFLE_WIDTH + \
120 STATUSBAR_LOCKM_WIDTH + \
122 #define STATUSBAR_LOCKR_WIDTH 5
124 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
125 #define STATUSBAR_DISK_WIDTH 12
126 #define STATUSBAR_DISK_X_POS(statusbar_width) statusbar_width - \
129 #define STATUSBAR_DISK_WIDTH 0
131 #define STATUSBAR_TIME_X_END(statusbar_width) statusbar_width - 1 - \
133 struct gui_syncstatusbar statusbars
;
136 #ifdef HAVE_LCD_BITMAP
137 static void gui_statusbar_icon_battery(struct screen
* display
, int percent
,
138 int batt_charge_step
);
139 static bool gui_statusbar_icon_volume(struct gui_statusbar
* bar
, int volume
);
140 static void gui_statusbar_icon_play_state(struct screen
* display
, int state
);
141 static void gui_statusbar_icon_play_mode(struct screen
* display
, int mode
);
142 static void gui_statusbar_icon_shuffle(struct screen
* display
);
143 static void gui_statusbar_icon_lock(struct screen
* display
);
144 #ifdef HAS_REMOTE_BUTTON_HOLD
145 static void gui_statusbar_icon_lock_remote(struct screen
* display
);
147 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
148 static void gui_statusbar_led(struct screen
* display
);
150 #ifdef HAVE_RECORDING
151 static void gui_statusbar_icon_recording_info(struct screen
* display
);
154 static void gui_statusbar_time(struct screen
* display
, struct tm
*time
);
162 * Initializes a status bar
163 * - bar : the bar to initialize
165 static void gui_statusbar_init(struct gui_statusbar
* bar
)
167 bar
->redraw_volume
= true;
168 bar
->volume_icon_switch_tick
= bar
->battery_icon_switch_tick
= current_tick
;
169 memset((void*)&(bar
->lastinfo
), 0, sizeof(struct status_info
));
171 bar
->last_tm_min
= 0;
175 void gui_statusbar_draw(struct gui_statusbar
* bar
, bool force_redraw
)
177 struct screen
* display
= bar
->display
;
179 #ifdef HAVE_LCD_CHARCELLS
181 (void)force_redraw
; /* players always "redraw" */
182 #endif /* HAVE_LCD_CHARCELLS */
184 bar
->info
.battlevel
= battery_level();
185 #ifdef HAVE_USB_POWER
186 bar
->info
.usb_inserted
= usb_inserted();
189 bar
->info
.inserted
= (charger_input_state
== CHARGER
);
190 if (bar
->info
.inserted
)
192 bar
->info
.battery_state
= true;
194 #if CONFIG_CHARGING >= CHARGING_MONITOR
196 /* zero battery run time if charging */
197 if (charge_state
> DISCHARGING
)
198 lasttime
= current_tick
;
200 /* animate battery if charging */
201 if ((charge_state
== DISCHARGING
) || (charge_state
== TRICKLE
))
203 bar
->info
.batt_charge_step
= -1;
207 #else /* CONFIG_CHARGING < CHARGING_MONITOR */
208 lasttime
= current_tick
;
210 #endif /* CONFIG_CHARGING < CHARGING_MONITOR */
211 /* animate in (max.) 4 steps, starting near the current charge level */
212 if (TIME_AFTER(current_tick
, bar
->battery_icon_switch_tick
))
214 if (++bar
->info
.batt_charge_step
> 3)
215 bar
->info
.batt_charge_step
= bar
->info
.battlevel
/ 34;
216 bar
->battery_icon_switch_tick
= current_tick
+ HZ
;
221 #endif /* CONFIG_CHARGING */
223 bar
->info
.batt_charge_step
= -1;
224 if (battery_level_safe())
225 bar
->info
.battery_state
= true;
227 /* blink battery if level is low */
228 if (TIME_AFTER(current_tick
, bar
->battery_icon_switch_tick
) &&
229 (bar
->info
.battlevel
> -1))
231 bar
->info
.battery_state
= !bar
->info
.battery_state
;
232 bar
->battery_icon_switch_tick
= current_tick
+ HZ
;
236 bar
->info
.volume
= global_settings
.volume
;
237 #ifdef HAVE_LCD_BITMAP
238 bar
->info
.shuffle
= global_settings
.playlist_shuffle
;
239 #ifdef HAS_BUTTON_HOLD
240 bar
->info
.keylock
= button_hold();
242 bar
->info
.keylock
= is_keys_locked();
243 #endif /* HAS_BUTTON_HOLD */
244 #ifdef HAS_REMOTE_BUTTON_HOLD
245 bar
->info
.keylockremote
= remote_button_hold();
247 bar
->info
.repeat
= global_settings
.repeat_mode
;
248 bar
->info
.playmode
= current_playmode();
250 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
251 if(!display
->has_disk_led
)
252 bar
->info
.led
= led_read(HZ
/2); /* delay should match polling interval */
255 bar
->time
= get_time();
256 #endif /* CONFIG_RTC */
258 /* only redraw if forced to, or info has changed */
259 if (force_redraw
|| bar
->redraw_volume
||
261 (bar
->time
->tm_min
!= bar
->last_tm_min
) ||
263 memcmp(&(bar
->info
), &(bar
->lastinfo
), sizeof(struct status_info
)))
266 viewport_set_defaults(&vp
, display
->screen_type
);
267 vp
.height
= STATUSBAR_HEIGHT
;
268 vp
.x
= STATUSBAR_X_POS
;
269 vp
.y
= STATUSBAR_Y_POS
;
270 display
->set_viewport(&vp
);
271 display
->set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
272 display
->fillrect(0, 0, display
->getwidth(), STATUSBAR_HEIGHT
);
273 display
->set_drawmode(DRMODE_SOLID
);
275 if (bar
->info
.battery_state
)
276 gui_statusbar_icon_battery(display
, bar
->info
.battlevel
,
277 bar
->info
.batt_charge_step
);
278 #ifdef HAVE_USB_POWER
279 if (bar
->info
.usb_inserted
)
280 display
->mono_bitmap(bitmap_icons_7x8
[Icon_USBPlug
],
281 STATUSBAR_PLUG_X_POS
,
282 STATUSBAR_Y_POS
, STATUSBAR_PLUG_WIDTH
,
284 #endif /* HAVE_USB_POWER */
286 #ifdef HAVE_USB_POWER
289 /* draw power plug if charging */
290 if (bar
->info
.inserted
)
291 display
->mono_bitmap(bitmap_icons_7x8
[Icon_Plug
],
292 STATUSBAR_PLUG_X_POS
,
293 STATUSBAR_Y_POS
, STATUSBAR_PLUG_WIDTH
,
295 #endif /* CONFIG_CHARGING */
296 #ifdef HAVE_RECORDING
297 /* turn off volume display in recording screen */
298 bool recscreen_on
= in_recording_screen();
301 bar
->redraw_volume
= gui_statusbar_icon_volume(bar
, bar
->info
.volume
);
302 gui_statusbar_icon_play_state(display
, current_playmode() + Icon_Play
);
304 #ifdef HAVE_RECORDING
305 /* If in recording screen, replace repeat mode, volume
306 and shuffle icons with recording info */
308 gui_statusbar_icon_recording_info(display
);
312 switch (bar
->info
.repeat
) {
313 #ifdef AB_REPEAT_ENABLE
315 gui_statusbar_icon_play_mode(display
, Icon_RepeatAB
);
317 #endif /* AB_REPEAT_ENABLE == 1 */
320 gui_statusbar_icon_play_mode(display
, Icon_RepeatOne
);
325 gui_statusbar_icon_play_mode(display
, Icon_Repeat
);
328 if (bar
->info
.shuffle
)
329 gui_statusbar_icon_shuffle(display
);
331 if (bar
->info
.keylock
)
332 gui_statusbar_icon_lock(display
);
333 #ifdef HAS_REMOTE_BUTTON_HOLD
334 if (bar
->info
.keylockremote
)
335 gui_statusbar_icon_lock_remote(display
);
338 gui_statusbar_time(display
, bar
->time
);
339 bar
->last_tm_min
= bar
->time
->tm_min
;
340 #endif /* CONFIG_RTC */
341 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
342 if(!display
->has_disk_led
&& bar
->info
.led
)
343 gui_statusbar_led(display
);
345 display
->update_viewport();
346 display
->set_viewport(NULL
);
347 bar
->lastinfo
= bar
->info
;
349 #endif /* HAVE_LCD_BITMAP */
352 #ifdef HAVE_LCD_CHARCELLS
353 display
->icon(ICON_BATTERY
, bar
->info
.battery_state
);
355 if (bar
->info
.batt_charge_step
> -1)
356 val
= bar
->info
.batt_charge_step
;
358 val
= (bar
->info
.battlevel
* 3 + 50) / 100;
359 display
->icon(ICON_BATTERY_1
, val
>= 1);
360 display
->icon(ICON_BATTERY_2
, val
>= 2);
361 display
->icon(ICON_BATTERY_3
, val
>= 3);
363 val
= 10 * (bar
->info
.volume
- sound_min(SOUND_VOLUME
))
364 / (sound_max(SOUND_VOLUME
) - sound_min(SOUND_VOLUME
));
365 display
->icon(ICON_VOLUME
, true);
366 display
->icon(ICON_VOLUME_1
, val
>= 1);
367 display
->icon(ICON_VOLUME_2
, val
>= 3);
368 display
->icon(ICON_VOLUME_3
, val
>= 5);
369 display
->icon(ICON_VOLUME_4
, val
>= 7);
370 display
->icon(ICON_VOLUME_5
, val
>= 9);
372 display
->icon(ICON_PLAY
, current_playmode() == STATUS_PLAY
);
373 display
->icon(ICON_PAUSE
, current_playmode() == STATUS_PAUSE
);
375 display
->icon(ICON_REPEAT
, global_settings
.repeat_mode
!= REPEAT_OFF
);
376 display
->icon(ICON_1
, global_settings
.repeat_mode
== REPEAT_ONE
);
378 display
->icon(ICON_RECORD
, record
);
379 display
->icon(ICON_AUDIO
, audio
);
380 display
->icon(ICON_PARAM
, param
);
381 display
->icon(ICON_USB
, usb
);
382 #endif /* HAVE_LCD_CHARCELLS */
385 #ifdef HAVE_LCD_BITMAP
388 * Print battery icon to status bar
390 static void gui_statusbar_icon_battery(struct screen
* display
, int percent
,
391 int batt_charge_step
)
395 unsigned int width
, height
;
397 unsigned int prevfg
= 0;
401 if (batt_charge_step
>= 0)
403 fill
= percent
* (STATUSBAR_BATTERY_WIDTH
-3) / 100;
404 endfill
= 34 * batt_charge_step
* (STATUSBAR_BATTERY_WIDTH
-3) / 100;
408 (void)batt_charge_step
;
411 fill
= endfill
= (percent
* (STATUSBAR_BATTERY_WIDTH
-3) + 50) / 100;
414 #if CONFIG_CHARGING == CHARGING_MONITOR && !defined(SIMULATOR)
415 /* Certain charge controlled targets */
416 /* show graphical animation when charging instead of numbers */
417 if ((global_settings
.battery_display
) &&
418 (charge_state
!= CHARGING
) &&
420 #else /* all others */
421 if (global_settings
.battery_display
&& (percent
> -1)) {
423 /* Numeric display */
424 display
->setfont(FONT_SYSFIXED
);
425 snprintf(buffer
, sizeof(buffer
), "%3d", percent
);
426 display
->getstringsize(buffer
, &width
, &height
);
427 if (height
<= STATUSBAR_HEIGHT
)
428 display
->putsxy(STATUSBAR_BATTERY_X_POS
429 + STATUSBAR_BATTERY_WIDTH
/ 2
430 - width
/2, STATUSBAR_Y_POS
, buffer
);
431 display
->setfont(FONT_UI
);
436 display
->drawrect(STATUSBAR_BATTERY_X_POS
, STATUSBAR_Y_POS
, 17, 7);
437 display
->vline(STATUSBAR_BATTERY_X_POS
+ 17, STATUSBAR_Y_POS
+ 2,
438 STATUSBAR_Y_POS
+ 4);
440 display
->fillrect(STATUSBAR_BATTERY_X_POS
+ 1, STATUSBAR_Y_POS
+ 1,
443 if (display
->depth
> 1)
445 prevfg
= display
->get_foreground();
446 display
->set_foreground(LCD_DARKGRAY
);
449 display
->fillrect(STATUSBAR_BATTERY_X_POS
+ 1 + fill
,
450 STATUSBAR_Y_POS
+ 1, endfill
- fill
, 5);
452 if (display
->depth
> 1)
453 display
->set_foreground(prevfg
);
458 display
->setfont(FONT_SYSFIXED
);
459 display
->putsxy(STATUSBAR_BATTERY_X_POS
+ STATUSBAR_BATTERY_WIDTH
/ 2
460 - 4, STATUSBAR_Y_POS
, "?");
461 display
->setfont(FONT_UI
);
466 * Print volume gauge to status bar
468 static bool gui_statusbar_icon_volume(struct gui_statusbar
* bar
, int volume
)
473 unsigned int width
, height
;
474 bool needs_redraw
= false;
475 int type
= global_settings
.volume_type
;
476 struct screen
* display
=bar
->display
;
477 const int minvol
= sound_min(SOUND_VOLUME
);
478 const int maxvol
= sound_max(SOUND_VOLUME
);
485 if (volume
== minvol
) {
486 display
->mono_bitmap(bitmap_icons_7x8
[Icon_Mute
],
487 STATUSBAR_VOLUME_X_POS
+ STATUSBAR_VOLUME_WIDTH
/ 2 - 4,
488 STATUSBAR_Y_POS
, 7, STATUSBAR_HEIGHT
);
491 /* We want to redraw the icon later on */
492 if (bar
->last_volume
!= volume
&& bar
->last_volume
>= minvol
) {
493 bar
->volume_icon_switch_tick
= current_tick
+ HZ
;
496 /* If the timeout hasn't yet been reached, we show it numerically
497 and tell the caller that we want to be called again */
498 if (TIME_BEFORE(current_tick
,bar
->volume_icon_switch_tick
)) {
503 /* display volume level numerical? */
506 display
->setfont(FONT_SYSFIXED
);
507 snprintf(buffer
, sizeof(buffer
), "%2d", volume
);
508 display
->getstringsize(buffer
, &width
, &height
);
509 if (height
<= STATUSBAR_HEIGHT
)
511 display
->putsxy(STATUSBAR_VOLUME_X_POS
512 + STATUSBAR_VOLUME_WIDTH
/ 2
513 - width
/2, STATUSBAR_Y_POS
, buffer
);
515 display
->setfont(FONT_UI
);
517 /* display volume bar */
518 vol
= (volume
- minvol
) * 14 / (maxvol
- minvol
);
519 for(i
=0; i
< vol
; i
++) {
520 display
->vline(STATUSBAR_VOLUME_X_POS
+ i
,
521 STATUSBAR_Y_POS
+ 6 - i
/ 2,
522 STATUSBAR_Y_POS
+ 6);
526 bar
->last_volume
= volume
;
532 * Print play state to status bar
534 static void gui_statusbar_icon_play_state(struct screen
* display
, int state
)
536 display
->mono_bitmap(bitmap_icons_7x8
[state
], STATUSBAR_PLAY_STATE_X_POS
,
537 STATUSBAR_Y_POS
, STATUSBAR_PLAY_STATE_WIDTH
,
542 * Print play mode to status bar
544 static void gui_statusbar_icon_play_mode(struct screen
* display
, int mode
)
546 display
->mono_bitmap(bitmap_icons_7x8
[mode
], STATUSBAR_PLAY_MODE_X_POS
,
547 STATUSBAR_Y_POS
, STATUSBAR_PLAY_MODE_WIDTH
,
552 * Print shuffle mode to status bar
554 static void gui_statusbar_icon_shuffle(struct screen
* display
)
556 display
->mono_bitmap(bitmap_icons_7x8
[Icon_Shuffle
],
557 STATUSBAR_SHUFFLE_X_POS
, STATUSBAR_Y_POS
,
558 STATUSBAR_SHUFFLE_WIDTH
, STATUSBAR_HEIGHT
);
562 * Print lock when keys are locked
564 static void gui_statusbar_icon_lock(struct screen
* display
)
566 display
->mono_bitmap(bitmap_icons_5x8
[Icon_Lock_Main
],
567 STATUSBAR_LOCKM_X_POS
, STATUSBAR_Y_POS
,
568 STATUSBAR_LOCKM_WIDTH
, STATUSBAR_HEIGHT
);
571 #ifdef HAS_REMOTE_BUTTON_HOLD
573 * Print remote lock when remote hold is enabled
575 static void gui_statusbar_icon_lock_remote(struct screen
* display
)
577 display
->mono_bitmap(bitmap_icons_5x8
[Icon_Lock_Remote
],
578 STATUSBAR_LOCKR_X_POS
, STATUSBAR_Y_POS
,
579 STATUSBAR_LOCKR_WIDTH
, STATUSBAR_HEIGHT
);
583 #if (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
585 * no real LED: disk activity in status bar
587 static void gui_statusbar_led(struct screen
* display
)
589 display
->mono_bitmap(bitmap_icon_disk
,
590 STATUSBAR_DISK_X_POS(display
->getwidth()),
591 STATUSBAR_Y_POS
, STATUSBAR_DISK_WIDTH
,
598 * Print time to status bar
600 static void gui_statusbar_time(struct screen
* display
, struct tm
*time
)
602 unsigned char buffer
[6];
603 unsigned int width
, height
;
605 if ( valid_time(time
) ) {
606 hour
= time
->tm_hour
;
607 minute
= time
->tm_min
;
608 if ( global_settings
.timeformat
) { /* 12 hour clock */
614 snprintf(buffer
, sizeof(buffer
), "%02d:%02d", hour
, minute
);
617 strncpy(buffer
, "--:--", sizeof buffer
);
619 display
->setfont(FONT_SYSFIXED
);
620 display
->getstringsize(buffer
, &width
, &height
);
621 if (height
<= STATUSBAR_HEIGHT
) {
622 display
->putsxy(STATUSBAR_TIME_X_END(display
->getwidth()) - width
,
623 STATUSBAR_Y_POS
, buffer
);
625 display
->setfont(FONT_UI
);
630 #ifdef HAVE_RECORDING
631 #if CONFIG_CODEC == SWCODEC
633 * Write a number to the display using bitmaps and return new position
635 static int write_bitmap_number(struct screen
* display
, int value
,
639 snprintf(buf
, sizeof(buf
), "%d", value
);
641 for (ptr
= buf
; *ptr
!= '\0'; ptr
++, x
+= BM_GLYPH_WIDTH
)
642 display
->mono_bitmap(bitmap_glyphs_4x8
[*ptr
- '0'], x
, y
,
643 BM_GLYPH_WIDTH
, STATUSBAR_HEIGHT
);
648 * Write format info bitmaps - right justified
650 static void gui_statusbar_write_format_info(struct screen
* display
)
652 /* Can't fit info for sw codec targets in statusbar using FONT_SYSFIXED
654 int rec_format
= global_settings
.rec_format
;
655 unsigned bitrk
= 0; /* compiler warns about unitialized use !! */
656 int xpos
= STATUSBAR_ENCODER_X_POS
;
657 int width
= STATUSBAR_ENCODER_WIDTH
;
658 const unsigned char *bm
= bitmap_formats_18x8
[rec_format
];
660 if (rec_format
== REC_FORMAT_MPA_L3
)
662 /* Special handling for mp3 */
663 bitrk
= global_settings
.mp3_enc_config
.bitrate
;
664 bitrk
= mp3_enc_bitr
[bitrk
];
666 width
= BM_MPA_L3_M_WIDTH
;
668 /* Slide 'M' to right if fewer than three digits used */
670 bitrk
= 999; /* neurotic safety check if corrupted */
674 xpos
+= BM_GLYPH_WIDTH
;
676 xpos
+= BM_GLYPH_WIDTH
;
681 /* Show bitmap - clipping right edge if needed */
682 display
->mono_bitmap_part(bm
, 0, 0, STATUSBAR_ENCODER_WIDTH
,
683 xpos
, STATUSBAR_Y_POS
, width
, STATUSBAR_HEIGHT
);
685 if (rec_format
== REC_FORMAT_MPA_L3
)
687 xpos
+= BM_MPA_L3_M_WIDTH
; /* to right of 'M' */
688 write_bitmap_number(display
, bitrk
, xpos
, STATUSBAR_Y_POS
);
693 * Write sample rate using bitmaps - left justified
695 static void gui_statusbar_write_samplerate_info(struct screen
* display
)
697 unsigned long samprk
;
703 #ifdef HAVE_SPDIF_REC
704 if (global_settings
.rec_source
== AUDIO_SRC_SPDIF
)
705 /* Use rate in use, not current measured rate if it changed */
706 samprk
= pcm_rec_sample_rate();
709 samprk
= rec_freq_sampr
[global_settings
.rec_frequency
];
710 #endif /* SIMULATOR */
714 samprk
= 99; /* Limit to 3 glyphs */
716 xpos
= write_bitmap_number(display
, (unsigned)samprk
,
717 STATUSBAR_RECFREQ_X_POS
, STATUSBAR_Y_POS
);
720 display
->mono_bitmap(bitmap_glyphs_4x8
[Glyph_4x8_k
], xpos
,
721 STATUSBAR_Y_POS
, BM_GLYPH_WIDTH
,
724 #endif /* CONFIG_CODEC == SWCODEC */
726 static void gui_statusbar_icon_recording_info(struct screen
* display
)
728 #if CONFIG_CODEC != SWCODEC
731 display
->setfont(FONT_SYSFIXED
);
732 #endif /* CONFIG_CODEC != SWCODEC */
734 /* Display Codec info in statusbar */
735 #if CONFIG_CODEC == SWCODEC
736 gui_statusbar_write_format_info(display
);
738 display
->mono_bitmap(bitmap_icons_5x8
[Icon_q
],
739 STATUSBAR_ENCODER_X_POS
+ 8, STATUSBAR_Y_POS
,
740 5, STATUSBAR_HEIGHT
);
742 snprintf(buffer
, sizeof(buffer
), "%d", global_settings
.rec_quality
);
743 display
->getstringsize(buffer
, &width
, &height
);
744 if (height
<= STATUSBAR_HEIGHT
)
745 display
->putsxy(STATUSBAR_ENCODER_X_POS
+ 13, STATUSBAR_Y_POS
, buffer
);
746 #endif /* CONFIG_CODEC == SWCODEC */
748 /* Display Samplerate info in statusbar */
749 #if CONFIG_CODEC == SWCODEC
750 /* SWCODEC targets use bitmaps for glyphs */
751 gui_statusbar_write_samplerate_info(display
);
753 /* hwcodec targets have sysfont characters */
754 #ifdef HAVE_SPDIF_REC
755 if (global_settings
.rec_source
== AUDIO_SRC_SPDIF
)
757 /* Can't measure S/PDIF sample rate on Archos/Sim yet */
758 strncpy(buffer
, "--", sizeof(buffer
));
761 #endif /* HAVE_SPDIF_IN */
763 static char const * const freq_strings
[12] =
764 { "44", "48", "32", "22", "24", "16" };
765 strncpy(buffer
, freq_strings
[global_settings
.rec_frequency
],
769 display
->getstringsize(buffer
, &width
, &height
);
771 if (height
<= STATUSBAR_HEIGHT
)
772 display
->putsxy(STATUSBAR_RECFREQ_X_POS
, STATUSBAR_Y_POS
, buffer
);
774 display
->setfont(FONT_UI
);
775 #endif /* CONFIG_CODEC == SWCODEC */
777 /* Display Channel status in status bar */
778 if(global_settings
.rec_channels
)
780 display
->mono_bitmap(bitmap_icons_5x8
[Icon_Mono
],
781 STATUSBAR_RECCHANNELS_X_POS
, STATUSBAR_Y_POS
,
782 STATUSBAR_RECCHANNELS_WIDTH
, STATUSBAR_HEIGHT
);
786 display
->mono_bitmap(bitmap_icons_5x8
[Icon_Stereo
],
787 STATUSBAR_RECCHANNELS_X_POS
, STATUSBAR_Y_POS
,
788 STATUSBAR_RECCHANNELS_WIDTH
, STATUSBAR_HEIGHT
);
791 #endif /* HAVE_RECORDING */
793 #endif /* HAVE_LCD_BITMAP */
795 void gui_syncstatusbar_init(struct gui_syncstatusbar
* bars
)
799 gui_statusbar_init( &(bars
->statusbars
[i
]) );
800 gui_statusbar_set_screen( &(bars
->statusbars
[i
]), &(screens
[i
]) );
804 void gui_syncstatusbar_draw(struct gui_syncstatusbar
* bars
,
807 #ifdef HAVE_LCD_BITMAP
808 if(!global_settings
.statusbar
)
810 #endif /* HAVE_LCD_BITMAP */
813 gui_statusbar_draw( &(bars
->statusbars
[i
]), force_redraw
);
817 void gui_statusbar_changed(bool enabled
)
820 send_event(GUI_EVENT_STATUSBAR_TOGGLE
, NULL
);