1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 by Daniel 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 ****************************************************************************/
26 #include "string-extra.h"
32 #include "filefuncs.h"
36 #include "lcd-remote.h"
37 #include "timefuncs.h"
39 #include "usb_screen.h"
42 #include "mp3_playback.h"
45 #include "ata_idle_notify.h"
48 #include "powermgmt.h"
49 #include "backlight.h"
54 #include "scrobbler.h"
66 #ifdef IPOD_ACCESSORY_PROTOCOL
70 #if (CONFIG_STORAGE & STORAGE_MMC)
74 #include "eeprom_settings.h"
75 #if defined(HAVE_RECORDING) && !defined(__PCTOOL__)
76 #include "recording.h"
78 #if defined(HAVE_LCD_BITMAP) && !defined(__PCTOOL__)
81 #endif /* End HAVE_LCD_BITMAP */
85 #if CONFIG_CODEC == SWCODEC
86 #include "voice_thread.h"
90 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) \
91 || defined(HAVE_HOTSWAP_STORAGE_AS_MAIN)
96 /* units used with output_dyn_value */
97 const unsigned char * const byte_units
[] =
105 const unsigned char * const * const kbyte_units
= &byte_units
[1];
107 /* Format a large-range value for output, using the appropriate unit so that
108 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
109 * units) if possible, and 3 significant digits are shown. If a buffer is
110 * given, the result is snprintf()'d into that buffer, otherwise the result is
112 char *output_dyn_value(char *buf
, int buf_size
, int value
,
113 const unsigned char * const *units
, bool bin_scale
)
115 int scale
= bin_scale
? 1024 : 1000;
120 while (value
>= scale
)
122 fraction
= value
% scale
;
127 fraction
= fraction
* 1000 / 1024;
129 if (value
>= 100 || !unit_no
)
131 else if (value
>= 10)
132 snprintf(tbuf
, sizeof(tbuf
), "%01d", fraction
/ 100);
134 snprintf(tbuf
, sizeof(tbuf
), "%02d", fraction
/ 10);
139 snprintf(buf
, buf_size
, "%d%s%s%s", value
, str(LANG_POINT
),
140 tbuf
, P2STR(units
[unit_no
]));
142 snprintf(buf
, buf_size
, "%d%s", value
, P2STR(units
[unit_no
]));
146 talk_fractional(tbuf
, value
, P2ID(units
[unit_no
]));
151 /* Ask the user if they really want to erase the current dynamic playlist
152 * returns true if the playlist should be replaced */
153 bool warn_on_pl_erase(void)
155 if (global_settings
.warnon_erase_dynplaylist
&&
156 !global_settings
.party_mode
&&
157 playlist_modified(NULL
))
159 static const char *lines
[] =
160 {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT
)};
161 static const struct text_message message
={lines
, 1};
163 return (gui_syncyesno_run(&message
, NULL
, NULL
) == YESNO_YES
);
170 /* Performance optimized version of the read_line() (see below) function. */
171 int fast_readline(int fd
, char *buf
, int buf_size
, void *parameters
,
172 int (*callback
)(int n
, char *buf
, void *parameters
))
182 rc
= read(fd
, &buf
[pos
], buf_size
- pos
- 1);
186 if ( (p
= strchr(buf
, '\n')) != NULL
)
192 rc
= callback(count
, buf
, parameters
);
199 pos
= buf_size
- ((long)next
- (long)buf
) - 1;
200 memmove(buf
, next
, pos
);
209 /* parse a line from a configuration file. the line format is:
213 Any whitespace before setting name or value (after ':') is ignored.
214 A # as first non-whitespace character discards the whole line.
215 Function sets pointers to null-terminated setting name and value.
216 Returns false if no valid config entry was found.
219 bool settings_parseline(char* line
, char** name
, char** value
)
223 line
= skip_whitespace(line
);
228 ptr
= strchr(line
, ':');
235 ptr
= skip_whitespace(ptr
);
240 static void system_flush(void)
244 call_storage_idle_notifys(true); /*doesnt work on usb and shutdown from ata thread */
247 static void system_restore(void)
252 static bool clean_shutdown(void (*callback
)(void *), void *parameter
)
257 scrobbler_poweroff();
259 #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
260 if(!charger_inserted())
263 bool batt_safe
= battery_level_safe();
264 #if CONFIG_CODEC != SWCODEC || defined(HAVE_RECORDING)
265 int audio_stat
= audio_status();
270 screens
[i
].clear_display();
277 if (!tagcache_prepare_shutdown())
280 splash(HZ
, ID2P(LANG_TAGCACHE_BUSY
));
284 if (battery_level() > 10)
285 splash(0, str(LANG_SHUTTINGDOWN
));
288 msg_id
= LANG_WARNING_BATTERY_LOW
;
289 splashf(0, "%s %s", str(LANG_WARNING_BATTERY_LOW
),
290 str(LANG_SHUTTINGDOWN
));
295 msg_id
= LANG_WARNING_BATTERY_EMPTY
;
296 splashf(0, "%s %s", str(LANG_WARNING_BATTERY_EMPTY
),
297 str(LANG_SHUTTINGDOWN
));
299 #if CONFIG_CODEC != SWCODEC
300 if (global_settings
.fade_on_stop
301 && (audio_stat
& AUDIO_STATUS_PLAY
))
307 if (batt_safe
) /* do not save on critical battery */
309 #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
310 if (audio_stat
& AUDIO_STATUS_RECORD
)
312 rec_command(RECORDING_CMD_STOP
);
313 /* wait for stop to complete */
314 while (audio_status() & AUDIO_STATUS_RECORD
)
318 bookmark_autobookmark(false);
320 /* audio_stop_recording == audio_stop for HWCODEC */
323 if (callback
!= NULL
)
326 #if CONFIG_CODEC != SWCODEC
327 /* wait for audio_stop or audio_stop_recording to complete */
328 while (audio_status())
332 #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
333 audio_close_recording();
336 if(global_settings
.talk_menu
)
338 bool enqueue
= false;
341 talk_id(msg_id
, enqueue
);
344 talk_id(LANG_SHUTTINGDOWN
, enqueue
);
345 #if CONFIG_CODEC == SWCODEC
351 #ifdef HAVE_EEPROM_SETTINGS
352 if (firmware_settings
.initialized
)
354 firmware_settings
.disk_clean
= true;
355 firmware_settings
.bl_version
= 0;
356 eeprom_settings_store();
370 bool list_stop_handler(void)
378 /* Stop the music if it is playing */
381 if (!global_settings
.party_mode
)
383 #if CONFIG_CODEC != SWCODEC
384 if (global_settings
.fade_on_stop
)
387 bookmark_autobookmark(true);
389 ret
= true; /* bookmarking can make a refresh necessary */
393 #if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
396 if (charger_inserted())
399 shutdown_screen(); /* won't return if shutdown actually happens */
401 ret
= true; /* screen is dirty, caller needs to refresh */
404 #ifndef HAVE_POWEROFF_WHILE_CHARGING
406 static long last_off
= 0;
408 if (TIME_BEFORE(current_tick
, last_off
+ HZ
/2))
410 if (charger_inserted())
413 ret
= true; /* screen is dirty, caller needs to refresh */
416 last_off
= current_tick
;
419 #endif /* CONFIG_CHARGING */
424 static bool waiting_to_resume_play
= false;
425 static long play_resume_tick
;
427 static void car_adapter_mode_processing(bool inserted
)
429 if (global_settings
.car_adapter_mode
)
434 * Just got plugged in, delay & resume if we were playing
436 if (audio_status() & AUDIO_STATUS_PAUSE
)
438 /* delay resume a bit while the engine is cranking */
439 play_resume_tick
= current_tick
+ HZ
*5;
440 waiting_to_resume_play
= true;
446 * Just got unplugged, pause if playing
448 if ((audio_status() & AUDIO_STATUS_PLAY
) &&
449 !(audio_status() & AUDIO_STATUS_PAUSE
))
451 pause_action(true, true);
453 waiting_to_resume_play
= false;
458 static void car_adapter_tick(void)
460 if (waiting_to_resume_play
)
462 if (TIME_AFTER(current_tick
, play_resume_tick
))
464 if (audio_status() & AUDIO_STATUS_PAUSE
)
466 queue_broadcast(SYS_CAR_ADAPTER_RESUME
, 0);
468 waiting_to_resume_play
= false;
473 void car_adapter_mode_init(void)
475 tick_add_task(car_adapter_tick
);
479 #ifdef HAVE_HEADPHONE_DETECTION
480 static void unplug_change(bool inserted
)
482 static bool headphone_caused_pause
= false;
484 if (global_settings
.unplug_mode
)
486 int audio_stat
= audio_status();
490 if ((audio_stat
& AUDIO_STATUS_PLAY
) &&
491 headphone_caused_pause
&&
492 global_settings
.unplug_mode
> 1 )
493 unpause_action(true, true);
494 headphone_caused_pause
= false;
496 if ((audio_stat
& AUDIO_STATUS_PLAY
) &&
497 !(audio_stat
& AUDIO_STATUS_PAUSE
))
499 headphone_caused_pause
= true;
500 pause_action(false, false);
507 long default_event_handler_ex(long event
, void (*callback
)(void *), void *parameter
)
509 #if CONFIG_PLATFORM & (PLATFORM_ANDROID|PLATFORM_MAEMO)
510 static bool resume
= false;
515 case SYS_BATTERY_UPDATE
:
516 if(global_settings
.talk_battery_level
)
518 talk_ids(true, VOICE_PAUSE
, VOICE_PAUSE
,
520 TALK_ID(battery_level(), UNIT_PERCENT
),
522 talk_force_enqueue_next();
525 case SYS_USB_CONNECTED
:
526 if (callback
!= NULL
)
528 #if (CONFIG_STORAGE & STORAGE_MMC) && (defined(ARCHOS_ONDIOSP) || defined(ARCHOS_ONDIOFM))
529 if (!mmc_touched() ||
530 (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED
))
535 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF)
536 check_bootfile(false); /* gets initial size */
539 gui_usb_screen_run(false);
541 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF)
542 check_bootfile(true);
547 return SYS_USB_CONNECTED
;
550 if (!clean_shutdown(callback
, parameter
))
554 case SYS_CHARGER_CONNECTED
:
555 car_adapter_mode_processing(true);
556 return SYS_CHARGER_CONNECTED
;
558 case SYS_CHARGER_DISCONNECTED
:
559 car_adapter_mode_processing(false);
560 /*reset rockbox battery runtime*/
561 global_status
.runtime
= 0;
562 return SYS_CHARGER_DISCONNECTED
;
564 case SYS_CAR_ADAPTER_RESUME
:
565 unpause_action(true, true);
566 return SYS_CAR_ADAPTER_RESUME
;
568 #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN
571 /* simple sanity: assume rockbox is on the first hotswappable
572 * driver, abort out if that one isn't inserted */
574 for (i
= 0; i
< NUM_DRIVES
; i
++)
576 if (storage_removable(i
) && !storage_present(i
))
577 return SYS_FS_CHANGED
;
580 check_bootfile(true); /* state gotten in main.c:init() */
583 return SYS_FS_CHANGED
;
585 #ifdef HAVE_HEADPHONE_DETECTION
586 case SYS_PHONE_PLUGGED
:
588 return SYS_PHONE_PLUGGED
;
590 case SYS_PHONE_UNPLUGGED
:
591 unplug_change(false);
592 return SYS_PHONE_UNPLUGGED
;
594 #ifdef IPOD_ACCESSORY_PROTOCOL
595 case SYS_IAP_PERIODIC
:
597 return SYS_IAP_PERIODIC
;
598 case SYS_IAP_HANDLEPKT
:
600 return SYS_IAP_HANDLEPKT
;
602 #if CONFIG_PLATFORM & (PLATFORM_ANDROID|PLATFORM_MAEMO)
603 /* stop playback if we receive a call */
604 case SYS_CALL_INCOMING
:
605 resume
= audio_status() == AUDIO_STATUS_PLAY
;
607 return SYS_CALL_INCOMING
;
608 /* resume playback if needed */
609 case SYS_CALL_HUNG_UP
:
610 if (resume
&& playlist_resume() != -1)
612 playlist_start(global_status
.resume_index
,
613 global_status
.resume_offset
);
616 return SYS_CALL_HUNG_UP
;
618 #if (CONFIG_PLATFORM & PLATFORM_HOSTED) && defined(PLATFORM_HAS_VOLUME_CHANGE)
619 case SYS_VOLUME_CHANGED
:
621 static bool firstvolume
= true;
622 /* kludge: since this events go to the button_queue,
623 * event data is available in the last button data */
624 int volume
= button_get_data();
625 DEBUGF("SYS_VOLUME_CHANGED: %d\n", volume
);
626 if (global_settings
.volume
!= volume
) {
627 global_settings
.volume
= volume
;
636 #ifdef HAVE_MULTIMEDIA_KEYS
637 /* multimedia keys on keyboards, headsets */
638 case BUTTON_MULTIMEDIA_PLAYPAUSE
:
640 int status
= audio_status();
641 if (status
& AUDIO_STATUS_PLAY
)
643 if (status
& AUDIO_STATUS_PAUSE
)
644 unpause_action(true, true);
646 pause_action(true, true);
649 if (playlist_resume() != -1)
651 playlist_start(global_status
.resume_index
,
652 global_status
.resume_offset
);
656 case BUTTON_MULTIMEDIA_NEXT
:
659 case BUTTON_MULTIMEDIA_PREV
:
662 case BUTTON_MULTIMEDIA_STOP
:
665 case BUTTON_MULTIMEDIA_REW
:
666 case BUTTON_MULTIMEDIA_FFWD
:
667 /* not supported yet, needs to be done in the WPS */
674 long default_event_handler(long event
)
676 return default_event_handler_ex(event
, NULL
, NULL
);
679 int show_logo( void )
681 #ifdef HAVE_LCD_BITMAP
685 snprintf(version
, sizeof(version
), "Ver. %s", rbversion
);
688 #if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS)
689 /* display the logo in the blue area of the screen */
690 lcd_setfont(FONT_SYSFIXED
);
691 lcd_getstringsize((unsigned char *)"A", &font_w
, &font_h
);
692 lcd_putsxy((LCD_WIDTH
/2) - ((strlen(version
)*font_w
)/2),
693 0, (unsigned char *)version
);
694 lcd_bitmap(rockboxlogo
, (LCD_WIDTH
- BMPWIDTH_rockboxlogo
) / 2, 16,
695 BMPWIDTH_rockboxlogo
, BMPHEIGHT_rockboxlogo
);
697 lcd_bitmap(rockboxlogo
, (LCD_WIDTH
- BMPWIDTH_rockboxlogo
) / 2, 10,
698 BMPWIDTH_rockboxlogo
, BMPHEIGHT_rockboxlogo
);
699 lcd_setfont(FONT_SYSFIXED
);
700 lcd_getstringsize((unsigned char *)"A", &font_w
, &font_h
);
701 lcd_putsxy((LCD_WIDTH
/2) - ((strlen(version
)*font_w
)/2),
702 LCD_HEIGHT
-font_h
, (unsigned char *)version
);
704 lcd_setfont(FONT_UI
);
707 char *rockbox
= " ROCKbox!";
710 lcd_double_height(true);
711 lcd_puts(0, 0, rockbox
);
712 lcd_puts_scroll(0, 1, rbversion
);
716 #ifdef HAVE_REMOTE_LCD
717 lcd_remote_clear_display();
718 lcd_remote_bitmap(remote_rockboxlogo
, 0, 10, BMPWIDTH_remote_rockboxlogo
,
719 BMPHEIGHT_remote_rockboxlogo
);
720 lcd_remote_setfont(FONT_SYSFIXED
);
721 lcd_remote_getstringsize((unsigned char *)"A", &font_w
, &font_h
);
722 lcd_remote_putsxy((LCD_REMOTE_WIDTH
/2) - ((strlen(version
)*font_w
)/2),
723 LCD_REMOTE_HEIGHT
-font_h
, (unsigned char *)version
);
724 lcd_remote_setfont(FONT_UI
);
732 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) || defined(HAVE_HOTSWAP_STORAGE_AS_MAIN)
734 memorize/compare details about the BOOTFILE
735 we don't use dircache because it may not be up to date after
736 USB disconnect (scanning in the background)
738 void check_bootfile(bool do_rolo
)
740 static unsigned short wrtdate
= 0;
741 static unsigned short wrttime
= 0;
743 struct dirent
* entry
= NULL
;
745 /* 1. open BOOTDIR and find the BOOTFILE dir entry */
746 dir
= opendir(BOOTDIR
);
748 if(!dir
) return; /* do we want an error splash? */
750 /* loop all files in BOOTDIR */
751 while(0 != (entry
= readdir(dir
)))
753 if(!strcasecmp(entry
->d_name
, BOOTFILE
))
755 struct dirinfo info
= dir_get_info(dir
, entry
);
756 /* found the bootfile */
757 if(wrtdate
&& do_rolo
)
759 if((info
.wrtdate
!= wrtdate
) ||
760 (info
.wrttime
!= wrttime
))
762 static const char *lines
[] = { ID2P(LANG_BOOT_CHANGED
),
763 ID2P(LANG_REBOOT_NOW
) };
764 static const struct text_message message
={ lines
, 2 };
765 button_clear_queue(); /* Empty the keyboard buffer */
766 if(gui_syncyesno_run(&message
, NULL
, NULL
) == YESNO_YES
)
769 rolo_load(BOOTDIR
"/" BOOTFILE
);
773 wrtdate
= info
.wrtdate
;
774 wrttime
= info
.wrttime
;
782 /* check range, set volume and save settings */
785 const int min_vol
= sound_min(SOUND_VOLUME
);
786 const int max_vol
= sound_max(SOUND_VOLUME
);
787 if (global_settings
.volume
< min_vol
)
788 global_settings
.volume
= min_vol
;
789 if (global_settings
.volume
> max_vol
)
790 global_settings
.volume
= max_vol
;
791 sound_set_volume(global_settings
.volume
);
792 global_status
.last_volume_change
= current_tick
;
796 char* strrsplt(char* str
, int c
)
798 char* s
= strrchr(str
, c
);
813 * removes the extension of filename (if it doesn't start with a .)
814 * puts the result in buffer
816 char *strip_extension(char* buffer
, int buffer_size
, const char *filename
)
818 char *dot
= strrchr(filename
, '.');
821 if (buffer_size
<= 0)
826 buffer_size
--; /* Make room for end nil */
828 if (dot
!= 0 && filename
[0] != '.')
830 len
= dot
- filename
;
831 len
= MIN(len
, buffer_size
);
838 strlcpy(buffer
, filename
, len
+ 1);
843 #if CONFIG_CODEC == SWCODEC
844 /* Play a standard sound */
845 void system_sound_play(enum system_sound sound
)
847 static const struct beep_params
850 unsigned short frequency
;
851 unsigned short duration
;
852 unsigned short amplitude
;
856 { &global_settings
.keyclick
,
857 4000, KEYCLICK_DURATION
, 2500 },
859 { &global_settings
.beep
,
861 [SOUND_TRACK_NO_MORE
] =
862 { &global_settings
.beep
,
866 const struct beep_params
*params
= &beep_params
[sound
];
868 if (*params
->setting
)
870 beep_play(params
->frequency
, params
->duration
,
871 params
->amplitude
* *params
->setting
);
875 /* Produce keyclick based upon button and global settings */
876 void keyclick_click(int button
)
878 /* Settings filters */
879 if (global_settings
.keyclick
&&
880 (global_settings
.keyclick_repeats
|| !(button
& BUTTON_REPEAT
)))
883 if (button
!= BUTTON_NONE
&& !(button
& BUTTON_REL
)
884 && !(button
& (SYS_EVENT
|BUTTON_MULTIMEDIA
)) )
886 system_sound_play(SOUND_KEYCLICK
);
890 #endif /* CONFIG_CODEC == SWCODEC */
892 #endif /* !defined(__PCTOOL__) */
894 /* Read (up to) a line of text from fd into buffer and return number of bytes
895 * read (which may be larger than the number of bytes stored in buffer). If
896 * an error occurs, -1 is returned (and buffer contains whatever could be
897 * read). A line is terminated by a LF char. Neither LF nor CR chars are
900 int read_line(int fd
, char* buffer
, int buffer_size
)
907 while (count
< buffer_size
)
911 if (1 != read(fd
, &c
, 1))
925 buffer
[MIN(count
, buffer_size
- 1)] = 0;
927 return errno
? -1 : num_read
;
931 char* skip_whitespace(char* const str
)
941 /* Format time into buf.
943 * buf - buffer to format to.
944 * buf_size - size of buffer.
945 * t - time to format, in milliseconds.
947 void format_time(char* buf
, int buf_size
, long t
)
949 int const time
= abs(t
/ 1000);
950 int const hours
= time
/ 3600;
951 int const minutes
= time
/ 60 - hours
* 60;
952 int const seconds
= time
% 60;
953 const char * const sign
= &"-"[t
< 0 ? 0 : 1];
957 snprintf(buf
, buf_size
, "%s%d:%02d", sign
, minutes
, seconds
);
961 snprintf(buf
, buf_size
, "%s%d:%02d:%02d", sign
, hours
, minutes
,
967 /** Open a UTF-8 file and set file descriptor to first byte after BOM.
968 * If no BOM is present this behaves like open().
969 * If the file is opened for writing and O_TRUNC is set, write a BOM to
970 * the opened file and leave the file pointer set after the BOM.
972 #define BOM "\xef\xbb\xbf"
975 int open_utf8(const char* pathname
, int flags
)
978 unsigned char bom
[BOM_SIZE
];
980 fd
= open(pathname
, flags
, 0666);
984 if(flags
& (O_TRUNC
| O_WRONLY
))
986 write(fd
, BOM
, BOM_SIZE
);
990 read(fd
, bom
, BOM_SIZE
);
992 if(memcmp(bom
, BOM
, BOM_SIZE
))
993 lseek(fd
, 0, SEEK_SET
);
999 #ifdef HAVE_LCD_COLOR
1001 * Helper function to convert a string of 6 hex digits to a native colour
1004 static int hex2dec(int c
)
1006 return (((c
) >= '0' && ((c
) <= '9')) ? (c
) - '0' :
1007 (toupper(c
)) - 'A' + 10);
1010 int hex_to_rgb(const char* hex
, int* color
)
1012 int red
, green
, blue
;
1015 while ((i
< 6) && (isxdigit(hex
[i
])))
1021 red
= (hex2dec(hex
[0]) << 4) | hex2dec(hex
[1]);
1022 green
= (hex2dec(hex
[2]) << 4) | hex2dec(hex
[3]);
1023 blue
= (hex2dec(hex
[4]) << 4) | hex2dec(hex
[5]);
1025 *color
= LCD_RGBPACK(red
,green
,blue
);
1029 #endif /* HAVE_LCD_COLOR */
1031 #ifdef HAVE_LCD_BITMAP
1032 /* '0'-'3' are ASCII 0x30 to 0x33 */
1033 #define is0123(x) (((x) & 0xfc) == 0x30)
1034 #if !defined(__PCTOOL__) || defined(CHECKWPS)
1035 bool parse_color(enum screen_type screen
, char *text
, int *value
)
1037 (void)text
; (void)value
; /* silence warnings on mono bitmap */
1040 #ifdef HAVE_LCD_COLOR
1041 if (screens
[screen
].depth
> 2)
1043 if (hex_to_rgb(text
, value
) < 0)
1050 #if LCD_DEPTH == 2 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2)
1051 if (screens
[screen
].depth
== 2)
1053 if (text
[1] != '\0' || !is0123(*text
))
1055 *value
= *text
- '0';
1061 #endif /* !defined(__PCTOOL__) || defined(CHECKWPS) */
1063 /* only used in USB HID and set_time screen */
1064 #if defined(USB_ENABLE_HID) || (CONFIG_RTC != 0)
1065 int clamp_value_wrap(int value
, int max
, int min
)
1075 #define MAX_ACTIVITY_DEPTH 12
1076 static enum current_activity
1077 current_activity
[MAX_ACTIVITY_DEPTH
] = {ACTIVITY_UNKNOWN
};
1078 static int current_activity_top
= 0;
1079 void push_current_activity(enum current_activity screen
)
1081 current_activity
[current_activity_top
++] = screen
;
1083 void pop_current_activity(void)
1085 current_activity_top
--;
1087 enum current_activity
get_current_activity(void)
1089 return current_activity
[current_activity_top
?current_activity_top
-1:0];