1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Daniel 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 ****************************************************************************/
27 #include "lcd-remote.h"
31 #include "timefuncs.h"
36 #include "mp3_playback.h"
39 #include "ata_idle_notify.h"
42 #include "powermgmt.h"
43 #include "backlight.h"
49 #include "scrobbler.h"
55 #include "eeprom_settings.h"
57 #include "recording.h"
59 #ifdef HAVE_LCD_BITMAP
62 #endif /* End HAVE_LCD_BITMAP */
63 #include "gui/gwps-common.h"
70 #if !defined(USB_NONE) && !defined(USB_IPODSTYLE)
77 /* Format a large-range value for output, using the appropriate unit so that
78 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
79 * units) if possible, and 3 significant digits are shown. If a buffer is
80 * given, the result is snprintf()'d into that buffer, otherwise the result is
82 char *output_dyn_value(char *buf
, int buf_size
, int value
,
83 const unsigned char **units
, bool bin_scale
)
85 int scale
= bin_scale
? 1024 : 1000;
91 while (value
>= scale
)
93 fraction
= value
% scale
;
98 fraction
= fraction
* 1000 / 1024;
100 if (value
>= 100 || !unit_no
)
102 else if (value
>= 10)
103 snprintf(tbuf
, sizeof(tbuf
), "%01d", fraction
/ 100);
105 snprintf(tbuf
, sizeof(tbuf
), "%02d", fraction
/ 10);
110 snprintf(buf
, buf_size
, "%d%s%s%s", value
, str(LANG_POINT
),
111 tbuf
, P2STR(units
[unit_no
]));
113 snprintf(buf
, buf_size
, "%d%s", value
, P2STR(units
[unit_no
]));
117 /* strip trailing zeros from the fraction */
118 for (i
= strlen(tbuf
) - 1; (i
>= 0) && (tbuf
[i
] == '0'); i
--)
121 talk_number(value
, true);
124 talk_id(LANG_POINT
, true);
125 talk_spell(tbuf
, true);
127 talk_id(P2ID(units
[unit_no
]), true);
132 /* Create a filename with a number part in a way that the number is 1
133 * higher than the highest numbered file matching the same pattern.
134 * It is allowed that buffer and path point to the same memory location,
135 * saving a strcpy(). Path must always be given without trailing slash.
136 * "num" can point to an int specifying the number to use or NULL or a value
137 * less than zero to number automatically. The final number used will also
138 * be returned in *num. If *num is >= 0 then *num will be incremented by
140 char *create_numbered_filename(char *buffer
, const char *path
,
141 const char *prefix
, const char *suffix
,
142 int numberlen
IF_CNFN_NUM_(, int *num
))
145 struct dirent
*entry
;
148 int prefixlen
= strlen(prefix
);
152 strncpy(buffer
, path
, MAX_PATH
);
154 pathlen
= strlen(buffer
);
157 if (num
&& *num
>= 0)
159 /* number specified */
165 /* automatic numbering */
168 dir
= opendir(pathlen
? buffer
: "/");
172 while ((entry
= readdir(dir
)))
176 if (strncasecmp((char *)entry
->d_name
, prefix
, prefixlen
)
177 || strcasecmp((char *)entry
->d_name
+ prefixlen
+ numberlen
, suffix
))
180 curr_num
= atoi((char *)entry
->d_name
+ prefixlen
);
181 if (curr_num
> max_num
)
190 snprintf(fmtstring
, sizeof(fmtstring
), "/%%s%%0%dd%%s", numberlen
);
191 snprintf(buffer
+ pathlen
, MAX_PATH
- pathlen
, fmtstring
, prefix
,
202 /* Format time into buf.
204 * buf - buffer to format to.
205 * buf_size - size of buffer.
206 * t - time to format, in milliseconds.
208 void format_time(char* buf
, int buf_size
, long t
)
212 snprintf(buf
, buf_size
, "%d:%02d",
213 (int) (t
/ 60000), (int) (t
% 60000 / 1000));
217 snprintf(buf
, buf_size
, "%d:%02d:%02d",
218 (int) (t
/ 3600000), (int) (t
% 3600000 / 60000),
219 (int) (t
% 60000 / 1000));
224 /* Create a filename with a date+time part.
225 It is allowed that buffer and path point to the same memory location,
226 saving a strcpy(). Path must always be given without trailing slash.
227 unique_time as true makes the function wait until the current time has
229 char *create_datetime_filename(char *buffer
, const char *path
,
230 const char *prefix
, const char *suffix
,
233 struct tm
*tm
= get_time();
234 static struct tm last_tm
;
237 while (unique_time
&& !memcmp(get_time(), &last_tm
, sizeof (struct tm
)))
243 strncpy(buffer
, path
, MAX_PATH
);
245 pathlen
= strlen(buffer
);
246 snprintf(buffer
+ pathlen
, MAX_PATH
- pathlen
,
247 "/%s%02d%02d%02d-%02d%02d%02d%s", prefix
,
248 tm
->tm_year
% 100, tm
->tm_mon
+ 1, tm
->tm_mday
,
249 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
, suffix
);
253 #endif /* CONFIG_RTC */
255 /* Read (up to) a line of text from fd into buffer and return number of bytes
256 * read (which may be larger than the number of bytes stored in buffer). If
257 * an error occurs, -1 is returned (and buffer contains whatever could be
258 * read). A line is terminated by a LF char. Neither LF nor CR chars are
261 int read_line(int fd
, char* buffer
, int buffer_size
)
268 while (count
< buffer_size
)
272 if (1 != read(fd
, &c
, 1))
286 buffer
[MIN(count
, buffer_size
- 1)] = 0;
288 return errno
? -1 : num_read
;
291 /* Performance optimized version of the previous function. */
292 int fast_readline(int fd
, char *buf
, int buf_size
, void *parameters
,
293 int (*callback
)(int n
, const char *buf
, void *parameters
))
303 rc
= read(fd
, &buf
[pos
], buf_size
- pos
- 1);
307 if ( (p
= strchr(buf
, '\r')) != NULL
)
315 if ( (p
= strchr(p
, '\n')) != NULL
)
321 rc
= callback(count
, buf
, parameters
);
328 pos
= buf_size
- ((long)next
- (long)buf
) - 1;
329 memmove(buf
, next
, pos
);
338 #ifdef HAVE_LCD_BITMAP
341 #define BMP_COMPRESSION 3 /* BI_BITFIELDS */
342 #define BMP_NUMCOLORS 3
344 #define BMP_COMPRESSION 0 /* BI_RGB */
346 #define BMP_NUMCOLORS (1 << LCD_DEPTH)
348 #define BMP_NUMCOLORS 0
354 #define BMP_LINESIZE ((LCD_WIDTH/8 + 3) & ~3)
357 #define BMP_LINESIZE ((LCD_WIDTH/2 + 3) & ~3)
360 #define BMP_LINESIZE ((LCD_WIDTH + 3) & ~3)
361 #elif LCD_DEPTH <= 16
363 #define BMP_LINESIZE ((LCD_WIDTH*2 + 3) & ~3)
366 #define BMP_LINESIZE ((LCD_WIDTH*3 + 3) & ~3)
369 #define BMP_HEADERSIZE (54 + 4 * BMP_NUMCOLORS)
370 #define BMP_DATASIZE (BMP_LINESIZE * LCD_HEIGHT)
371 #define BMP_TOTALSIZE (BMP_HEADERSIZE + BMP_DATASIZE)
373 #define LE16_CONST(x) (x)&0xff, ((x)>>8)&0xff
374 #define LE32_CONST(x) (x)&0xff, ((x)>>8)&0xff, ((x)>>16)&0xff, ((x)>>24)&0xff
376 static const unsigned char bmpheader
[] =
378 0x42, 0x4d, /* 'BM' */
379 LE32_CONST(BMP_TOTALSIZE
), /* Total file size */
380 0x00, 0x00, 0x00, 0x00, /* Reserved */
381 LE32_CONST(BMP_HEADERSIZE
), /* Offset to start of pixel data */
383 0x28, 0x00, 0x00, 0x00, /* Size of (2nd) header */
384 LE32_CONST(LCD_WIDTH
), /* Width in pixels */
385 LE32_CONST(LCD_HEIGHT
), /* Height in pixels */
386 0x01, 0x00, /* Number of planes (always 1) */
387 LE16_CONST(BMP_BPP
), /* Bits per pixel 1/4/8/16/24 */
388 LE32_CONST(BMP_COMPRESSION
),/* Compression mode */
389 LE32_CONST(BMP_DATASIZE
), /* Size of bitmap data */
390 0xc4, 0x0e, 0x00, 0x00, /* Horizontal resolution (pixels/meter) */
391 0xc4, 0x0e, 0x00, 0x00, /* Vertical resolution (pixels/meter) */
392 LE32_CONST(BMP_NUMCOLORS
), /* Number of used colours */
393 LE32_CONST(BMP_NUMCOLORS
), /* Number of important colours */
396 0x90, 0xee, 0x90, 0x00, /* Colour #0 */
397 0x00, 0x00, 0x00, 0x00 /* Colour #1 */
399 0xe6, 0xd8, 0xad, 0x00, /* Colour #0 */
400 0x99, 0x90, 0x73, 0x00, /* Colour #1 */
401 0x4c, 0x48, 0x39, 0x00, /* Colour #2 */
402 0x00, 0x00, 0x00, 0x00 /* Colour #3 */
403 #elif LCD_DEPTH == 16
404 0x00, 0xf8, 0x00, 0x00, /* red bitfield mask */
405 0xe0, 0x07, 0x00, 0x00, /* green bitfield mask */
406 0x1f, 0x00, 0x00, 0x00 /* blue bitfield mask */
410 static void (*screen_dump_hook
)(int fh
) = NULL
;
412 void screen_dump(void)
415 char filename
[MAX_PATH
];
418 static unsigned char line_block
[8][BMP_LINESIZE
];
420 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
421 static unsigned char line_block
[BMP_LINESIZE
];
423 static unsigned char line_block
[4][BMP_LINESIZE
];
425 #elif LCD_DEPTH == 16
426 static unsigned short line_block
[BMP_LINESIZE
/2];
430 create_datetime_filename(filename
, "", "dump ", ".bmp", false);
432 create_numbered_filename(filename
, "", "dump_", ".bmp", 4
433 IF_CNFN_NUM_(, NULL
));
436 fh
= creat(filename
);
440 if (screen_dump_hook
)
442 screen_dump_hook(fh
);
446 write(fh
, bmpheader
, sizeof(bmpheader
));
448 /* BMP image goes bottom up */
450 for (by
= LCD_FBHEIGHT
- 1; by
>= 0; by
--)
452 unsigned char *src
= &lcd_framebuffer
[by
][0];
453 unsigned char *dst
= &line_block
[0][0];
455 memset(line_block
, 0, sizeof(line_block
));
456 for (bx
= LCD_WIDTH
/8; bx
> 0; bx
--)
458 unsigned dst_mask
= 0x80;
461 for (ix
= 8; ix
> 0; ix
--)
463 unsigned char *dst_blk
= dst
;
464 unsigned src_byte
= *src
++;
467 for (iy
= 8; iy
> 0; iy
--)
470 *dst_blk
|= dst_mask
;
472 dst_blk
+= BMP_LINESIZE
;
479 write(fh
, line_block
, sizeof(line_block
));
482 #if LCD_PIXELFORMAT == HORIZONTAL_PACKING
483 for (by
= LCD_FBHEIGHT
- 1; by
>= 0; by
--)
485 unsigned char *src
= &lcd_framebuffer
[by
][0];
486 unsigned char *dst
= line_block
;
488 memset(line_block
, 0, sizeof(line_block
));
489 for (bx
= LCD_FBWIDTH
; bx
> 0; bx
--)
491 unsigned src_byte
= *src
++;
493 *dst
++ = ((src_byte
>> 2) & 0x30) | ((src_byte
>> 4) & 0x03);
494 *dst
++ = ((src_byte
<< 2) & 0x30) | (src_byte
& 0x03);
497 write(fh
, line_block
, sizeof(line_block
));
499 #else /* VERTICAL_PACKING */
500 for (by
= LCD_FBHEIGHT
- 1; by
>= 0; by
--)
502 unsigned char *src
= &lcd_framebuffer
[by
][0];
503 unsigned char *dst
= &line_block
[3][0];
505 memset(line_block
, 0, sizeof(line_block
));
506 for (bx
= LCD_WIDTH
/2; bx
> 0; bx
--)
508 unsigned char *dst_blk
= dst
++;
509 unsigned src_byte0
= *src
++;
510 unsigned src_byte1
= *src
++;
513 for (iy
= 4; iy
> 0; iy
--)
515 *dst_blk
= ((src_byte0
& 3) << 4) | (src_byte1
& 3);
518 dst_blk
-= BMP_LINESIZE
;
522 write(fh
, line_block
, sizeof(line_block
));
525 #elif LCD_DEPTH == 16
526 for (by
= LCD_HEIGHT
- 1; by
>= 0; by
--)
528 unsigned short *src
= &lcd_framebuffer
[by
][0];
529 unsigned short *dst
= line_block
;
531 memset(line_block
, 0, sizeof(line_block
));
532 for (bx
= LCD_WIDTH
; bx
> 0; bx
--)
534 #if (LCD_PIXELFORMAT == RGB565SWAPPED)
535 /* iPod LCD data is big endian although the CPU is not */
536 *dst
++ = htobe16(*src
++);
538 *dst
++ = htole16(*src
++);
542 write(fh
, line_block
, sizeof(line_block
));
544 #endif /* LCD_DEPTH */
550 void screen_dump_set_hook(void (*hook
)(int fh
))
552 screen_dump_hook
= hook
;
555 #endif /* HAVE_LCD_BITMAP */
557 /* parse a line from a configuration file. the line format is:
561 Any whitespace before setting name or value (after ':') is ignored.
562 A # as first non-whitespace character discards the whole line.
563 Function sets pointers to null-terminated setting name and value.
564 Returns false if no valid config entry was found.
567 bool settings_parseline(char* line
, char** name
, char** value
)
571 while ( isspace(*line
) )
577 ptr
= strchr(line
, ':');
584 while (isspace(*ptr
))
590 static void system_flush(void)
593 call_ata_idle_notifys(true); /*doesnt work on usb and shutdown from ata thread */
596 static void system_restore(void)
601 static bool clean_shutdown(void (*callback
)(void *), void *parameter
)
606 bookmark_autobookmark();
607 call_ata_idle_notifys(true);
613 scrobbler_poweroff();
615 #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
616 if(!charger_inserted())
619 bool batt_safe
= battery_level_safe();
620 int audio_stat
= audio_status();
623 screens
[i
].clear_display();
628 if (!tagcache_prepare_shutdown())
631 gui_syncsplash(HZ
, ID2P(LANG_TAGCACHE_BUSY
));
635 if (battery_level() > 10)
636 gui_syncsplash(0, str(LANG_SHUTTINGDOWN
));
639 msg_id
= LANG_WARNING_BATTERY_LOW
;
640 gui_syncsplash(0, "%s %s",
641 str(LANG_WARNING_BATTERY_LOW
),
642 str(LANG_SHUTTINGDOWN
));
647 msg_id
= LANG_WARNING_BATTERY_EMPTY
;
648 gui_syncsplash(0, "%s %s",
649 str(LANG_WARNING_BATTERY_EMPTY
),
650 str(LANG_SHUTTINGDOWN
));
653 if (global_settings
.fade_on_stop
654 && (audio_stat
& AUDIO_STATUS_PLAY
))
659 if (batt_safe
) /* do not save on critical battery */
661 #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
662 if (audio_stat
& AUDIO_STATUS_RECORD
)
664 rec_command(RECORDING_CMD_STOP
);
665 /* wait for stop to complete */
666 while (audio_status() & AUDIO_STATUS_RECORD
)
670 bookmark_autobookmark();
672 /* audio_stop_recording == audio_stop for HWCODEC */
675 if (callback
!= NULL
)
678 #if CONFIG_CODEC != SWCODEC
679 /* wait for audio_stop or audio_stop_recording to complete */
680 while (audio_status())
684 #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
685 audio_close_recording();
688 if(global_settings
.talk_menu
)
690 bool enqueue
= false;
693 talk_id(msg_id
, enqueue
);
696 talk_id(LANG_SHUTTINGDOWN
, enqueue
);
697 #if CONFIG_CODEC == SWCODEC
703 #ifdef HAVE_EEPROM_SETTINGS
704 if (firmware_settings
.initialized
)
706 firmware_settings
.disk_clean
= true;
707 firmware_settings
.bl_version
= 0;
708 eeprom_settings_store();
723 bool list_stop_handler(void)
727 /* Stop the music if it is playing */
730 if (!global_settings
.party_mode
)
732 if (global_settings
.fade_on_stop
)
734 bookmark_autobookmark();
736 ret
= true; /* bookmarking can make a refresh necessary */
740 #if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
743 if (charger_inserted())
746 shutdown_screen(); /* won't return if shutdown actually happens */
748 ret
= true; /* screen is dirty, caller needs to refresh */
751 #ifndef HAVE_POWEROFF_WHILE_CHARGING
753 static long last_off
= 0;
755 if (TIME_BEFORE(current_tick
, last_off
+ HZ
/2))
757 if (charger_inserted())
760 ret
= true; /* screen is dirty, caller needs to refresh */
763 last_off
= current_tick
;
766 #endif /* CONFIG_CHARGING */
771 static bool waiting_to_resume_play
= false;
772 static long play_resume_tick
;
774 static void car_adapter_mode_processing(bool inserted
)
776 if (global_settings
.car_adapter_mode
)
781 * Just got plugged in, delay & resume if we were playing
783 if (audio_status() & AUDIO_STATUS_PAUSE
)
785 /* delay resume a bit while the engine is cranking */
786 play_resume_tick
= current_tick
+ HZ
*5;
787 waiting_to_resume_play
= true;
793 * Just got unplugged, pause if playing
795 if ((audio_status() & AUDIO_STATUS_PLAY
) &&
796 !(audio_status() & AUDIO_STATUS_PAUSE
))
798 if (global_settings
.fade_on_stop
)
803 waiting_to_resume_play
= false;
808 static void car_adapter_tick(void)
810 if (waiting_to_resume_play
)
812 if (TIME_AFTER(current_tick
, play_resume_tick
))
814 if (audio_status() & AUDIO_STATUS_PAUSE
)
816 queue_broadcast(SYS_CAR_ADAPTER_RESUME
, 0);
818 waiting_to_resume_play
= false;
823 void car_adapter_mode_init(void)
825 tick_add_task(car_adapter_tick
);
829 #ifdef HAVE_HEADPHONE_DETECTION
830 static void unplug_change(bool inserted
)
832 if (global_settings
.unplug_mode
)
836 if ( global_settings
.unplug_mode
> 1 )
842 if (global_settings
.unplug_rw
)
844 if ( audio_current_track()->elapsed
>
845 (unsigned long)(global_settings
.unplug_rw
*1000))
846 audio_ff_rewind(audio_current_track()->elapsed
-
847 (global_settings
.unplug_rw
*1000));
856 long default_event_handler_ex(long event
, void (*callback
)(void *), void *parameter
)
860 case SYS_USB_CONNECTED
:
861 if (callback
!= NULL
)
864 if (!mmc_touched() ||
865 (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED
))
868 scrobbler_flush_cache();
871 #if !defined(USB_NONE) && !defined(USB_IPODSTYLE)
872 check_bootfile(false); /* gets initial size */
877 #if !defined(USB_NONE) && !defined(USB_IPODSTYLE)
878 check_bootfile(true);
883 return SYS_USB_CONNECTED
;
885 if (!clean_shutdown(callback
, parameter
))
889 case SYS_CHARGER_CONNECTED
:
890 car_adapter_mode_processing(true);
891 return SYS_CHARGER_CONNECTED
;
893 case SYS_CHARGER_DISCONNECTED
:
894 car_adapter_mode_processing(false);
895 return SYS_CHARGER_DISCONNECTED
;
897 case SYS_CAR_ADAPTER_RESUME
:
899 return SYS_CAR_ADAPTER_RESUME
;
901 #ifdef HAVE_HEADPHONE_DETECTION
902 case SYS_PHONE_PLUGGED
:
904 return SYS_PHONE_PLUGGED
;
906 case SYS_PHONE_UNPLUGGED
:
907 unplug_change(false);
908 return SYS_PHONE_UNPLUGGED
;
914 long default_event_handler(long event
)
916 return default_event_handler_ex(event
, NULL
, NULL
);
919 int show_logo( void )
921 #ifdef HAVE_LCD_BITMAP
925 snprintf(version
, sizeof(version
), "Ver. %s", appsversion
);
928 lcd_bitmap(rockboxlogo
, 0, 10, BMPWIDTH_rockboxlogo
, BMPHEIGHT_rockboxlogo
);
929 lcd_setfont(FONT_SYSFIXED
);
930 lcd_getstringsize((unsigned char *)"A", &font_w
, &font_h
);
931 lcd_putsxy((LCD_WIDTH
/2) - ((strlen(version
)*font_w
)/2),
932 LCD_HEIGHT
-font_h
, (unsigned char *)version
);
933 lcd_setfont(FONT_UI
);
936 char *rockbox
= " ROCKbox!";
939 lcd_double_height(true);
940 lcd_puts(0, 0, rockbox
);
941 lcd_puts_scroll(0, 1, appsversion
);
945 #ifdef HAVE_REMOTE_LCD
946 lcd_remote_clear_display();
947 lcd_remote_bitmap(remote_rockboxlogo
, 0, 10, BMPWIDTH_remote_rockboxlogo
,
948 BMPHEIGHT_remote_rockboxlogo
);
949 lcd_remote_setfont(FONT_SYSFIXED
);
950 lcd_remote_getstringsize((unsigned char *)"A", &font_w
, &font_h
);
951 lcd_remote_putsxy((LCD_REMOTE_WIDTH
/2) - ((strlen(version
)*font_w
)/2),
952 LCD_REMOTE_HEIGHT
-font_h
, (unsigned char *)version
);
953 lcd_remote_setfont(FONT_UI
);
960 #if CONFIG_CODEC == SWCODEC
961 int get_replaygain_mode(bool have_track_gain
, bool have_album_gain
)
965 bool track
= ((global_settings
.replaygain_type
== REPLAYGAIN_TRACK
)
966 || ((global_settings
.replaygain_type
== REPLAYGAIN_SHUFFLE
)
967 && global_settings
.playlist_shuffle
));
969 type
= (!track
&& have_album_gain
) ? REPLAYGAIN_ALBUM
970 : have_track_gain
? REPLAYGAIN_TRACK
: -1;
977 #if !defined(USB_NONE) && !defined(USB_IPODSTYLE)
979 memorize/compare details about the BOOTFILE
980 we don't use dircache because it may not be up to date after
981 USB disconnect (scanning in the background)
983 void check_bootfile(bool do_rolo
)
985 static unsigned short wrtdate
= 0;
986 static unsigned short wrttime
= 0;
988 struct dirent
* entry
= NULL
;
990 /* 1. open BOOTDIR and find the BOOTFILE dir entry */
991 dir
= opendir(BOOTDIR
);
993 if(!dir
) return; /* do we want an error splash? */
995 /* loop all files in BOOTDIR */
996 while(0 != (entry
= readdir(dir
)))
998 if(!strcasecmp(entry
->d_name
, BOOTFILE
))
1000 /* found the bootfile */
1001 if(wrtdate
&& do_rolo
)
1003 if((entry
->wrtdate
!= wrtdate
) ||
1004 (entry
->wrttime
!= wrttime
))
1006 char *lines
[] = { ID2P(LANG_BOOT_CHANGED
),
1007 ID2P(LANG_REBOOT_NOW
) };
1008 struct text_message message
={ lines
, 2 };
1009 button_clear_queue(); /* Empty the keyboard buffer */
1010 if(gui_syncyesno_run(&message
, NULL
, NULL
) == YESNO_YES
)
1011 rolo_load(BOOTDIR
"/" BOOTFILE
);
1014 wrtdate
= entry
->wrtdate
;
1015 wrttime
= entry
->wrttime
;
1023 /* check range, set volume and save settings */
1026 const int min_vol
= sound_min(SOUND_VOLUME
);
1027 const int max_vol
= sound_max(SOUND_VOLUME
);
1028 if (global_settings
.volume
< min_vol
)
1029 global_settings
.volume
= min_vol
;
1030 if (global_settings
.volume
> max_vol
)
1031 global_settings
.volume
= max_vol
;
1032 sound_set_volume(global_settings
.volume
);
1036 #ifdef HAVE_LCD_COLOR
1038 * Helper function to convert a string of 6 hex digits to a native colour
1041 #define hex2dec(c) (((c) >= '0' && ((c) <= '9')) ? (toupper(c)) - '0' : \
1042 (toupper(c)) - 'A' + 10)
1044 int hex_to_rgb(const char* hex
)
1047 int red
, green
, blue
;
1049 if (strlen(hex
) == 6) {
1050 for (i
=0; i
< 6; i
++ ) {
1051 if (!isxdigit(hex
[i
])) {
1058 red
= (hex2dec(hex
[0]) << 4) | hex2dec(hex
[1]);
1059 green
= (hex2dec(hex
[2]) << 4) | hex2dec(hex
[3]);
1060 blue
= (hex2dec(hex
[4]) << 4) | hex2dec(hex
[5]);
1061 return LCD_RGBPACK(red
,green
,blue
);
1067 #endif /* HAVE_LCD_COLOR */