1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Björn Stenberg
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
23 #include "backlight.h"
26 #ifdef HAVE_REMOTE_LCD
27 #include "lcd-remote.h"
33 #include "mp3_playback.h"
42 #include "powermgmt.h"
53 #include "statusbar.h"
54 #include "screen_access.h"
55 #include "quickscreen.h"
61 #ifdef HAVE_LCD_BITMAP
62 #include <bitmaps/usblogo.h>
65 #ifdef HAVE_REMOTE_LCD
66 #include <bitmaps/remote_usblogo.h>
72 #if CONFIG_CODEC == SWCODEC
76 #ifdef HAVE_LCD_BITMAP
77 #define SCROLLBAR_WIDTH 6
80 /* only used in set_time screen */
81 #if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
82 static int clamp_value_wrap(int value
, int max
, int min
)
98 bool statusbar
= global_settings
.statusbar
; /* force the statusbar */
99 global_settings
.statusbar
= true;
101 show_main_backdrop();
103 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
104 show_remote_main_backdrop();
108 screens
[i
].backlight_on();
109 screens
[i
].clear_display();
111 if (i
== SCREEN_REMOTE
)
113 screens
[i
].bitmap(remote_usblogo
,
114 (LCD_REMOTE_WIDTH
-BMPWIDTH_remote_usblogo
),
115 (LCD_REMOTE_HEIGHT
-BMPHEIGHT_remote_usblogo
)/2,
116 BMPWIDTH_remote_usblogo
, BMPHEIGHT_remote_usblogo
);
121 #ifdef HAVE_LCD_BITMAP
122 screens
[i
].transparent_bitmap(usblogo
,
123 (LCD_WIDTH
-BMPWIDTH_usblogo
),
124 (LCD_HEIGHT
-BMPHEIGHT_usblogo
)/2,
125 BMPWIDTH_usblogo
, BMPHEIGHT_usblogo
);
127 screens
[i
].double_height(false);
128 screens
[i
].puts_scroll(0, 0, "[USB Mode]");
129 status_set_param(false);
130 status_set_audio(false);
131 status_set_usb(true);
132 #endif /* HAVE_LCD_BITMAP */
139 gui_syncstatusbar_draw(&statusbars
, true);
141 while (button_get(true) & BUTTON_REL
);
143 usb_acknowledge(SYS_USB_CONNECTED_ACK
);
144 while(usb_wait_for_disconnect_w_tmo(&button_queue
, HZ
)) {
146 #ifdef HAVE_MMC /* USB-MMC bridge can report activity */
147 led(mmc_usb_active(HZ
));
148 #endif /* HAVE_MMC */
149 gui_syncstatusbar_draw(&statusbars
, false);
152 #endif /* SIMULATOR */
153 #ifdef HAVE_LCD_CHARCELLS
154 status_set_usb(false);
155 #endif /* HAVE_LCD_CHARCELLS */
157 screens
[i
].backlight_on();
158 global_settings
.statusbar
= statusbar
;
159 #endif /* USB_NONE */
163 int mmc_remove_request(void)
165 struct queue_event ev
;
168 screens
[i
].clear_display();
169 gui_syncsplash(1, str(LANG_REMOVE_MMC
));
170 if (global_settings
.talk_menu
)
171 talk_id(LANG_REMOVE_MMC
, false);
175 queue_wait_w_tmo(&button_queue
, &ev
, HZ
/2);
178 case SYS_HOTSWAP_EXTRACTED
:
179 return SYS_HOTSWAP_EXTRACTED
;
181 case SYS_USB_DISCONNECTED
:
182 return SYS_USB_DISCONNECTED
;
188 /* the charging screen is only used for archos targets */
189 #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) && defined(CPU_SH)
191 #ifdef HAVE_LCD_BITMAP
192 static void charging_display_info(bool animate
)
194 unsigned char charging_logo
[36];
195 const int pox_x
= (LCD_WIDTH
- sizeof(charging_logo
)) / 2;
196 const int pox_y
= 32;
197 static unsigned phase
= 3;
202 #ifdef NEED_ATA_POWER_BATT_MEASURE
203 if (ide_powered()) /* FM and V2 can only measure when ATA power is on */
206 int battv
= battery_voltage();
207 snprintf(buf
, 32, " Batt: %d.%02dV %d%% ", battv
/ 1000,
208 (battv
% 1000) / 10, battery_level());
212 #if CONFIG_CHARGING == CHARGING_CONTROL
214 snprintf(buf
, 32, "Charge mode:");
217 if (charge_state
== CHARGING
)
218 snprintf(buf
, 32, str(LANG_BATTERY_CHARGE
));
219 else if (charge_state
== TOPOFF
)
220 snprintf(buf
, 32, str(LANG_BATTERY_TOPOFF_CHARGE
));
221 else if (charge_state
== TRICKLE
)
222 snprintf(buf
, 32, str(LANG_BATTERY_TRICKLE_CHARGE
));
224 snprintf(buf
, 32, "not charging");
227 if (!charger_enabled
)
229 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
233 memset(charging_logo
+3, 0x00, 32);
234 charging_logo
[0] = 0x3C;
235 charging_logo
[1] = 0x24;
236 charging_logo
[2] = charging_logo
[35] = 0xFF;
239 { /* draw the outline */
241 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 8, sizeof(charging_logo
), 8);
242 lcd_set_drawmode(DRMODE_FG
);
244 charging_logo
[0] = charging_logo
[1] = 0x00;
245 memset(charging_logo
+2, 0x80, 34);
246 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
, sizeof(charging_logo
), 8);
248 memset(charging_logo
+2, 0x01, 34);
249 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 16, sizeof(charging_logo
), 8);
250 lcd_set_drawmode(DRMODE_SOLID
);
253 { /* animate the middle part */
254 for (i
= 3; i
<MIN(sizeof(charging_logo
)-1, phase
); i
++)
256 if ((i
-phase
) % 8 == 0)
257 { /* draw a "bubble" here */
259 bitpos
= (phase
+ i
/8) % 15; /* "bounce" effect */
261 bitpos
= 14 - bitpos
;
262 charging_logo
[i
] = 0x01 << bitpos
;
265 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 8, sizeof(charging_logo
), 8);
270 #else /* not HAVE_LCD_BITMAP */
272 static unsigned long logo_chars
[4];
273 static const unsigned char logo_pattern
[] = {
274 0x07, 0x04, 0x1c, 0x14, 0x1c, 0x04, 0x07, 0, /* char 1 */
275 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 2 */
276 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 3 */
277 0x1f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1f, 0, /* char 4 */
280 static void logo_lock_patterns(bool on
)
286 for (i
= 0; i
< 4; i
++)
287 logo_chars
[i
] = lcd_get_locked_pattern();
291 for (i
= 0; i
< 4; i
++)
292 lcd_unlock_pattern(logo_chars
[i
]);
296 static void charging_display_info(bool animate
)
300 static unsigned phase
= 3;
303 battv
= battery_voltage();
304 snprintf(buf
, sizeof(buf
), " %d.%02dV", battv
/ 1000, (battv
% 1000) / 10);
307 memcpy(buf
, logo_pattern
, 32); /* copy logo patterns */
309 if (!animate
) /* build the screen */
311 lcd_double_height(false);
312 lcd_puts(0, 0, "[Charging]");
313 for (i
= 0; i
< 4; i
++)
314 lcd_putc(i
, 1, logo_chars
[i
]);
316 else /* animate the logo */
318 for (i
= 3; i
< MIN(19, phase
); i
++)
320 if ((i
- phase
) % 5 == 0)
321 { /* draw a "bubble" here */
322 ypos
= (phase
+ i
/5) % 9; /* "bounce" effect */
325 buf
[5 - ypos
+ 8 * (i
/5)] |= 0x10 >> (i
%5);
331 for (i
= 0; i
< 4; i
++)
332 lcd_define_pattern(logo_chars
[i
], buf
+ 8 * i
);
336 #endif /* (not) HAVE_LCD_BITMAP */
338 /* blocks while charging, returns on event:
339 1 if charger cable was removed
340 2 if Off/Stop key was pressed
341 3 if On key was pressed
342 4 if USB was connected */
344 int charging_screen(void)
349 ide_power_enable(false); /* power down the disk, else would be spinning */
352 backlight_set_timeout(global_settings
.backlight_timeout
);
353 #ifdef HAVE_REMOTE_LCD
354 remote_backlight_set_timeout(global_settings
.remote_backlight_timeout
);
356 backlight_set_timeout_plugged(global_settings
.backlight_timeout_plugged
);
357 gui_syncstatusbar_draw(&statusbars
, true);
359 #ifdef HAVE_LCD_CHARCELLS
360 logo_lock_patterns(true);
362 charging_display_info(false);
366 gui_syncstatusbar_draw(&statusbars
, false);
367 charging_display_info(true);
368 button
= get_action(CONTEXT_STD
,HZ
/3);
369 if (button
== ACTION_STD_OK
)
371 else if (usb_detect())
373 else if (!charger_inserted())
377 #ifdef HAVE_LCD_CHARCELLS
378 logo_lock_patterns(false);
382 #endif /* CONFIG_CHARGING && !HAVE_POWEROFF_WHILE_CHARGING && defined(CPU_SH) */
384 #ifdef HAVE_PITCHSCREEN
386 #define PITCH_MAX 2000
387 #define PITCH_MIN 500
388 #define PITCH_SMALL_DELTA 1
389 #define PITCH_BIG_DELTA 10
390 #define PITCH_NUDGE_DELTA 20
392 #define PITCH_MODE_ABSOLUTE 1
393 #define PITCH_MODE_SEMITONE -PITCH_MODE_ABSOLUTE
395 static int pitch_mode
= PITCH_MODE_ABSOLUTE
; /* 1 - absolute, -1 - semitone */
398 0 if no key was pressed
399 1 if USB was connected */
401 static void pitch_screen_draw(struct screen
*display
, int pitch
, int pitch_mode
)
404 unsigned char buf
[32];
407 display
->clear_display();
409 if (display
->nb_lines
< 4) /* very small screen, just show the pitch value */
411 w
= snprintf((char *)buf
, sizeof(buf
), "%s: %d.%d%%",str(LANG_PITCH
),
412 pitch
/ 10, pitch
% 10 );
413 display
->putsxy((display
->width
-(w
*display
->char_width
))/2,
414 display
->nb_lines
/2,buf
);
416 else /* bigger screen, show everything... */
420 if (pitch_mode
== PITCH_MODE_ABSOLUTE
) {
421 ptr
= str(LANG_PITCH_UP
);
423 ptr
= str(LANG_PITCH_UP_SEMITONE
);
425 display
->getstringsize(ptr
,&w
,&h
);
426 display
->putsxy((display
->width
-w
)/2, 0, ptr
);
427 display
->mono_bitmap(bitmap_icons_7x8
[Icon_UpArrow
],
428 display
->width
/2 - 3, h
, 7, 8);
430 /* DOWN: Pitch Down */
431 if (pitch_mode
== PITCH_MODE_ABSOLUTE
) {
432 ptr
= str(LANG_PITCH_DOWN
);
434 ptr
= str(LANG_PITCH_DOWN_SEMITONE
);
436 display
->getstringsize(ptr
,&w
,&h
);
437 display
->putsxy((display
->width
-w
)/2, display
->height
- h
, ptr
);
438 display
->mono_bitmap(bitmap_icons_7x8
[Icon_DownArrow
],
439 display
->width
/2 - 3, display
->height
- h
*2, 7, 8);
443 display
->getstringsize(ptr
,&w
,&h
);
444 display
->putsxy(display
->width
-w
, (display
->height
-h
)/2, ptr
);
445 display
->mono_bitmap(bitmap_icons_7x8
[Icon_FastForward
],
446 display
->width
-w
-8, (display
->height
-h
)/2, 7, 8);
450 display
->getstringsize(ptr
,&w
,&h
);
451 display
->putsxy(0, (display
->height
-h
)/2, ptr
);
452 display
->mono_bitmap(bitmap_icons_7x8
[Icon_FastBackward
],
453 w
+1, (display
->height
-h
)/2, 7, 8);
456 snprintf((char *)buf
, sizeof(buf
), str(LANG_PITCH
));
457 display
->getstringsize(buf
,&w
,&h
);
458 display
->putsxy((display
->width
-w
)/2, (display
->height
/2)-h
, buf
);
460 snprintf((char *)buf
, sizeof(buf
), "%d.%d%%",
461 pitch
/ 10, pitch
% 10 );
462 display
->getstringsize(buf
,&w
,&h
);
463 display
->putsxy((display
->width
-w
)/2, display
->height
/2, buf
);
469 static int pitch_increase(int pitch
, int delta
, bool allow_cutoff
)
474 if (pitch
+ delta
>= PITCH_MIN
) {
475 new_pitch
= pitch
+ delta
;
480 new_pitch
= PITCH_MIN
;
482 } else if (delta
> 0) {
483 if (pitch
+ delta
<= PITCH_MAX
) {
484 new_pitch
= pitch
+ delta
;
489 new_pitch
= PITCH_MAX
;
492 /* delta == 0 -> no real change */
495 sound_set_pitch(new_pitch
);
500 /* Factor for changing the pitch one half tone up.
501 The exact value is 2^(1/12) = 1.05946309436
502 But we use only integer arithmetics, so take
503 rounded factor multiplied by 10^5=100,000. This is
504 enough to get the same promille values as if we
505 had used floating point (checked with a spread
508 #define PITCH_SEMITONE_FACTOR 105946L
510 /* Some helpful constants. K is the scaling factor for SEMITONE.
511 N is for more accurate rounding
514 #define PITCH_K_FCT 100000UL
515 #define PITCH_N_FCT 10
516 #define PITCH_KN_FCT 1000000UL
518 static int pitch_increase_semitone(int pitch
, bool up
)
521 uint32_t round_fct
; /* How much to scale down at the end */
524 tmp
= tmp
* PITCH_SEMITONE_FACTOR
;
525 round_fct
= PITCH_K_FCT
;
527 tmp
= (tmp
* PITCH_KN_FCT
) / PITCH_SEMITONE_FACTOR
;
528 round_fct
= PITCH_N_FCT
;
530 /* Scaling down with rounding */
531 tmp
= (tmp
+ round_fct
/ 2) / round_fct
;
532 return pitch_increase(pitch
, tmp
- pitch
, false);
535 bool pitch_screen(void)
538 int pitch
= sound_get_pitch();
539 int new_pitch
, delta
= 0;
544 #if CONFIG_CODEC == SWCODEC
545 pcmbuf_set_low_latency(true);
551 pitch_screen_draw(&screens
[i
], pitch
, pitch_mode
);
553 button
= get_action(CONTEXT_PITCHSCREEN
,TIMEOUT_BLOCK
);
555 case ACTION_PS_INC_SMALL
:
556 delta
= PITCH_SMALL_DELTA
;
559 case ACTION_PS_INC_BIG
:
560 delta
= PITCH_BIG_DELTA
;
563 case ACTION_PS_DEC_SMALL
:
564 delta
= -PITCH_SMALL_DELTA
;
567 case ACTION_PS_DEC_BIG
:
568 delta
= -PITCH_BIG_DELTA
;
571 case ACTION_PS_NUDGE_RIGHT
:
572 new_pitch
= pitch_increase(pitch
, PITCH_NUDGE_DELTA
, false);
573 nudged
= (new_pitch
!= pitch
);
577 case ACTION_PS_NUDGE_RIGHTOFF
:
579 pitch
= pitch_increase(pitch
, -PITCH_NUDGE_DELTA
, false);
584 case ACTION_PS_NUDGE_LEFT
:
585 new_pitch
= pitch_increase(pitch
, -PITCH_NUDGE_DELTA
, false);
586 nudged
= (new_pitch
!= pitch
);
590 case ACTION_PS_NUDGE_LEFTOFF
:
592 pitch
= pitch_increase(pitch
, PITCH_NUDGE_DELTA
, false);
597 case ACTION_PS_RESET
:
599 sound_set_pitch( pitch
);
602 case ACTION_PS_TOGGLE_MODE
:
603 pitch_mode
= -pitch_mode
;
611 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
618 if (pitch_mode
== PITCH_MODE_ABSOLUTE
) {
619 pitch
= pitch_increase(pitch
, delta
, true);
621 pitch
= pitch_increase_semitone(pitch
, delta
> 0 ? true:false);
628 #if CONFIG_CODEC == SWCODEC
629 pcmbuf_set_low_latency(false);
631 lcd_setfont(FONT_UI
);
634 #endif /* HAVE_PITCHSCREEN */
637 void charging_splash(void)
639 gui_syncsplash(2*HZ
, (unsigned char *)str(LANG_BATTERY_CHARGE
));
640 button_clear_queue();
645 #if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
647 /* little helper function for voice output */
648 static void say_time(int cursorpos
, const struct tm
*tm
)
653 if (!global_settings
.talk_menu
)
671 value
= tm
->tm_year
+ 1900;
678 if (cursorpos
== 4) /* month */
679 talk_id(LANG_MONTH_JANUARY
+ tm
->tm_mon
, false);
681 talk_value(value
, unit
, false);
688 #define SEPARATOR ":"
689 bool set_time_screen(const char* title
, struct tm
*tm
)
693 unsigned int i
, j
, s
;
695 unsigned int julianday
;
696 unsigned int realyear
;
698 unsigned int min
, max
;
699 unsigned int statusbar_height
= 0;
700 unsigned int separator_width
, weekday_width
;
701 unsigned int prev_line_height
;
702 int daysinmonth
[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
703 unsigned char buffer
[20];
705 /* 6 possible cursor possitions, 2 values stored for each: x, y */
706 unsigned int cursor
[6][2];
709 unsigned char *ptr
[6];
711 if(global_settings
.statusbar
)
712 statusbar_height
= STATUSBAR_HEIGHT
;
714 /* speak selection when screen is entered */
715 say_time(cursorpos
, tm
);
718 /* for easy acess in the drawing loop */
719 ptr
[0] = buffer
; /* hours */
720 ptr
[1] = buffer
+ 3; /* minutes */
721 ptr
[2] = buffer
+ 6; /* seconds */
722 ptr
[3] = buffer
+ 9; /* year */
723 ptr
[4] = str(LANG_MONTH_JANUARY
+ tm
->tm_mon
); /* monthname */
724 ptr
[5] = buffer
+ 14; /* day of month */
726 /* calculate the number of days in febuary */
727 realyear
= tm
->tm_year
+ 1900;
728 if((realyear
% 4 == 0 && !(realyear
% 100 == 0)) || realyear
% 400 == 0)
733 /* fix day if month or year changed */
734 if (tm
->tm_mday
> daysinmonth
[tm
->tm_mon
])
735 tm
->tm_mday
= daysinmonth
[tm
->tm_mon
];
737 /* calculate day of week */
738 julianday
= tm
->tm_mday
;
739 for(i
= 0; (int)i
< tm
->tm_mon
; i
++) {
740 julianday
+= daysinmonth
[i
];
743 tm
->tm_wday
= (realyear
+ julianday
+ (realyear
- 1) / 4 -
744 (realyear
- 1) / 100 + (realyear
- 1) / 400 + 7 - 1) % 7;
746 /* put all the numbers we want from the tm struct into
747 an easily printable buffer */
748 snprintf(buffer
, sizeof(buffer
),
749 "%02d " "%02d " "%02d " "%04d " "%02d",
750 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
,
751 tm
->tm_year
+1900, tm
->tm_mday
);
753 /* convert spaces in the buffer to '\0' to make it possible to work
754 directly on the buffer */
755 for(i
=0; i
< sizeof(buffer
); i
++)
763 /* minimum lines needed is 2 + title line */
764 gui_textarea_update_nblines(&screens
[s
]);
765 if (screens
[s
].nb_lines
< 4)
767 screens
[s
].setfont(FONT_SYSFIXED
);
768 gui_textarea_update_nblines(&screens
[s
]);
771 /* recalculate the positions and offsets */
772 if (screens
[s
].nb_lines
>= 3)
773 screens
[s
].getstringsize(title
, NULL
, &prev_line_height
);
775 prev_line_height
= 0;
777 screens
[s
].getstringsize(SEPARATOR
, &separator_width
, NULL
);
780 screens
[s
].getstringsize(str(LANG_WEEKDAY_SUNDAY
+ tm
->tm_wday
), &weekday_width
, NULL
);
781 screens
[s
].getstringsize(" ", &separator_width
, NULL
);
783 for(i
=0, j
=0; i
< 6; i
++)
785 if(i
==3) /* second row */
787 j
= weekday_width
+ separator_width
;;
788 prev_line_height
*= 2;
790 screens
[s
].getstringsize(ptr
[i
], &width
, NULL
);
791 cursor
[i
][INDEX_Y
] = prev_line_height
+ statusbar_height
;
792 cursor
[i
][INDEX_X
] = j
;
793 j
+= width
+ separator_width
;
796 /* draw the screen */
797 screens
[s
].set_drawmode(DRMODE_SOLID
);
798 gui_textarea_clear(&screens
[s
]);
799 /* display the screen title */
800 screens
[s
].puts_scroll(0, 0, title
);
802 /* these are not selectable, so we draw them outside the loop */
803 screens
[s
].putsxy(0, cursor
[3][INDEX_Y
], str(LANG_WEEKDAY_SUNDAY
+ tm
->tm_wday
)); /* name of the week day */
805 /* draw the selected item with drawmode set to
806 DRMODE_SOLID|DRMODE_INVERSEVID, all other selectable
807 items with drawmode DRMODE_SOLID */
810 if (cursorpos
== (int)i
)
811 screens
[s
].set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
813 screens
[s
].putsxy(cursor
[i
][INDEX_X
],
814 cursor
[i
][INDEX_Y
], ptr
[i
]);
816 screens
[s
].set_drawmode(DRMODE_SOLID
);
818 screens
[s
].putsxy(cursor
[i
/4 +1][INDEX_X
] - separator_width
,
819 cursor
[0][INDEX_Y
], SEPARATOR
);
822 /* print help text */
823 if (screens
[s
].nb_lines
> 4)
824 screens
[s
].puts(0, 4, str(LANG_TIME_SET_BUTTON
));
825 if (screens
[s
].nb_lines
> 5)
826 screens
[s
].puts(0, 5, str(LANG_TIME_REVERT
));
829 gui_syncstatusbar_draw(&statusbars
, true);
831 /* set the most common numbers */
834 /* calculate the minimum and maximum for the number under cursor */
838 valptr
= &tm
->tm_hour
;
841 valptr
= &tm
->tm_min
;
844 valptr
= &tm
->tm_sec
;
849 valptr
= &tm
->tm_year
;
853 valptr
= &tm
->tm_mon
;
857 max
= daysinmonth
[tm
->tm_mon
];
858 valptr
= &tm
->tm_mday
;
862 button
= get_action(CONTEXT_SETTINGS_TIME
, TIMEOUT_BLOCK
);
864 case ACTION_STD_PREV
:
865 cursorpos
= clamp_value_wrap(--cursorpos
, 5, 0);
866 say_time(cursorpos
, tm
);
868 case ACTION_STD_NEXT
:
869 cursorpos
= clamp_value_wrap(++cursorpos
, 5, 0);
870 say_time(cursorpos
, tm
);
872 case ACTION_SETTINGS_INC
:
873 case ACTION_SETTINGS_INCREPEAT
:
874 *valptr
= clamp_value_wrap(++(*valptr
), max
, min
);
875 say_time(cursorpos
, tm
);
877 case ACTION_SETTINGS_DEC
:
878 case ACTION_SETTINGS_DECREPEAT
:
879 *valptr
= clamp_value_wrap(--(*valptr
), max
, min
);
880 say_time(cursorpos
, tm
);
887 case ACTION_STD_CANCEL
:
893 if (default_event_handler(button
) == SYS_USB_CONNECTED
)
900 screens
[i
].setfont(FONT_UI
);
901 gui_textarea_update_nblines(&screens
[i
]);
905 #endif /* defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) */
907 #if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
908 bool shutdown_screen(void)
912 long time_entered
= current_tick
;
916 gui_syncsplash(0, str(LANG_CONFIRM_SHUTDOWN
));
918 while(!done
&& TIME_BEFORE(current_tick
,time_entered
+HZ
*2))
920 button
= get_action(CONTEXT_STD
,HZ
);
923 case ACTION_STD_CANCEL
:
927 /* do nothing here, because ACTION_NONE might be caused
928 * by timeout or button release. In case of timeout the loop
929 * is terminated by TIME_BEFORE */
934 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
944 static const int id3_headers
[]=
949 LANG_ID3_ALBUMARTIST
,
960 #if CONFIG_CODEC == SWCODEC
967 static char * id3_get_info(int selected_item
, void* data
,
968 char *buffer
, size_t buffer_len
)
970 struct mp3entry
* id3
=(struct mp3entry
*)data
;
971 int info_no
=selected_item
/2;
972 if(!(selected_item
%2))
974 return( str(id3_headers
[info_no
]));
982 case 0:/*LANG_ID3_TITLE*/
985 case 1:/*LANG_ID3_ARTIST*/
988 case 2:/*LANG_ID3_ALBUM*/
991 case 3:/*LANG_ID3_ALBUMARTIST*/
992 info
=id3
->albumartist
;
994 case 4:/*LANG_ID3_GROUPING*/
997 case 5:/*LANG_ID3_DISCNUM*/
998 if (id3
->disc_string
)
999 info
= id3
->disc_string
;
1000 else if (id3
->discnum
)
1002 snprintf(buffer
, buffer_len
, "%d", id3
->discnum
);
1006 case 6:/*LANG_ID3_TRACKNUM*/
1007 if (id3
->track_string
)
1008 info
= id3
->track_string
;
1009 else if (id3
->tracknum
)
1011 snprintf(buffer
, buffer_len
, "%d", id3
->tracknum
);
1015 case 7:/*LANG_ID3_COMMENT*/
1018 case 8:/*LANG_ID3_GENRE*/
1019 info
= id3
->genre_string
;
1021 case 9:/*LANG_ID3_YEAR*/
1022 if (id3
->year_string
)
1023 info
= id3
->year_string
;
1026 snprintf(buffer
, buffer_len
, "%d", id3
->year
);
1030 case 10:/*LANG_ID3_LENGTH*/
1031 format_time(buffer
, buffer_len
, id3
->length
);
1034 case 11:/*LANG_ID3_PLAYLIST*/
1035 snprintf(buffer
, buffer_len
, "%d/%d", playlist_get_display_index(),
1039 case 12:/*LANG_ID3_BITRATE*/
1040 snprintf(buffer
, buffer_len
, "%d kbps%s", id3
->bitrate
,
1041 id3
->vbr
? str(LANG_ID3_VBR
) : (const unsigned char*) "");
1044 case 13:/*LANG_ID3_FREQUENCY*/
1045 snprintf(buffer
, buffer_len
, "%ld Hz", id3
->frequency
);
1048 #if CONFIG_CODEC == SWCODEC
1049 case 14:/*LANG_ID3_TRACK_GAIN*/
1050 info
=id3
->track_gain_string
;
1052 case 15:/*LANG_ID3_ALBUM_GAIN*/
1053 info
=id3
->album_gain_string
;
1055 case 16:/*LANG_ID3_PATH*/
1057 case 14:/*LANG_ID3_PATH*/
1062 return info
&& *info
? info
: (char*) str(LANG_ID3_NO_INFO
);
1066 bool browse_id3(void)
1068 struct gui_synclist id3_lists
;
1069 struct mp3entry
* id3
= audio_current_track();
1072 gui_synclist_init(&id3_lists
, &id3_get_info
, id3
, true, 2, NULL
);
1073 gui_synclist_set_nb_items(&id3_lists
,
1074 sizeof(id3_headers
)/sizeof(id3_headers
[0])*2);
1075 gui_synclist_draw(&id3_lists
);
1076 gui_syncstatusbar_draw(&statusbars
, true);
1078 gui_syncstatusbar_draw(&statusbars
, false);
1079 key
= get_action(CONTEXT_LIST
,HZ
/2);
1080 if(key
!=ACTION_NONE
&& key
!=ACTION_UNKNOWN
1081 && !gui_synclist_do_button(&id3_lists
, &key
,LIST_WRAP_UNLESS_HELD
))
1083 return(default_event_handler(key
) == SYS_USB_CONNECTED
);
1088 static char* runtime_get_data(int selected_item
, void* data
,
1089 char* buffer
, size_t buffer_len
)
1092 unsigned char *headers
[] = {str(LANG_RUNNING_TIME
), str(LANG_TOP_TIME
) };
1094 if(!(selected_item
%2))
1095 return headers
[selected_item
/2];
1098 t
= global_status
.topruntime
;
1100 else t
= global_status
.runtime
;
1102 snprintf(buffer
, buffer_len
, "%dh %dm %ds",
1103 t
/ 3600, (t
% 3600) / 60, t
% 60);
1107 static int runtime_speak_data(int selected_item
, void* data
)
1110 long title_ids
[] = {LANG_RUNNING_TIME
, LANG_TOP_TIME
};
1112 title_ids
[selected_item
/2],
1113 TALK_ID((selected_item
== 0) ? global_status
.runtime
1114 : global_status
.topruntime
, UNIT_TIME
));
1119 bool view_runtime(void)
1121 static const char *lines
[]={ID2P(LANG_CLEAR_TIME
)};
1122 static const struct text_message message
={lines
, 1};
1124 struct gui_synclist lists
;
1126 gui_synclist_init(&lists
, runtime_get_data
, NULL
, false, 2, NULL
);
1127 #if !defined(HAVE_LCD_CHARCELLS)
1128 gui_synclist_set_title(&lists
, str(LANG_RUNNING_TIME
), NOICON
);
1130 gui_synclist_set_title(&lists
, NULL
, NOICON
);
1132 if(global_settings
.talk_menu
)
1133 gui_synclist_set_voice_callback(&lists
, runtime_speak_data
);
1134 gui_synclist_set_icon_callback(&lists
, NULL
);
1135 gui_synclist_set_nb_items(&lists
, 4);
1136 gui_synclist_speak_item(&lists
);
1140 if (charger_inserted()
1141 #ifdef HAVE_USB_POWER
1146 global_status
.runtime
= 0;
1151 global_status
.runtime
+= ((current_tick
- lasttime
) / HZ
);
1153 lasttime
= current_tick
;
1154 gui_synclist_draw(&lists
);
1155 gui_syncstatusbar_draw(&statusbars
, true);
1156 list_do_action(CONTEXT_STD
, HZ
,
1157 &lists
, &action
, LIST_WRAP_UNLESS_HELD
);
1158 if(action
== ACTION_STD_CANCEL
)
1160 if(action
== ACTION_STD_OK
) {
1161 if(gui_syncyesno_run(&message
, NULL
, NULL
)==YESNO_YES
)
1163 if (!(gui_synclist_get_sel_pos(&lists
)/2))
1164 global_status
.runtime
= 0;
1166 global_status
.topruntime
= 0;
1167 gui_synclist_speak_item(&lists
);
1170 if(default_event_handler(action
) == SYS_USB_CONNECTED
)