1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Björn Stenberg
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 "backlight.h"
28 #ifdef HAVE_REMOTE_LCD
29 #include "lcd-remote.h"
35 #include "mp3_playback.h"
37 #if defined(HAVE_USBSTACK)
40 #include "usb_keymaps.h"
50 #include "powermgmt.h"
59 #include "statusbar.h"
60 #include "screen_access.h"
66 #include "appevents.h"
69 #ifdef HAVE_LCD_BITMAP
70 #include "bitmaps/usblogo.h"
73 #ifdef HAVE_REMOTE_LCD
74 #include "bitmaps/remote_usblogo.h"
77 #if (CONFIG_STORAGE & STORAGE_MMC)
80 #if CONFIG_CODEC == SWCODEC
84 /* only used in set_time screen */
85 #if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
86 static int clamp_value_wrap(int value
, int max
, int min
)
102 static int handle_usb_events(void)
104 #if (CONFIG_STORAGE & STORAGE_MMC)
106 #endif /* STORAGE_MMC */
108 /* Don't return until we get SYS_USB_DISCONNECTED or SYS_TIMEOUT */
112 #ifdef USB_ENABLE_HID
113 if (usb_core_driver_enabled(USB_DRIVER_HID
))
115 button
= get_hid_usb_action();
117 /* On mode change, we need to refresh the screen */
118 if (button
== ACTION_USB_HID_MODE_SWITCH_NEXT
||
119 button
== ACTION_USB_HID_MODE_SWITCH_PREV
)
127 button
= button_get_w_tmo(HZ
/2);
128 /* hid emits the event in get_action */
129 send_event(GUI_EVENT_ACTIONUPDATE
, NULL
);
134 case SYS_USB_DISCONNECTED
:
135 usb_acknowledge(SYS_USB_DISCONNECTED_ACK
);
141 #if (CONFIG_STORAGE & STORAGE_MMC) /* USB-MMC bridge can report activity */
142 if(TIME_AFTER(current_tick
,next_update
))
145 led(mmc_usb_active(HZ
));
147 next_update
=current_tick
+HZ
/2;
149 #endif /* STORAGE_MMC */
156 #define MODE_NAME_LEN 32
157 void usb_screen(void)
163 int usb_bars
= VP_SB_ALLSCREENS
; /* force statusbars */
164 int old_bars
= viewportmanager_get_statusbar();
165 #if defined HAVE_TOUCHSCREEN
166 enum touchscreen_mode old_mode
= touchscreen_get_mode();
168 /* TODO: Paint buttons on screens OR switch to point mode and use
169 * touchscreen as a touchpad to move the host's mouse cursor */
170 touchscreen_set_mode(TOUCHSCREEN_BUTTON
);
174 usb_acknowledge(SYS_USB_CONNECTED_ACK
);
177 #ifdef USB_ENABLE_HID
178 usb_keypad_mode
= global_settings
.usb_keypad_mode
;
185 struct screen
*screen
= &screens
[i
];
187 screen
->backdrop_show(BACKDROP_MAIN
);
188 screen
->backlight_on();
189 screen
->clear_display();
190 #ifdef HAVE_REMOTE_LCD
191 if (i
== SCREEN_REMOTE
)
193 screen
->bitmap(remote_usblogo
,
194 (LCD_REMOTE_WIDTH
-BMPWIDTH_remote_usblogo
),
195 (LCD_REMOTE_HEIGHT
-BMPHEIGHT_remote_usblogo
)/2,
196 BMPWIDTH_remote_usblogo
, BMPHEIGHT_remote_usblogo
);
201 #ifdef HAVE_LCD_BITMAP
202 screen
->transparent_bitmap(usblogo
,
203 (LCD_WIDTH
-BMPWIDTH_usblogo
),
204 (LCD_HEIGHT
-BMPHEIGHT_usblogo
)/2,
205 BMPWIDTH_usblogo
, BMPHEIGHT_usblogo
);
206 #ifdef USB_ENABLE_HID
209 screen
->getstringsize(str(keypad_mode_name_get()), &w
, &h
);
210 screen
->putsxy((LCD_WIDTH
- w
) / 2, BMPHEIGHT_usblogo
+
211 (LCD_HEIGHT
- BMPHEIGHT_usblogo
+ h
) / 2,
212 str(keypad_mode_name_get()));
213 #endif /* USB_ENABLE_HID */
214 #else /* HAVE_LCD_BITMAP */
215 screen
->double_height(false);
216 screen
->puts_scroll(0, 0, "[USB Mode]");
217 status_set_param(false);
218 status_set_audio(false);
219 status_set_usb(true);
220 #endif /* HAVE_LCD_BITMAP */
224 /* force statusbar by ignoring the setting */
225 usb_bars
|= VP_SB_IGNORE_SETTING(i
);
228 viewportmanager_set_statusbar(usb_bars
);
231 if (button_get_w_tmo(HZ
/2))
233 send_event(GUI_EVENT_ACTIONUPDATE
, NULL
);
235 if (handle_usb_events())
237 #endif /* SIMULATOR */
240 #ifdef USB_ENABLE_HID
241 if (global_settings
.usb_keypad_mode
!= usb_keypad_mode
)
243 global_settings
.usb_keypad_mode
= usb_keypad_mode
;
248 #ifdef HAVE_TOUCHSCREEN
249 touchscreen_set_mode(old_mode
);
252 #ifdef HAVE_LCD_CHARCELLS
253 status_set_usb(false);
254 #endif /* HAVE_LCD_CHARCELLS */
257 screens
[i
].backlight_on();
259 viewportmanager_set_statusbar(old_bars
);
260 send_event(GUI_EVENT_REFRESH
, NULL
);
262 #endif /* USB_NONE */
265 #if (CONFIG_STORAGE & STORAGE_MMC)
266 int mmc_remove_request(void)
268 struct queue_event ev
;
271 screens
[i
].clear_display();
272 splash(0, ID2P(LANG_REMOVE_MMC
));
276 queue_wait_w_tmo(&button_queue
, &ev
, HZ
/2);
279 case SYS_HOTSWAP_EXTRACTED
:
280 return SYS_HOTSWAP_EXTRACTED
;
282 case SYS_USB_DISCONNECTED
:
283 return SYS_USB_DISCONNECTED
;
289 /* the charging screen is only used for archos targets */
290 #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING) && defined(CPU_SH)
292 #ifdef HAVE_LCD_BITMAP
293 static void charging_display_info(bool animate
)
295 unsigned char charging_logo
[36];
296 const int pox_x
= (LCD_WIDTH
- sizeof(charging_logo
)) / 2;
297 const int pox_y
= 32;
298 static unsigned phase
= 3;
301 #ifdef NEED_ATA_POWER_BATT_MEASURE
302 if (ide_powered()) /* FM and V2 can only measure when ATA power is on */
305 int battv
= battery_voltage();
306 lcd_putsf(0, 7, " Batt: %d.%02dV %d%% ", battv
/ 1000,
307 (battv
% 1000) / 10, battery_level());
310 #ifdef ARCHOS_RECORDER
311 lcd_puts(0, 2, "Charge mode:");
314 if (charge_state
== CHARGING
)
315 s
= str(LANG_BATTERY_CHARGE
);
316 else if (charge_state
== TOPOFF
)
317 s
= str(LANG_BATTERY_TOPOFF_CHARGE
);
318 else if (charge_state
== TRICKLE
)
319 s
= str(LANG_BATTERY_TRICKLE_CHARGE
);
324 if (!charger_enabled())
326 #endif /* ARCHOS_RECORDER */
329 memset(charging_logo
+3, 0x00, 32);
330 charging_logo
[0] = 0x3C;
331 charging_logo
[1] = 0x24;
332 charging_logo
[2] = charging_logo
[35] = 0xFF;
335 { /* draw the outline */
337 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 8,
338 sizeof(charging_logo
), 8);
339 lcd_set_drawmode(DRMODE_FG
);
341 charging_logo
[0] = charging_logo
[1] = 0x00;
342 memset(charging_logo
+2, 0x80, 34);
343 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
, sizeof(charging_logo
), 8);
345 memset(charging_logo
+2, 0x01, 34);
346 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 16,
347 sizeof(charging_logo
), 8);
348 lcd_set_drawmode(DRMODE_SOLID
);
351 { /* animate the middle part */
352 for (i
= 3; i
<MIN(sizeof(charging_logo
)-1, phase
); i
++)
354 if ((i
-phase
) % 8 == 0)
355 { /* draw a "bubble" here */
357 bitpos
= (phase
+ i
/8) % 15; /* "bounce" effect */
359 bitpos
= 14 - bitpos
;
360 charging_logo
[i
] = BIT_N(bitpos
);
363 lcd_mono_bitmap(charging_logo
, pox_x
, pox_y
+ 8,
364 sizeof(charging_logo
), 8);
369 #else /* not HAVE_LCD_BITMAP */
371 static unsigned long logo_chars
[4];
372 static const unsigned char logo_pattern
[] = {
373 0x07, 0x04, 0x1c, 0x14, 0x1c, 0x04, 0x07, 0, /* char 1 */
374 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 2 */
375 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0, /* char 3 */
376 0x1f, 0x01, 0x01, 0x01, 0x01, 0x01, 0x1f, 0, /* char 4 */
379 static void logo_lock_patterns(bool on
)
385 for (i
= 0; i
< 4; i
++)
386 logo_chars
[i
] = lcd_get_locked_pattern();
390 for (i
= 0; i
< 4; i
++)
391 lcd_unlock_pattern(logo_chars
[i
]);
395 static void charging_display_info(bool animate
)
399 static unsigned phase
= 3;
402 battv
= battery_voltage();
403 lcd_putsf(4, 1, " %d.%02dV", battv
/ 1000, (battv
% 1000) / 10);
405 memcpy(buf
, logo_pattern
, 32); /* copy logo patterns */
407 if (!animate
) /* build the screen */
409 lcd_double_height(false);
410 lcd_puts(0, 0, "[Charging]");
411 for (i
= 0; i
< 4; i
++)
412 lcd_putc(i
, 1, logo_chars
[i
]);
414 else /* animate the logo */
416 for (i
= 3; i
< MIN(19, phase
); i
++)
418 if ((i
- phase
) % 5 == 0)
419 { /* draw a "bubble" here */
420 ypos
= (phase
+ i
/5) % 9; /* "bounce" effect */
423 buf
[5 - ypos
+ 8 * (i
/5)] |= 0x10u
>> (i
%5);
429 for (i
= 0; i
< 4; i
++)
430 lcd_define_pattern(logo_chars
[i
], buf
+ 8 * i
);
434 #endif /* (not) HAVE_LCD_BITMAP */
436 /* blocks while charging, returns on event:
437 1 if charger cable was removed
438 2 if Off/Stop key was pressed
439 3 if On key was pressed
440 4 if USB was connected */
442 int charging_screen(void)
447 ide_power_enable(false); /* power down the disk, else would be spinning */
450 backlight_set_timeout(global_settings
.backlight_timeout
);
451 #ifdef HAVE_REMOTE_LCD
452 remote_backlight_set_timeout(global_settings
.remote_backlight_timeout
);
454 backlight_set_timeout_plugged(global_settings
.backlight_timeout_plugged
);
456 #ifdef HAVE_LCD_CHARCELLS
457 logo_lock_patterns(true);
459 charging_display_info(false);
463 gui_syncstatusbar_draw(&statusbars
, false);
464 charging_display_info(true);
465 button
= get_action(CONTEXT_STD
,HZ
/3);
466 if (button
== ACTION_STD_OK
)
468 else if (usb_detect() == USB_INSERTED
)
470 else if (!charger_inserted())
474 #ifdef HAVE_LCD_CHARCELLS
475 logo_lock_patterns(false);
479 #endif /* CONFIG_CHARGING && !HAVE_POWEROFF_WHILE_CHARGING && defined(CPU_SH) */
482 void charging_splash(void)
484 splash(2*HZ
, str(LANG_BATTERY_CHARGE
));
485 button_clear_queue();
490 #if defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0)
492 /* little helper function for voice output */
493 static void say_time(int cursorpos
, const struct tm
*tm
)
498 if (!global_settings
.talk_menu
)
516 value
= tm
->tm_year
+ 1900;
523 if (cursorpos
== 4) /* month */
524 talk_id(LANG_MONTH_JANUARY
+ tm
->tm_mon
, false);
526 talk_value(value
, unit
, false);
533 #define SEPARATOR ":"
536 #define IDX_MINUTES 1
537 #define IDX_SECONDS 2
543 #define OFF_MINUTES 3
544 #define OFF_SECONDS 6
548 bool set_time_screen(const char* title
, struct tm
*tm
)
552 unsigned int statusbar_height
= 0;
553 unsigned char offsets_ptr
[] =
554 { OFF_HOURS
, OFF_MINUTES
, OFF_SECONDS
, OFF_YEAR
, 0, OFF_DAY
};
558 offsets_ptr
[IDX_HOURS
] = OFF_SECONDS
;
559 offsets_ptr
[IDX_SECONDS
] = OFF_HOURS
;
560 offsets_ptr
[IDX_YEAR
] = OFF_DAY
;
561 offsets_ptr
[IDX_DAY
] = OFF_YEAR
;
564 if(global_settings
.statusbar
)
565 statusbar_height
= STATUSBAR_HEIGHT
;
567 /* speak selection when screen is entered */
568 say_time(cursorpos
, tm
);
572 unsigned int i
, s
, realyear
, min
, max
;
573 unsigned char *ptr
[6];
574 unsigned char buffer
[20];
576 static unsigned char daysinmonth
[] =
577 {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
579 /* for easy acess in the drawing loop */
580 for (i
= 0; i
< 6; i
++)
581 ptr
[i
] = buffer
+ offsets_ptr
[i
];
582 ptr
[IDX_MONTH
] = str(LANG_MONTH_JANUARY
+ tm
->tm_mon
); /* month name */
584 /* calculate the number of days in febuary */
585 realyear
= tm
->tm_year
+ 1900;
586 if((realyear
% 4 == 0 && !(realyear
% 100 == 0)) || realyear
% 400 == 0)
591 /* fix day if month or year changed */
592 if (tm
->tm_mday
> daysinmonth
[tm
->tm_mon
])
593 tm
->tm_mday
= daysinmonth
[tm
->tm_mon
];
595 /* calculate day of week */
598 /* put all the numbers we want from the tm struct into
599 an easily printable buffer */
600 snprintf(buffer
, sizeof(buffer
),
601 "%02d " "%02d " "%02d " "%04d " "%02d",
602 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
,
603 tm
->tm_year
+1900, tm
->tm_mday
);
605 /* convert spaces in the buffer to '\0' to make it possible to work
606 directly on the buffer */
607 for(i
=0; i
< sizeof(buffer
); i
++)
616 unsigned int separator_width
, weekday_width
;
617 unsigned int j
, width
, prev_line_height
;
618 struct viewport viewports
[NB_SCREENS
];
619 /* 6 possible cursor possitions, 2 values stored for each: x, y */
620 unsigned int cursor
[6][2];
621 struct viewport
*vp
= &viewports
[s
];
622 struct screen
*screen
= &screens
[s
];
623 static unsigned char rtl_idx
[] =
624 { IDX_SECONDS
, IDX_MINUTES
, IDX_HOURS
, IDX_DAY
, IDX_MONTH
, IDX_YEAR
};
626 viewport_set_defaults(vp
, s
);
627 screen
->set_viewport(vp
);
628 nb_lines
= viewport_get_nb_lines(vp
);
630 /* minimum lines needed is 2 + title line */
633 vp
->font
= FONT_SYSFIXED
;
634 nb_lines
= viewport_get_nb_lines(vp
);
637 /* recalculate the positions and offsets */
639 screen
->getstringsize(title
, NULL
, &prev_line_height
);
641 prev_line_height
= 0;
643 screen
->getstringsize(SEPARATOR
, &separator_width
, NULL
);
646 screen
->getstringsize(str(LANG_WEEKDAY_SUNDAY
+ tm
->tm_wday
),
647 &weekday_width
, NULL
);
648 screen
->getstringsize(" ", &separator_width
, NULL
);
650 for(i
=0, j
=0; i
< 6; i
++)
652 if(i
==3) /* second row */
654 j
= weekday_width
+ separator_width
;
655 prev_line_height
*= 2;
657 screen
->getstringsize(ptr
[i
], &width
, NULL
);
658 cursor
[i
][INDEX_Y
] = prev_line_height
+ statusbar_height
;
659 cursor
[i
][INDEX_X
] = j
;
660 j
+= width
+ separator_width
;
663 /* draw the screen */
664 screen
->set_viewport(vp
);
665 screen
->clear_viewport();
666 /* display the screen title */
667 screen
->puts_scroll(0, 0, title
);
669 /* these are not selectable, so we draw them outside the loop */
670 /* name of the week day */
671 screen
->putsxy(0, cursor
[3][INDEX_Y
],
672 str(LANG_WEEKDAY_SUNDAY
+ tm
->tm_wday
));
674 pos
= lang_is_rtl() ? rtl_idx
[cursorpos
] : cursorpos
;
675 /* draw the selected item with drawmode set to
676 DRMODE_SOLID|DRMODE_INVERSEVID, all other selectable
677 items with drawmode DRMODE_SOLID */
681 vp
->drawmode
= (DRMODE_SOLID
|DRMODE_INVERSEVID
);
683 screen
->putsxy(cursor
[i
][INDEX_X
],
684 cursor
[i
][INDEX_Y
], ptr
[i
]);
686 vp
->drawmode
= DRMODE_SOLID
;
688 screen
->putsxy(cursor
[i
/4 +1][INDEX_X
] - separator_width
,
689 cursor
[0][INDEX_Y
], SEPARATOR
);
692 /* print help text */
694 screen
->puts(0, 4, str(LANG_TIME_SET_BUTTON
));
696 screen
->puts(0, 5, str(LANG_TIME_REVERT
));
697 screen
->update_viewport();
698 screen
->set_viewport(NULL
);
701 /* set the most common numbers */
704 /* calculate the minimum and maximum for the number under cursor */
708 valptr
= &tm
->tm_hour
;
711 valptr
= &tm
->tm_min
;
714 valptr
= &tm
->tm_sec
;
719 valptr
= &tm
->tm_year
;
723 valptr
= &tm
->tm_mon
;
727 max
= daysinmonth
[tm
->tm_mon
];
728 valptr
= &tm
->tm_mday
;
732 #ifdef HAVE_TOUCHSCREEN
733 enum touchscreen_mode old_mode
= touchscreen_get_mode();
735 touchscreen_set_mode(TOUCHSCREEN_BUTTON
);
737 button
= get_action(CONTEXT_SETTINGS_TIME
, TIMEOUT_BLOCK
);
738 #ifdef HAVE_TOUCHSCREEN
739 touchscreen_set_mode(old_mode
);
742 case ACTION_STD_PREV
:
743 cursorpos
= clamp_value_wrap(--cursorpos
, 5, 0);
744 say_time(cursorpos
, tm
);
746 case ACTION_STD_NEXT
:
747 cursorpos
= clamp_value_wrap(++cursorpos
, 5, 0);
748 say_time(cursorpos
, tm
);
750 case ACTION_SETTINGS_INC
:
751 case ACTION_SETTINGS_INCREPEAT
:
752 *valptr
= clamp_value_wrap(++(*valptr
), max
, min
);
753 say_time(cursorpos
, tm
);
755 case ACTION_SETTINGS_DEC
:
756 case ACTION_SETTINGS_DECREPEAT
:
757 *valptr
= clamp_value_wrap(--(*valptr
), max
, min
);
758 say_time(cursorpos
, tm
);
765 case ACTION_STD_CANCEL
:
771 if (default_event_handler(button
) == SYS_USB_CONNECTED
)
778 #endif /* defined(HAVE_LCD_BITMAP) && (CONFIG_RTC != 0) */
780 #if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
781 bool shutdown_screen(void)
785 long time_entered
= current_tick
;
789 splash(0, str(LANG_CONFIRM_SHUTDOWN
));
791 while(!done
&& TIME_BEFORE(current_tick
,time_entered
+HZ
*2))
793 button
= get_action(CONTEXT_STD
,HZ
);
796 case ACTION_STD_CANCEL
:
800 /* do nothing here, because ACTION_NONE might be caused
801 * by timeout or button release. In case of timeout the loop
802 * is terminated by TIME_BEFORE */
807 if(default_event_handler(button
) == SYS_USB_CONNECTED
)
817 static const int id3_headers
[]=
822 LANG_ID3_ALBUMARTIST
,
833 #if CONFIG_CODEC == SWCODEC
840 struct id3view_info
{
841 struct mp3entry
* id3
;
843 int info_id
[ARRAYLEN(id3_headers
)];
846 static const char* id3_get_info(int selected_item
, void* data
,
847 char *buffer
, size_t buffer_len
)
849 struct id3view_info
*info
= (struct id3view_info
*)data
;
850 struct mp3entry
* id3
=info
->id3
;
851 int info_no
=selected_item
/2;
852 if(!(selected_item
%2))
854 return(str(id3_headers
[info
->info_id
[info_no
]]));
860 switch(info
->info_id
[info_no
])
862 case 0:/*LANG_ID3_TITLE*/
865 case 1:/*LANG_ID3_ARTIST*/
868 case 2:/*LANG_ID3_ALBUM*/
871 case 3:/*LANG_ID3_ALBUMARTIST*/
872 val
=id3
->albumartist
;
874 case 4:/*LANG_ID3_GROUPING*/
877 case 5:/*LANG_ID3_DISCNUM*/
878 if (id3
->disc_string
)
879 val
= id3
->disc_string
;
880 else if (id3
->discnum
)
882 snprintf(buffer
, buffer_len
, "%d", id3
->discnum
);
886 case 6:/*LANG_ID3_TRACKNUM*/
887 if (id3
->track_string
)
888 val
= id3
->track_string
;
889 else if (id3
->tracknum
)
891 snprintf(buffer
, buffer_len
, "%d", id3
->tracknum
);
895 case 7:/*LANG_ID3_COMMENT*/
898 case 8:/*LANG_ID3_GENRE*/
899 val
= id3
->genre_string
;
901 case 9:/*LANG_ID3_YEAR*/
902 if (id3
->year_string
)
903 val
= id3
->year_string
;
906 snprintf(buffer
, buffer_len
, "%d", id3
->year
);
910 case 10:/*LANG_ID3_LENGTH*/
911 format_time(buffer
, buffer_len
, id3
->length
);
914 case 11:/*LANG_ID3_PLAYLIST*/
915 snprintf(buffer
, buffer_len
, "%d/%d",
916 playlist_get_display_index(), playlist_amount());
919 case 12:/*LANG_ID3_BITRATE*/
920 snprintf(buffer
, buffer_len
, "%d kbps%s", id3
->bitrate
,
921 id3
->vbr
? str(LANG_ID3_VBR
) : (const unsigned char*) "");
924 case 13:/*LANG_ID3_FREQUENCY*/
925 snprintf(buffer
, buffer_len
, "%ld Hz", id3
->frequency
);
928 #if CONFIG_CODEC == SWCODEC
929 case 14:/*LANG_ID3_TRACK_GAIN*/
930 val
=id3
->track_gain_string
;
932 case 15:/*LANG_ID3_ALBUM_GAIN*/
933 val
=id3
->album_gain_string
;
935 case 16:/*LANG_ID3_PATH*/
937 case 14:/*LANG_ID3_PATH*/
942 return val
&& *val
? val
: NULL
;
946 bool browse_id3(void)
948 struct gui_synclist id3_lists
;
949 struct mp3entry
* id3
= audio_current_track();
952 struct id3view_info info
;
955 for (i
= 0; i
< ARRAYLEN(id3_headers
); i
++)
959 if (id3_get_info((i
*2)+1, &info
, temp
, 8) != NULL
)
960 info
.info_id
[info
.count
++] = i
;
963 gui_synclist_init(&id3_lists
, &id3_get_info
, &info
, true, 2, NULL
);
964 gui_synclist_set_nb_items(&id3_lists
, info
.count
*2);
965 gui_synclist_draw(&id3_lists
);
967 key
= get_action(CONTEXT_LIST
,HZ
/2);
968 if(key
!=ACTION_NONE
&& key
!=ACTION_UNKNOWN
969 && !gui_synclist_do_button(&id3_lists
, &key
,LIST_WRAP_UNLESS_HELD
))
971 return(default_event_handler(key
) == SYS_USB_CONNECTED
);
976 static const char* runtime_get_data(int selected_item
, void* data
,
977 char* buffer
, size_t buffer_len
)
981 switch (selected_item
)
983 case 0: return str(LANG_RUNNING_TIME
);
984 case 1: t
= global_status
.runtime
; break;
985 case 2: return str(LANG_TOP_TIME
);
986 case 3: t
= global_status
.topruntime
; break;
991 snprintf(buffer
, buffer_len
, "%dh %dm %ds",
992 t
/ 3600, (t
% 3600) / 60, t
% 60);
996 static int runtime_speak_data(int selected_item
, void* data
)
1000 (selected_item
< 2) ? LANG_RUNNING_TIME
: LANG_TOP_TIME
,
1001 TALK_ID((selected_item
< 2) ? global_status
.runtime
1002 : global_status
.topruntime
, UNIT_TIME
));
1007 bool view_runtime(void)
1009 static const char *lines
[]={ID2P(LANG_CLEAR_TIME
)};
1010 static const struct text_message message
={lines
, 1};
1012 struct gui_synclist lists
;
1014 gui_synclist_init(&lists
, runtime_get_data
, NULL
, false, 2, NULL
);
1015 #if !defined(HAVE_LCD_CHARCELLS)
1016 gui_synclist_set_title(&lists
, str(LANG_RUNNING_TIME
), NOICON
);
1018 gui_synclist_set_title(&lists
, NULL
, NOICON
);
1020 if(global_settings
.talk_menu
)
1021 gui_synclist_set_voice_callback(&lists
, runtime_speak_data
);
1022 gui_synclist_set_icon_callback(&lists
, NULL
);
1023 gui_synclist_set_nb_items(&lists
, 4);
1024 gui_synclist_speak_item(&lists
);
1028 if (charger_inserted())
1030 global_status
.runtime
= 0;
1035 global_status
.runtime
+= ((current_tick
- lasttime
) / HZ
);
1037 lasttime
= current_tick
;
1038 gui_synclist_draw(&lists
);
1039 list_do_action(CONTEXT_STD
, HZ
,
1040 &lists
, &action
, LIST_WRAP_UNLESS_HELD
);
1041 if(action
== ACTION_STD_CANCEL
)
1043 if(action
== ACTION_STD_OK
) {
1044 if(gui_syncyesno_run(&message
, NULL
, NULL
)==YESNO_YES
)
1046 if (!(gui_synclist_get_sel_pos(&lists
)/2))
1047 global_status
.runtime
= 0;
1049 global_status
.topruntime
= 0;
1050 gui_synclist_speak_item(&lists
);
1053 if(default_event_handler(action
) == SYS_USB_CONNECTED
)
1059 #ifdef HAVE_TOUCHSCREEN
1060 static int get_sample(struct touchscreen_calibration
*cal
, int x
, int y
, int i
,
1061 struct screen
* screen
)
1067 screen
->drawline(x
- 10, y
, x
- 2, y
);
1068 screen
->drawline(x
+ 2, y
, x
+ 10, y
);
1069 screen
->drawline(x
, y
- 10, x
, y
- 2);
1070 screen
->drawline(x
, y
+ 2, x
, y
+ 10);
1073 /* Wait for a touchscreen press */
1076 action
= get_action(CONTEXT_STD
, TIMEOUT_BLOCK
);
1077 if(action
== ACTION_TOUCHSCREEN
)
1079 if(action_get_touchscreen_press(&ts_x
, &ts_y
) == BUTTON_REL
)
1082 else if(action
== ACTION_STD_CANCEL
)
1086 cal
->x
[i
][0] = ts_x
;
1087 cal
->y
[i
][0] = ts_y
;
1097 short points
[3][2] = {
1098 {LCD_WIDTH
/10, LCD_HEIGHT
/10},
1099 {7*LCD_WIDTH
/8, LCD_HEIGHT
/2},
1100 {LCD_WIDTH
/2, 7*LCD_HEIGHT
/8}
1102 struct screen
* screen
= &screens
[SCREEN_MAIN
];
1103 enum touchscreen_mode old_mode
= touchscreen_get_mode();
1104 struct touchscreen_calibration cal
;
1106 int statusbar
= global_settings
.statusbar
; /* hide the statusbar */
1107 global_settings
.statusbar
= STATUSBAR_OFF
;
1109 touchscreen_disable_mapping(); /* set raw mode */
1110 touchscreen_set_mode(TOUCHSCREEN_POINT
);
1113 screen
->clear_display();
1115 if(get_sample(&cal
, points
[i
][0], points
[i
][1], i
, screen
))
1123 touchscreen_calibrate(&cal
);
1125 touchscreen_reset_mapping();
1126 memcpy(&global_settings
.ts_calibration_data
, &calibration_parameters
, sizeof(struct touchscreen_parameter
));
1127 touchscreen_set_mode(old_mode
);
1128 global_settings
.statusbar
= statusbar
;
1133 int reset_mapping(void)
1135 touchscreen_reset_mapping();
1136 memcpy(&global_settings
.ts_calibration_data
, &calibration_parameters
, sizeof(struct touchscreen_parameter
));