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"
60 #ifdef HAVE_LCD_BITMAP
61 #include <bitmaps/usblogo.h>
64 #ifdef HAVE_REMOTE_LCD
65 #include <bitmaps/remote_usblogo.h>
71 #if CONFIG_CODEC == SWCODEC
75 #if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1))
79 #ifdef HAVE_LCD_BITMAP
80 #define SCROLLBAR_WIDTH 6
83 /* only used in set_time screen */
84 #if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
85 static int clamp_value_wrap(int value
, int max
, int min
)
101 bool statusbar
= global_settings
.statusbar
; /* force the statusbar */
102 global_settings
.statusbar
= true;
104 show_main_backdrop();
106 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
107 show_remote_main_backdrop();
111 screens
[i
].backlight_on();
112 screens
[i
].clear_display();
114 if (i
== SCREEN_REMOTE
)
116 screens
[i
].bitmap(remote_usblogo
,
117 (LCD_REMOTE_WIDTH
-BMPWIDTH_remote_usblogo
),
118 (LCD_REMOTE_HEIGHT
-BMPHEIGHT_remote_usblogo
)/2,
119 BMPWIDTH_remote_usblogo
, BMPHEIGHT_remote_usblogo
);
124 #ifdef HAVE_LCD_BITMAP
125 screens
[i
].transparent_bitmap(usblogo
,
126 (LCD_WIDTH
-BMPWIDTH_usblogo
),
127 (LCD_HEIGHT
-BMPHEIGHT_usblogo
)/2,
128 BMPWIDTH_usblogo
, BMPHEIGHT_usblogo
);
130 screens
[i
].double_height(false);
131 screens
[i
].puts_scroll(0, 0, "[USB Mode]");
132 status_set_param(false);
133 status_set_audio(false);
134 status_set_usb(true);
135 #endif /* HAVE_LCD_BITMAP */
142 gui_syncstatusbar_draw(&statusbars
, true);
144 while (button_get(true) & BUTTON_REL
);
146 usb_acknowledge(SYS_USB_CONNECTED_ACK
);
147 while(usb_wait_for_disconnect_w_tmo(&button_queue
, HZ
)) {
149 #ifdef HAVE_MMC /* USB-MMC bridge can report activity */
150 led(mmc_usb_active(HZ
));
151 #endif /* HAVE_MMC */
152 gui_syncstatusbar_draw(&statusbars
, false);
155 #endif /* SIMULATOR */
156 #ifdef HAVE_LCD_CHARCELLS
157 status_set_usb(false);
158 #endif /* HAVE_LCD_CHARCELLS */
160 screens
[i
].backlight_on();
161 global_settings
.statusbar
= statusbar
;
162 #endif /* USB_NONE */
166 int mmc_remove_request(void)
168 struct queue_event ev
;
171 screens
[i
].clear_display();
172 gui_syncsplash(1, str(LANG_REMOVE_MMC
));
173 if (global_settings
.talk_menu
)
174 talk_id(LANG_REMOVE_MMC
, false);
178 queue_wait_w_tmo(&button_queue
, &ev
, HZ
/2);
181 case SYS_HOTSWAP_EXTRACTED
:
182 return SYS_HOTSWAP_EXTRACTED
;
184 case SYS_USB_DISCONNECTED
:
185 return SYS_USB_DISCONNECTED
;
191 /* the charging screen is only used for archos targets */
192 #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) && defined(CPU_SH)
194 #ifdef HAVE_LCD_BITMAP
195 static void charging_display_info(bool animate
)
197 unsigned char charging_logo
[36];
198 const int pox_x
= (LCD_WIDTH
- sizeof(charging_logo
)) / 2;
199 const int pox_y
= 32;
200 static unsigned phase
= 3;
205 #ifdef NEED_ATA_POWER_BATT_MEASURE
206 if (ide_powered()) /* FM and V2 can only measure when ATA power is on */
209 int battv
= battery_voltage();
210 snprintf(buf
, 32, " Batt: %d.%02dV %d%% ", battv
/ 1000,
211 (battv
% 1000) / 10, battery_level());
215 #if CONFIG_CHARGING == CHARGING_CONTROL
217 snprintf(buf
, 32, "Charge mode:");
220 if (charge_state
== CHARGING
)
221 snprintf(buf
, 32, str(LANG_BATTERY_CHARGE
));
222 else if (charge_state
== TOPOFF
)
223 snprintf(buf
, 32, str(LANG_BATTERY_TOPOFF_CHARGE
));
224 else if (charge_state
== TRICKLE
)
225 snprintf(buf
, 32, str(LANG_BATTERY_TRICKLE_CHARGE
));
227 snprintf(buf
, 32, "not charging");
230 if (!charger_enabled
)
232 #endif /* CONFIG_CHARGING == CHARGING_CONTROL */
236 memset(charging_logo
+3, 0x00, 32);
237 charging_logo
[0] = 0x3C;
238 charging_logo
[1] = 0x24;
239 charging_logo
[2] = charging_logo
[35] = 0xFF;
242 { /* draw the outline */
244 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 8, sizeof(charging_logo
), 8);
245 lcd_set_drawmode(DRMODE_FG
);
247 charging_logo
[0] = charging_logo
[1] = 0x00;
248 memset(charging_logo
+2, 0x80, 34);
249 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
, sizeof(charging_logo
), 8);
251 memset(charging_logo
+2, 0x01, 34);
252 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 16, sizeof(charging_logo
), 8);
253 lcd_set_drawmode(DRMODE_SOLID
);
256 { /* animate the middle part */
257 for (i
= 3; i
<MIN(sizeof(charging_logo
)-1, phase
); i
++)
259 if ((i
-phase
) % 8 == 0)
260 { /* draw a "bubble" here */
262 bitpos
= (phase
+ i
/8) % 15; /* "bounce" effect */
264 bitpos
= 14 - bitpos
;
265 charging_logo
[i
] = 0x01 << bitpos
;
268 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 8, sizeof(charging_logo
), 8);
273 #else /* not HAVE_LCD_BITMAP */
275 static unsigned long logo_chars
[4];
276 static const unsigned char logo_pattern
[] = {
277 0x07, 0x04, 0x1c, 0x14, 0x1c, 0x04, 0x07, 0, /* char 1 */
278 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 2 */
279 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 3 */
280 0x1f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1f, 0, /* char 4 */
283 static void logo_lock_patterns(bool on
)
289 for (i
= 0; i
< 4; i
++)
290 logo_chars
[i
] = lcd_get_locked_pattern();
294 for (i
= 0; i
< 4; i
++)
295 lcd_unlock_pattern(logo_chars
[i
]);
299 static void charging_display_info(bool animate
)
303 static unsigned phase
= 3;
306 battv
= battery_voltage();
307 snprintf(buf
, sizeof(buf
), " %d.%02dV", battv
/ 1000, (battv
% 1000) / 10);
310 memcpy(buf
, logo_pattern
, 32); /* copy logo patterns */
312 if (!animate
) /* build the screen */
314 lcd_double_height(false);
315 lcd_puts(0, 0, "[Charging]");
316 for (i
= 0; i
< 4; i
++)
317 lcd_putc(i
, 1, logo_chars
[i
]);
319 else /* animate the logo */
321 for (i
= 3; i
< MIN(19, phase
); i
++)
323 if ((i
- phase
) % 5 == 0)
324 { /* draw a "bubble" here */
325 ypos
= (phase
+ i
/5) % 9; /* "bounce" effect */
328 buf
[5 - ypos
+ 8 * (i
/5)] |= 0x10 >> (i
%5);
334 for (i
= 0; i
< 4; i
++)
335 lcd_define_pattern(logo_chars
[i
], buf
+ 8 * i
);
339 #endif /* (not) HAVE_LCD_BITMAP */
341 /* blocks while charging, returns on event:
342 1 if charger cable was removed
343 2 if Off/Stop key was pressed
344 3 if On key was pressed
345 4 if USB was connected */
347 int charging_screen(void)
352 ide_power_enable(false); /* power down the disk, else would be spinning */
355 backlight_set_timeout(global_settings
.backlight_timeout
);
356 #ifdef HAVE_REMOTE_LCD
357 remote_backlight_set_timeout(global_settings
.remote_backlight_timeout
);
359 backlight_set_timeout_plugged(global_settings
.backlight_timeout_plugged
);
360 gui_syncstatusbar_draw(&statusbars
, true);
362 #ifdef HAVE_LCD_CHARCELLS
363 logo_lock_patterns(true);
365 charging_display_info(false);
369 gui_syncstatusbar_draw(&statusbars
, false);
370 charging_display_info(true);
371 button
= get_action(CONTEXT_STD
,HZ
/3);
372 if (button
== ACTION_STD_OK
)
374 else if (usb_detect())
376 else if (!charger_inserted())
380 #ifdef HAVE_LCD_CHARCELLS
381 logo_lock_patterns(false);
385 #endif /* CONFIG_CHARGING && !HAVE_POWEROFF_WHILE_CHARGING && defined(CPU_SH) */
387 #ifdef HAVE_PITCHSCREEN
389 #define PITCH_MAX 2000
390 #define PITCH_MIN 500
391 #define PITCH_SMALL_DELTA 1
392 #define PITCH_BIG_DELTA 10
393 #define PITCH_NUDGE_DELTA 20
395 #define PITCH_MODE_ABSOLUTE 1
396 #define PITCH_MODE_SEMITONE -PITCH_MODE_ABSOLUTE
398 static int pitch_mode
= PITCH_MODE_ABSOLUTE
; /* 1 - absolute, -1 - semitone */
401 0 if no key was pressed
402 1 if USB was connected */
404 static void pitch_screen_draw(struct screen
*display
, int pitch
, int pitch_mode
)
407 unsigned char buf
[32];
410 display
->clear_display();
412 if (display
->nb_lines
< 4) /* very small screen, just show the pitch value */
414 w
= snprintf((char *)buf
, sizeof(buf
), "%s: %d.%d%%",str(LANG_PITCH
),
415 pitch
/ 10, pitch
% 10 );
416 display
->putsxy((display
->width
-(w
*display
->char_width
))/2,
417 display
->nb_lines
/2,buf
);
419 else /* bigger screen, show everything... */
423 if (pitch_mode
== PITCH_MODE_ABSOLUTE
) {
424 ptr
= str(LANG_PITCH_UP
);
426 ptr
= str(LANG_PITCH_UP_SEMITONE
);
428 display
->getstringsize(ptr
,&w
,&h
);
429 display
->putsxy((display
->width
-w
)/2, 0, ptr
);
430 display
->mono_bitmap(bitmap_icons_7x8
[Icon_UpArrow
],
431 display
->width
/2 - 3, h
, 7, 8);
433 /* DOWN: Pitch Down */
434 if (pitch_mode
== PITCH_MODE_ABSOLUTE
) {
435 ptr
= str(LANG_PITCH_DOWN
);
437 ptr
= str(LANG_PITCH_DOWN_SEMITONE
);
439 display
->getstringsize(ptr
,&w
,&h
);
440 display
->putsxy((display
->width
-w
)/2, display
->height
- h
, ptr
);
441 display
->mono_bitmap(bitmap_icons_7x8
[Icon_DownArrow
],
442 display
->width
/2 - 3, display
->height
- h
*2, 7, 8);
446 display
->getstringsize(ptr
,&w
,&h
);
447 display
->putsxy(display
->width
-w
, (display
->height
-h
)/2, ptr
);
448 display
->mono_bitmap(bitmap_icons_7x8
[Icon_FastForward
],
449 display
->width
-w
-8, (display
->height
-h
)/2, 7, 8);
453 display
->getstringsize(ptr
,&w
,&h
);
454 display
->putsxy(0, (display
->height
-h
)/2, ptr
);
455 display
->mono_bitmap(bitmap_icons_7x8
[Icon_FastBackward
],
456 w
+1, (display
->height
-h
)/2, 7, 8);
459 snprintf((char *)buf
, sizeof(buf
), str(LANG_PITCH
));
460 display
->getstringsize(buf
,&w
,&h
);
461 display
->putsxy((display
->width
-w
)/2, (display
->height
/2)-h
, buf
);
463 snprintf((char *)buf
, sizeof(buf
), "%d.%d%%",
464 pitch
/ 10, pitch
% 10 );
465 display
->getstringsize(buf
,&w
,&h
);
466 display
->putsxy((display
->width
-w
)/2, display
->height
/2, buf
);
472 static int pitch_increase(int pitch
, int delta
, bool allow_cutoff
)
477 if (pitch
+ delta
>= PITCH_MIN
) {
478 new_pitch
= pitch
+ delta
;
483 new_pitch
= PITCH_MIN
;
485 } else if (delta
> 0) {
486 if (pitch
+ delta
<= PITCH_MAX
) {
487 new_pitch
= pitch
+ delta
;
492 new_pitch
= PITCH_MAX
;
495 /* delta == 0 -> no real change */
498 sound_set_pitch(new_pitch
);
503 /* Factor for changing the pitch one half tone up.
504 The exact value is 2^(1/12) = 1.05946309436
505 But we use only integer arithmetics, so take
506 rounded factor multiplied by 10^5=100,000. This is
507 enough to get the same promille values as if we
508 had used floating point (checked with a spread
511 #define PITCH_SEMITONE_FACTOR 105946L
513 /* Some helpful constants. K is the scaling factor for SEMITONE.
514 N is for more accurate rounding
517 #define PITCH_K_FCT 100000UL
518 #define PITCH_N_FCT 10
519 #define PITCH_KN_FCT 1000000UL
521 static int pitch_increase_semitone(int pitch
, bool up
)
524 uint32_t round_fct
; /* How much to scale down at the end */
527 tmp
= tmp
* PITCH_SEMITONE_FACTOR
;
528 round_fct
= PITCH_K_FCT
;
530 tmp
= (tmp
* PITCH_KN_FCT
) / PITCH_SEMITONE_FACTOR
;
531 round_fct
= PITCH_N_FCT
;
533 /* Scaling down with rounding */
534 tmp
= (tmp
+ round_fct
/ 2) / round_fct
;
535 return pitch_increase(pitch
, tmp
- pitch
, false);
538 bool pitch_screen(void)
541 int pitch
= sound_get_pitch();
542 int new_pitch
, delta
= 0;
547 #if CONFIG_CODEC == SWCODEC
548 pcmbuf_set_low_latency(true);
554 pitch_screen_draw(&screens
[i
], pitch
, pitch_mode
);
556 button
= get_action(CONTEXT_PITCHSCREEN
,TIMEOUT_BLOCK
);
558 case ACTION_PS_INC_SMALL
:
559 delta
= PITCH_SMALL_DELTA
;
562 case ACTION_PS_INC_BIG
:
563 delta
= PITCH_BIG_DELTA
;
566 case ACTION_PS_DEC_SMALL
:
567 delta
= -PITCH_SMALL_DELTA
;
570 case ACTION_PS_DEC_BIG
:
571 delta
= -PITCH_BIG_DELTA
;
574 case ACTION_PS_NUDGE_RIGHT
:
575 new_pitch
= pitch_increase(pitch
, PITCH_NUDGE_DELTA
, false);
576 nudged
= (new_pitch
!= pitch
);
580 case ACTION_PS_NUDGE_RIGHTOFF
:
582 pitch
= pitch_increase(pitch
, -PITCH_NUDGE_DELTA
, false);
587 case ACTION_PS_NUDGE_LEFT
:
588 new_pitch
= pitch_increase(pitch
, -PITCH_NUDGE_DELTA
, false);
589 nudged
= (new_pitch
!= pitch
);
593 case ACTION_PS_NUDGE_LEFTOFF
:
595 pitch
= pitch_increase(pitch
, PITCH_NUDGE_DELTA
, false);
600 case ACTION_PS_RESET
:
602 sound_set_pitch( pitch
);
605 case ACTION_PS_TOGGLE_MODE
:
606 pitch_mode
= -pitch_mode
;
614 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
621 if (pitch_mode
== PITCH_MODE_ABSOLUTE
) {
622 pitch
= pitch_increase(pitch
, delta
, true);
624 pitch
= pitch_increase_semitone(pitch
, delta
> 0 ? true:false);
631 #if CONFIG_CODEC == SWCODEC
632 pcmbuf_set_low_latency(false);
634 lcd_setfont(FONT_UI
);
637 #endif /* HAVE_PITCHSCREEN */
640 void charging_splash(void)
642 gui_syncsplash(2*HZ
, (unsigned char *)str(LANG_BATTERY_CHARGE
));
643 button_clear_queue();
648 #if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
650 /* little helper function for voice output */
651 static void say_time(int cursorpos
, const struct tm
*tm
)
656 if (!global_settings
.talk_menu
)
674 value
= tm
->tm_year
+ 1900;
681 if (cursorpos
== 4) /* month */
682 talk_id(LANG_MONTH_JANUARY
+ tm
->tm_mon
, false);
684 talk_value(value
, unit
, false);
691 #define SEPARATOR ":"
692 bool set_time_screen(const char* title
, struct tm
*tm
)
696 unsigned int i
, j
, s
;
698 unsigned int julianday
;
699 unsigned int realyear
;
701 unsigned int min
, max
;
702 unsigned int statusbar_height
= 0;
703 unsigned int separator_width
, weekday_width
;
704 unsigned int prev_line_height
;
705 int daysinmonth
[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
706 unsigned char buffer
[20];
708 /* 6 possible cursor possitions, 2 values stored for each: x, y */
709 unsigned int cursor
[6][2];
712 unsigned char *ptr
[6];
714 if(global_settings
.statusbar
)
715 statusbar_height
= STATUSBAR_HEIGHT
;
717 /* speak selection when screen is entered */
718 say_time(cursorpos
, tm
);
721 /* for easy acess in the drawing loop */
722 ptr
[0] = buffer
; /* hours */
723 ptr
[1] = buffer
+ 3; /* minutes */
724 ptr
[2] = buffer
+ 6; /* seconds */
725 ptr
[3] = buffer
+ 9; /* year */
726 ptr
[4] = str(LANG_MONTH_JANUARY
+ tm
->tm_mon
); /* monthname */
727 ptr
[5] = buffer
+ 14; /* day of month */
729 /* calculate the number of days in febuary */
730 realyear
= tm
->tm_year
+ 1900;
731 if((realyear
% 4 == 0 && !(realyear
% 100 == 0)) || realyear
% 400 == 0)
736 /* fix day if month or year changed */
737 if (tm
->tm_mday
> daysinmonth
[tm
->tm_mon
])
738 tm
->tm_mday
= daysinmonth
[tm
->tm_mon
];
740 /* calculate day of week */
741 julianday
= tm
->tm_mday
;
742 for(i
= 0; (int)i
< tm
->tm_mon
; i
++) {
743 julianday
+= daysinmonth
[i
];
746 tm
->tm_wday
= (realyear
+ julianday
+ (realyear
- 1) / 4 -
747 (realyear
- 1) / 100 + (realyear
- 1) / 400 + 7 - 1) % 7;
749 /* put all the numbers we want from the tm struct into
750 an easily printable buffer */
751 snprintf(buffer
, sizeof(buffer
),
752 "%02d " "%02d " "%02d " "%04d " "%02d",
753 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
,
754 tm
->tm_year
+1900, tm
->tm_mday
);
756 /* convert spaces in the buffer to '\0' to make it possible to work
757 directly on the buffer */
758 for(i
=0; i
< sizeof(buffer
); i
++)
766 /* minimum lines needed is 2 + title line */
767 gui_textarea_update_nblines(&screens
[s
]);
768 if (screens
[s
].nb_lines
< 4)
770 screens
[s
].setfont(FONT_SYSFIXED
);
771 gui_textarea_update_nblines(&screens
[s
]);
774 /* recalculate the positions and offsets */
775 if (screens
[s
].nb_lines
>= 3)
776 screens
[s
].getstringsize(title
, NULL
, &prev_line_height
);
778 prev_line_height
= 0;
780 screens
[s
].getstringsize(SEPARATOR
, &separator_width
, NULL
);
783 screens
[s
].getstringsize(str(LANG_WEEKDAY_SUNDAY
+ tm
->tm_wday
), &weekday_width
, NULL
);
784 screens
[s
].getstringsize(" ", &separator_width
, NULL
);
786 for(i
=0, j
=0; i
< 6; i
++)
788 if(i
==3) /* second row */
790 j
= weekday_width
+ separator_width
;;
791 prev_line_height
*= 2;
793 screens
[s
].getstringsize(ptr
[i
], &width
, NULL
);
794 cursor
[i
][INDEX_Y
] = prev_line_height
+ statusbar_height
;
795 cursor
[i
][INDEX_X
] = j
;
796 j
+= width
+ separator_width
;
799 /* draw the screen */
800 screens
[s
].set_drawmode(DRMODE_SOLID
);
801 gui_textarea_clear(&screens
[s
]);
802 /* display the screen title */
803 screens
[s
].puts_scroll(0, 0, title
);
805 /* these are not selectable, so we draw them outside the loop */
806 screens
[s
].putsxy(0, cursor
[3][INDEX_Y
], str(LANG_WEEKDAY_SUNDAY
+ tm
->tm_wday
)); /* name of the week day */
808 /* draw the selected item with drawmode set to
809 DRMODE_SOLID|DRMODE_INVERSEVID, all other selectable
810 items with drawmode DRMODE_SOLID */
813 if (cursorpos
== (int)i
)
814 screens
[s
].set_drawmode(DRMODE_SOLID
|DRMODE_INVERSEVID
);
816 screens
[s
].putsxy(cursor
[i
][INDEX_X
],
817 cursor
[i
][INDEX_Y
], ptr
[i
]);
819 screens
[s
].set_drawmode(DRMODE_SOLID
);
821 screens
[s
].putsxy(cursor
[i
/4 +1][INDEX_X
] - separator_width
,
822 cursor
[0][INDEX_Y
], SEPARATOR
);
825 /* print help text */
826 if (screens
[s
].nb_lines
> 4)
827 screens
[s
].puts(0, 4, str(LANG_TIME_SET_BUTTON
));
828 if (screens
[s
].nb_lines
> 5)
829 screens
[s
].puts(0, 5, str(LANG_TIME_REVERT
));
832 gui_syncstatusbar_draw(&statusbars
, true);
834 /* set the most common numbers */
837 /* calculate the minimum and maximum for the number under cursor */
841 valptr
= &tm
->tm_hour
;
844 valptr
= &tm
->tm_min
;
847 valptr
= &tm
->tm_sec
;
852 valptr
= &tm
->tm_year
;
856 valptr
= &tm
->tm_mon
;
860 max
= daysinmonth
[tm
->tm_mon
];
861 valptr
= &tm
->tm_mday
;
865 button
= get_action(CONTEXT_SETTINGS_TIME
, TIMEOUT_BLOCK
);
867 case ACTION_STD_PREV
:
868 cursorpos
= clamp_value_wrap(--cursorpos
, 5, 0);
869 say_time(cursorpos
, tm
);
871 case ACTION_STD_NEXT
:
872 cursorpos
= clamp_value_wrap(++cursorpos
, 5, 0);
873 say_time(cursorpos
, tm
);
875 case ACTION_SETTINGS_INC
:
876 case ACTION_SETTINGS_INCREPEAT
:
877 *valptr
= clamp_value_wrap(++(*valptr
), max
, min
);
878 say_time(cursorpos
, tm
);
880 case ACTION_SETTINGS_DEC
:
881 case ACTION_SETTINGS_DECREPEAT
:
882 *valptr
= clamp_value_wrap(--(*valptr
), max
, min
);
883 say_time(cursorpos
, tm
);
890 case ACTION_STD_CANCEL
:
896 if (default_event_handler(button
) == SYS_USB_CONNECTED
)
903 screens
[i
].setfont(FONT_UI
);
904 gui_textarea_update_nblines(&screens
[i
]);
908 #endif /* defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) */
910 #if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
911 bool shutdown_screen(void)
915 long time_entered
= current_tick
;
919 gui_syncsplash(0, str(LANG_CONFIRM_SHUTDOWN
));
921 while(!done
&& TIME_BEFORE(current_tick
,time_entered
+HZ
*2))
923 button
= get_action(CONTEXT_STD
,HZ
);
926 case ACTION_STD_CANCEL
:
930 /* do nothing here, because ACTION_NONE might be caused
931 * by timeout or button release. In case of timeout the loop
932 * is terminated by TIME_BEFORE */
937 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
947 static const int id3_headers
[]=
952 LANG_ID3_ALBUMARTIST
,
963 #if CONFIG_CODEC == SWCODEC
970 static char * id3_get_info(int selected_item
, void* data
, char *buffer
)
972 struct mp3entry
* id3
=(struct mp3entry
*)data
;
973 int info_no
=selected_item
/2;
974 if(!(selected_item
%2))
976 return( str(id3_headers
[info_no
]));
984 case 0:/*LANG_ID3_TITLE*/
987 case 1:/*LANG_ID3_ARTIST*/
990 case 2:/*LANG_ID3_ALBUM*/
993 case 3:/*LANG_ID3_ALBUMARTIST*/
994 info
=id3
->albumartist
;
996 case 4:/*LANG_ID3_GROUPING*/
999 case 5:/*LANG_ID3_DISCNUM*/
1000 if (id3
->disc_string
)
1001 info
= id3
->disc_string
;
1002 else if (id3
->discnum
)
1004 snprintf(buffer
, MAX_PATH
, "%d", id3
->discnum
);
1008 case 6:/*LANG_ID3_TRACKNUM*/
1009 if (id3
->track_string
)
1010 info
= id3
->track_string
;
1011 else if (id3
->tracknum
)
1013 snprintf(buffer
, MAX_PATH
, "%d", id3
->tracknum
);
1017 case 7:/*LANG_ID3_COMMENT*/
1020 case 8:/*LANG_ID3_GENRE*/
1021 info
= id3
->genre_string
;
1023 case 9:/*LANG_ID3_YEAR*/
1024 if (id3
->year_string
)
1025 info
= id3
->year_string
;
1028 snprintf(buffer
, MAX_PATH
, "%d", id3
->year
);
1032 case 10:/*LANG_ID3_LENGTH*/
1033 format_time(buffer
, MAX_PATH
, id3
->length
);
1036 case 11:/*LANG_ID3_PLAYLIST*/
1037 snprintf(buffer
, MAX_PATH
, "%d/%d", playlist_get_display_index(),
1041 case 12:/*LANG_ID3_BITRATE*/
1042 snprintf(buffer
, MAX_PATH
, "%d kbps%s", id3
->bitrate
,
1043 id3
->vbr
? str(LANG_ID3_VBR
) : (const unsigned char*) "");
1046 case 13:/*LANG_ID3_FREQUENCY*/
1047 snprintf(buffer
, MAX_PATH
, "%ld Hz", id3
->frequency
);
1050 #if CONFIG_CODEC == SWCODEC
1051 case 14:/*LANG_ID3_TRACK_GAIN*/
1052 info
=id3
->track_gain_string
;
1054 case 15:/*LANG_ID3_ALBUM_GAIN*/
1055 info
=id3
->album_gain_string
;
1057 case 16:/*LANG_ID3_PATH*/
1059 case 14:/*LANG_ID3_PATH*/
1064 return info
&& *info
? info
: (char*) str(LANG_ID3_NO_INFO
);
1068 bool browse_id3(void)
1070 struct gui_synclist id3_lists
;
1071 struct mp3entry
* id3
= audio_current_track();
1074 gui_synclist_init(&id3_lists
, &id3_get_info
, id3
, true, 2);
1075 gui_synclist_set_nb_items(&id3_lists
,
1076 sizeof(id3_headers
)/sizeof(id3_headers
[0])*2);
1077 gui_synclist_draw(&id3_lists
);
1078 gui_syncstatusbar_draw(&statusbars
, true);
1080 gui_syncstatusbar_draw(&statusbars
, false);
1081 key
= get_action(CONTEXT_LIST
,HZ
/2);
1082 if(key
!=ACTION_NONE
&& key
!=ACTION_UNKNOWN
1083 && !gui_synclist_do_button(&id3_lists
, &key
,LIST_WRAP_UNLESS_HELD
))
1085 return(default_event_handler(key
) == SYS_USB_CONNECTED
);
1090 static char* runtime_get_data(int selected_item
, void* data
, char* buffer
)
1093 unsigned char *headers
[] = {str(LANG_RUNNING_TIME
), str(LANG_TOP_TIME
) };
1095 if(!(selected_item
%2))
1096 return headers
[selected_item
/2];
1098 if(selected_item
/2) t
= global_status
.topruntime
;
1099 else t
= global_status
.runtime
;
1101 snprintf(buffer
, 16, "%dh %dm %ds",
1102 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 unsigned char *lines
[]={ID2P(LANG_CLEAR_TIME
)};
1122 struct text_message message
={(char **)lines
, 1};
1124 struct gui_synclist lists
;
1126 gui_synclist_init(&lists
, runtime_get_data
, NULL
, false, 2);
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
)