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"
38 #include "timefuncs.h"
40 #include "usb_screen.h"
43 #include "mp3_playback.h"
46 #include "ata_idle_notify.h"
49 #include "powermgmt.h"
50 #include "backlight.h"
55 #include "scrobbler.h"
67 #ifdef IPOD_ACCESSORY_PROTOCOL
71 #if (CONFIG_STORAGE & STORAGE_MMC)
75 #include "eeprom_settings.h"
76 #if defined(HAVE_RECORDING) && !defined(__PCTOOL__)
77 #include "recording.h"
79 #if defined(HAVE_LCD_BITMAP) && !defined(__PCTOOL__)
82 #endif /* End HAVE_LCD_BITMAP */
86 #if CONFIG_CODEC == SWCODEC
87 #include "voice_thread.h"
91 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) \
92 || defined(HAVE_HOTSWAP_STORAGE_AS_MAIN)
97 /* units used with output_dyn_value */
98 const unsigned char * const byte_units
[] =
106 const unsigned char * const * const kbyte_units
= &byte_units
[1];
108 /* Format a large-range value for output, using the appropriate unit so that
109 * the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
110 * units) if possible, and 3 significant digits are shown. If a buffer is
111 * given, the result is snprintf()'d into that buffer, otherwise the result is
113 char *output_dyn_value(char *buf
, int buf_size
, int value
,
114 const unsigned char * const *units
, bool bin_scale
)
116 int scale
= bin_scale
? 1024 : 1000;
121 while (value
>= scale
)
123 fraction
= value
% scale
;
128 fraction
= fraction
* 1000 / 1024;
130 if (value
>= 100 || !unit_no
)
132 else if (value
>= 10)
133 snprintf(tbuf
, sizeof(tbuf
), "%01d", fraction
/ 100);
135 snprintf(tbuf
, sizeof(tbuf
), "%02d", fraction
/ 10);
140 snprintf(buf
, buf_size
, "%d%s%s%s", value
, str(LANG_POINT
),
141 tbuf
, P2STR(units
[unit_no
]));
143 snprintf(buf
, buf_size
, "%d%s", value
, P2STR(units
[unit_no
]));
147 talk_fractional(tbuf
, value
, P2ID(units
[unit_no
]));
152 /* Ask the user if they really want to erase the current dynamic playlist
153 * returns true if the playlist should be replaced */
154 bool warn_on_pl_erase(void)
156 if (global_settings
.warnon_erase_dynplaylist
&&
157 !global_settings
.party_mode
&&
158 playlist_modified(NULL
))
160 static const char *lines
[] =
161 {ID2P(LANG_WARN_ERASEDYNPLAYLIST_PROMPT
)};
162 static const struct text_message message
={lines
, 1};
164 return (gui_syncyesno_run(&message
, NULL
, NULL
) == YESNO_YES
);
171 /* Performance optimized version of the read_line() (see below) function. */
172 int fast_readline(int fd
, char *buf
, int buf_size
, void *parameters
,
173 int (*callback
)(int n
, char *buf
, void *parameters
))
183 rc
= read(fd
, &buf
[pos
], buf_size
- pos
- 1);
187 if ( (p
= strchr(buf
, '\n')) != NULL
)
193 rc
= callback(count
, buf
, parameters
);
200 pos
= buf_size
- ((long)next
- (long)buf
) - 1;
201 memmove(buf
, next
, pos
);
210 /* parse a line from a configuration file. the line format is:
214 Any whitespace before setting name or value (after ':') is ignored.
215 A # as first non-whitespace character discards the whole line.
216 Function sets pointers to null-terminated setting name and value.
217 Returns false if no valid config entry was found.
220 bool settings_parseline(char* line
, char** name
, char** value
)
224 line
= skip_whitespace(line
);
229 ptr
= strchr(line
, ':');
236 ptr
= skip_whitespace(ptr
);
241 static void system_flush(void)
243 scrobbler_shutdown();
246 call_storage_idle_notifys(true); /*doesnt work on usb and shutdown from ata thread */
249 static void system_restore(void)
255 static bool clean_shutdown(void (*callback
)(void *), void *parameter
)
260 scrobbler_poweroff();
262 #if CONFIG_CHARGING && !defined(HAVE_POWEROFF_WHILE_CHARGING)
263 if(!charger_inserted())
266 bool batt_safe
= battery_level_safe();
267 #if CONFIG_CODEC != SWCODEC || defined(HAVE_RECORDING)
268 int audio_stat
= audio_status();
273 screens
[i
].clear_display();
280 if (!tagcache_prepare_shutdown())
283 splash(HZ
, ID2P(LANG_TAGCACHE_BUSY
));
287 if (battery_level() > 10)
288 splash(0, str(LANG_SHUTTINGDOWN
));
291 msg_id
= LANG_WARNING_BATTERY_LOW
;
292 splashf(0, "%s %s", str(LANG_WARNING_BATTERY_LOW
),
293 str(LANG_SHUTTINGDOWN
));
298 msg_id
= LANG_WARNING_BATTERY_EMPTY
;
299 splashf(0, "%s %s", str(LANG_WARNING_BATTERY_EMPTY
),
300 str(LANG_SHUTTINGDOWN
));
302 #if CONFIG_CODEC != SWCODEC
303 if (global_settings
.fade_on_stop
304 && (audio_stat
& AUDIO_STATUS_PLAY
))
310 if (batt_safe
) /* do not save on critical battery */
312 #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
313 if (audio_stat
& AUDIO_STATUS_RECORD
)
315 rec_command(RECORDING_CMD_STOP
);
316 /* wait for stop to complete */
317 while (audio_status() & AUDIO_STATUS_RECORD
)
321 bookmark_autobookmark(false);
323 /* audio_stop_recording == audio_stop for HWCODEC */
326 if (callback
!= NULL
)
329 #if CONFIG_CODEC != SWCODEC
330 /* wait for audio_stop or audio_stop_recording to complete */
331 while (audio_status())
335 #if defined(HAVE_RECORDING) && CONFIG_CODEC == SWCODEC
336 audio_close_recording();
339 if(global_settings
.talk_menu
)
341 bool enqueue
= false;
344 talk_id(msg_id
, enqueue
);
347 talk_id(LANG_SHUTTINGDOWN
, enqueue
);
348 #if CONFIG_CODEC == SWCODEC
354 #ifdef HAVE_EEPROM_SETTINGS
355 if (firmware_settings
.initialized
)
357 firmware_settings
.disk_clean
= true;
358 firmware_settings
.bl_version
= 0;
359 eeprom_settings_store();
373 bool list_stop_handler(void)
381 /* Stop the music if it is playing */
384 if (!global_settings
.party_mode
)
386 #if CONFIG_CODEC != SWCODEC
387 if (global_settings
.fade_on_stop
)
390 bookmark_autobookmark(true);
392 ret
= true; /* bookmarking can make a refresh necessary */
396 #if (CONFIG_KEYPAD == RECORDER_PAD) && !defined(HAVE_SW_POWEROFF)
399 if (charger_inserted())
402 shutdown_screen(); /* won't return if shutdown actually happens */
404 ret
= true; /* screen is dirty, caller needs to refresh */
407 #ifndef HAVE_POWEROFF_WHILE_CHARGING
409 static long last_off
= 0;
411 if (TIME_BEFORE(current_tick
, last_off
+ HZ
/2))
413 if (charger_inserted())
416 ret
= true; /* screen is dirty, caller needs to refresh */
419 last_off
= current_tick
;
422 #endif /* CONFIG_CHARGING */
427 static bool waiting_to_resume_play
= false;
428 static long play_resume_tick
;
430 static void car_adapter_mode_processing(bool inserted
)
432 if (global_settings
.car_adapter_mode
)
437 * Just got plugged in, delay & resume if we were playing
439 if (audio_status() & AUDIO_STATUS_PAUSE
)
441 /* delay resume a bit while the engine is cranking */
442 play_resume_tick
= current_tick
+ HZ
*5;
443 waiting_to_resume_play
= true;
449 * Just got unplugged, pause if playing
451 if ((audio_status() & AUDIO_STATUS_PLAY
) &&
452 !(audio_status() & AUDIO_STATUS_PAUSE
))
454 pause_action(true, true);
456 waiting_to_resume_play
= false;
461 static void car_adapter_tick(void)
463 if (waiting_to_resume_play
)
465 if (TIME_AFTER(current_tick
, play_resume_tick
))
467 if (audio_status() & AUDIO_STATUS_PAUSE
)
469 queue_broadcast(SYS_CAR_ADAPTER_RESUME
, 0);
471 waiting_to_resume_play
= false;
476 void car_adapter_mode_init(void)
478 tick_add_task(car_adapter_tick
);
482 #ifdef HAVE_HEADPHONE_DETECTION
483 static void unplug_change(bool inserted
)
485 static bool headphone_caused_pause
= false;
487 if (global_settings
.unplug_mode
)
489 int audio_stat
= audio_status();
493 if ((audio_stat
& AUDIO_STATUS_PLAY
) &&
494 headphone_caused_pause
&&
495 global_settings
.unplug_mode
> 1 )
496 unpause_action(true, true);
497 headphone_caused_pause
= false;
499 if ((audio_stat
& AUDIO_STATUS_PLAY
) &&
500 !(audio_stat
& AUDIO_STATUS_PAUSE
))
502 headphone_caused_pause
= true;
503 pause_action(false, false);
510 long default_event_handler_ex(long event
, void (*callback
)(void *), void *parameter
)
512 #if CONFIG_PLATFORM & (PLATFORM_ANDROID|PLATFORM_MAEMO)
513 static bool resume
= false;
518 case SYS_BATTERY_UPDATE
:
519 if(global_settings
.talk_battery_level
)
521 talk_ids(true, VOICE_PAUSE
, VOICE_PAUSE
,
523 TALK_ID(battery_level(), UNIT_PERCENT
),
525 talk_force_enqueue_next();
528 case SYS_USB_CONNECTED
:
529 if (callback
!= NULL
)
531 #if (CONFIG_STORAGE & STORAGE_MMC) && (defined(ARCHOS_ONDIOSP) || defined(ARCHOS_ONDIOFM))
532 if (!mmc_touched() ||
533 (mmc_remove_request() == SYS_HOTSWAP_EXTRACTED
))
538 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF)
539 check_bootfile(false); /* gets initial size */
542 gui_usb_screen_run(false);
544 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF)
545 check_bootfile(true);
550 return SYS_USB_CONNECTED
;
553 if (!clean_shutdown(callback
, parameter
))
557 case SYS_CHARGER_CONNECTED
:
558 car_adapter_mode_processing(true);
559 return SYS_CHARGER_CONNECTED
;
561 case SYS_CHARGER_DISCONNECTED
:
562 car_adapter_mode_processing(false);
563 /*reset rockbox battery runtime*/
564 global_status
.runtime
= 0;
565 return SYS_CHARGER_DISCONNECTED
;
567 case SYS_CAR_ADAPTER_RESUME
:
568 unpause_action(true, true);
569 return SYS_CAR_ADAPTER_RESUME
;
571 #ifdef HAVE_HOTSWAP_STORAGE_AS_MAIN
574 /* simple sanity: assume rockbox is on the first hotswappable
575 * driver, abort out if that one isn't inserted */
577 for (i
= 0; i
< NUM_DRIVES
; i
++)
579 if (storage_removable(i
) && !storage_present(i
))
580 return SYS_FS_CHANGED
;
583 check_bootfile(true); /* state gotten in main.c:init() */
586 return SYS_FS_CHANGED
;
588 #ifdef HAVE_HEADPHONE_DETECTION
589 case SYS_PHONE_PLUGGED
:
591 return SYS_PHONE_PLUGGED
;
593 case SYS_PHONE_UNPLUGGED
:
594 unplug_change(false);
595 return SYS_PHONE_UNPLUGGED
;
597 #ifdef IPOD_ACCESSORY_PROTOCOL
598 case SYS_IAP_PERIODIC
:
600 return SYS_IAP_PERIODIC
;
601 case SYS_IAP_HANDLEPKT
:
603 return SYS_IAP_HANDLEPKT
;
605 #if CONFIG_PLATFORM & (PLATFORM_ANDROID|PLATFORM_MAEMO)
606 /* stop playback if we receive a call */
607 case SYS_CALL_INCOMING
:
608 resume
= audio_status() == AUDIO_STATUS_PLAY
;
610 return SYS_CALL_INCOMING
;
611 /* resume playback if needed */
612 case SYS_CALL_HUNG_UP
:
613 if (resume
&& playlist_resume() != -1)
615 playlist_start(global_status
.resume_index
,
616 global_status
.resume_offset
);
619 return SYS_CALL_HUNG_UP
;
621 #if (CONFIG_PLATFORM & PLATFORM_HOSTED) && defined(PLATFORM_HAS_VOLUME_CHANGE)
622 case SYS_VOLUME_CHANGED
:
624 static bool firstvolume
= true;
625 /* kludge: since this events go to the button_queue,
626 * event data is available in the last button data */
627 int volume
= button_get_data();
628 DEBUGF("SYS_VOLUME_CHANGED: %d\n", volume
);
629 if (global_settings
.volume
!= volume
) {
630 global_settings
.volume
= volume
;
639 #ifdef HAVE_MULTIMEDIA_KEYS
640 /* multimedia keys on keyboards, headsets */
641 case BUTTON_MULTIMEDIA_PLAYPAUSE
:
643 int status
= audio_status();
644 if (status
& AUDIO_STATUS_PLAY
)
646 if (status
& AUDIO_STATUS_PAUSE
)
647 unpause_action(true, true);
649 pause_action(true, true);
652 if (playlist_resume() != -1)
654 playlist_start(global_status
.resume_index
,
655 global_status
.resume_offset
);
659 case BUTTON_MULTIMEDIA_NEXT
:
662 case BUTTON_MULTIMEDIA_PREV
:
665 case BUTTON_MULTIMEDIA_STOP
:
668 case BUTTON_MULTIMEDIA_REW
:
669 case BUTTON_MULTIMEDIA_FFWD
:
670 /* not supported yet, needs to be done in the WPS */
677 long default_event_handler(long event
)
679 return default_event_handler_ex(event
, NULL
, NULL
);
682 int show_logo( void )
684 #ifdef HAVE_LCD_BITMAP
688 snprintf(version
, sizeof(version
), "Ver. %s", rbversion
);
691 #if defined(SANSA_CLIP) || defined(SANSA_CLIPV2) || defined(SANSA_CLIPPLUS)
692 /* display the logo in the blue area of the screen */
693 lcd_setfont(FONT_SYSFIXED
);
694 lcd_getstringsize((unsigned char *)"A", &font_w
, &font_h
);
695 lcd_putsxy((LCD_WIDTH
/2) - ((strlen(version
)*font_w
)/2),
696 0, (unsigned char *)version
);
697 lcd_bitmap(rockboxlogo
, (LCD_WIDTH
- BMPWIDTH_rockboxlogo
) / 2, 16,
698 BMPWIDTH_rockboxlogo
, BMPHEIGHT_rockboxlogo
);
700 lcd_bitmap(rockboxlogo
, (LCD_WIDTH
- BMPWIDTH_rockboxlogo
) / 2, 10,
701 BMPWIDTH_rockboxlogo
, BMPHEIGHT_rockboxlogo
);
702 lcd_setfont(FONT_SYSFIXED
);
703 lcd_getstringsize((unsigned char *)"A", &font_w
, &font_h
);
704 lcd_putsxy((LCD_WIDTH
/2) - ((strlen(version
)*font_w
)/2),
705 LCD_HEIGHT
-font_h
, (unsigned char *)version
);
707 lcd_setfont(FONT_UI
);
710 char *rockbox
= " ROCKbox!";
713 lcd_double_height(true);
714 lcd_puts(0, 0, rockbox
);
715 lcd_puts_scroll(0, 1, rbversion
);
719 #ifdef HAVE_REMOTE_LCD
720 lcd_remote_clear_display();
721 lcd_remote_bitmap(remote_rockboxlogo
, 0, 10, BMPWIDTH_remote_rockboxlogo
,
722 BMPHEIGHT_remote_rockboxlogo
);
723 lcd_remote_setfont(FONT_SYSFIXED
);
724 lcd_remote_getstringsize((unsigned char *)"A", &font_w
, &font_h
);
725 lcd_remote_putsxy((LCD_REMOTE_WIDTH
/2) - ((strlen(version
)*font_w
)/2),
726 LCD_REMOTE_HEIGHT
-font_h
, (unsigned char *)version
);
727 lcd_remote_setfont(FONT_UI
);
735 #if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) || defined(HAVE_HOTSWAP_STORAGE_AS_MAIN)
737 memorize/compare details about the BOOTFILE
738 we don't use dircache because it may not be up to date after
739 USB disconnect (scanning in the background)
741 void check_bootfile(bool do_rolo
)
743 static unsigned short wrtdate
= 0;
744 static unsigned short wrttime
= 0;
746 struct dirent
* entry
= NULL
;
748 /* 1. open BOOTDIR and find the BOOTFILE dir entry */
749 dir
= opendir(BOOTDIR
);
751 if(!dir
) return; /* do we want an error splash? */
753 /* loop all files in BOOTDIR */
754 while(0 != (entry
= readdir(dir
)))
756 if(!strcasecmp(entry
->d_name
, BOOTFILE
))
758 struct dirinfo info
= dir_get_info(dir
, entry
);
759 /* found the bootfile */
760 if(wrtdate
&& do_rolo
)
762 if((info
.wrtdate
!= wrtdate
) ||
763 (info
.wrttime
!= wrttime
))
765 static const char *lines
[] = { ID2P(LANG_BOOT_CHANGED
),
766 ID2P(LANG_REBOOT_NOW
) };
767 static const struct text_message message
={ lines
, 2 };
768 button_clear_queue(); /* Empty the keyboard buffer */
769 if(gui_syncyesno_run(&message
, NULL
, NULL
) == YESNO_YES
)
770 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];