2002-11-22 13:00:10 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 by Daniel Stenberg
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2002-11-22 13:00:10 +00:00
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2004-07-05 11:15:50 +00:00
|
|
|
#ifndef MISC_H
|
|
|
|
#define MISC_H
|
2002-11-22 13:00:10 +00:00
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#include <stdbool.h>
|
2008-06-07 09:35:57 +00:00
|
|
|
#include <inttypes.h>
|
2009-01-29 21:05:13 +00:00
|
|
|
#include "config.h"
|
2010-08-10 14:15:03 +00:00
|
|
|
#include "screen_access.h"
|
2008-08-02 20:39:03 +00:00
|
|
|
|
2009-10-17 13:40:42 +00:00
|
|
|
extern const unsigned char * const byte_units[];
|
2018-12-09 18:09:40 +00:00
|
|
|
extern const unsigned char * const * const kibyte_units;
|
Auto-Ranging Time Formatting For Menus (hh:mm:ss:mss)
Unifies time formatting in settings_list.c allows time format to
display as HH:MM:SS.MSS or any consecutive combination thereof
(hh:mm:ss, mm:ss, mm:ss.mss, ss.mss, hh, mm, ss ,mss)
works in INT and TABLE settings with the addition of flag 'F_TIME_SETTING'
Time is auto-ranged dependent on value
Adds talk_time_intervals to allow time values to be spoken similar to
display format: x Hours, x Minutes, x Seconds, x Milliseconds
Table lookups merged or removed from recording, clip meter and lcd timeout
-String_Choice replaced with TABLE_SETTING or INT_SETTING for these
functions as well, cleaned-up cfg_vals that get saved to cfgfile
RTL Languages ARE supported
Negative values ARE supported
Backlight on/off are now Always and Never to share formatter with LCD
Timeout
Added flag to allow ranged units to be locked to a minimum index
Added flag to allow leading zero to be supressed from the largest unit
merged talk_time_unit() and talk_time_intervals()
optimized time_split()
optimized format_time_auto()
Backlight time-out list same as original
Change-Id: I59027c62d3f2956bd16fdcc1a48b2ac32c084abd
2018-12-18 04:27:55 +00:00
|
|
|
extern const unsigned char * const unit_strings_core[];
|
2005-01-31 00:39:20 +00:00
|
|
|
/* Format a large-range value for output, using the appropriate unit so that
|
|
|
|
* the displayed value is in the range 1 <= display < 1000 (1024 for "binary"
|
|
|
|
* units) if possible, and 3 significant digits are shown. If a buffer is
|
|
|
|
* given, the result is snprintf()'d into that buffer, otherwise the result is
|
|
|
|
* voiced.*/
|
2018-12-09 18:09:40 +00:00
|
|
|
char *output_dyn_value(char *buf,
|
|
|
|
int buf_size,
|
|
|
|
int value,
|
|
|
|
const unsigned char * const *units,
|
|
|
|
unsigned int unit_count,
|
|
|
|
bool binary_scale);
|
2003-05-04 02:04:31 +00:00
|
|
|
|
Auto-Ranging Time Formatting For Menus (hh:mm:ss:mss)
Unifies time formatting in settings_list.c allows time format to
display as HH:MM:SS.MSS or any consecutive combination thereof
(hh:mm:ss, mm:ss, mm:ss.mss, ss.mss, hh, mm, ss ,mss)
works in INT and TABLE settings with the addition of flag 'F_TIME_SETTING'
Time is auto-ranged dependent on value
Adds talk_time_intervals to allow time values to be spoken similar to
display format: x Hours, x Minutes, x Seconds, x Milliseconds
Table lookups merged or removed from recording, clip meter and lcd timeout
-String_Choice replaced with TABLE_SETTING or INT_SETTING for these
functions as well, cleaned-up cfg_vals that get saved to cfgfile
RTL Languages ARE supported
Negative values ARE supported
Backlight on/off are now Always and Never to share formatter with LCD
Timeout
Added flag to allow ranged units to be locked to a minimum index
Added flag to allow leading zero to be supressed from the largest unit
merged talk_time_unit() and talk_time_intervals()
optimized time_split()
optimized format_time_auto()
Backlight time-out list same as original
Change-Id: I59027c62d3f2956bd16fdcc1a48b2ac32c084abd
2018-12-18 04:27:55 +00:00
|
|
|
|
|
|
|
/* format_time_auto */
|
|
|
|
enum e_fmt_time_auto_idx
|
|
|
|
{
|
|
|
|
UNIT_IDX_HR = 0,
|
|
|
|
UNIT_IDX_MIN,
|
|
|
|
UNIT_IDX_SEC,
|
|
|
|
UNIT_IDX_MS,
|
|
|
|
UNIT_IDX_TIME_COUNT,
|
|
|
|
};
|
|
|
|
#define UNIT_IDX_MASK 0x01FFU /*Return only Unit_IDX*/
|
|
|
|
#define UNIT_TRIM_ZERO 0x0200U /*Don't show leading zero on max_idx*/
|
|
|
|
#define UNIT_LOCK_HR 0x0400U /*Don't Auto Range below this field*/
|
|
|
|
#define UNIT_LOCK_MIN 0x0800U /*Don't Auto Range below this field*/
|
|
|
|
#define UNIT_LOCK_SEC 0x1000U /*Don't Auto Range below this field*/
|
|
|
|
|
|
|
|
/* time_split_units()
|
|
|
|
split time values depending on base unit
|
|
|
|
unit_idx: UNIT_HOUR, UNIT_MIN, UNIT_SEC, UNIT_MS
|
|
|
|
abs_value: absolute time value
|
|
|
|
units_in: array of unsigned ints with IDX_TIME_COUNT fields
|
|
|
|
*/
|
|
|
|
unsigned int time_split_units(int unit_idx, unsigned long abs_val,
|
|
|
|
unsigned long (*units_in)[UNIT_IDX_TIME_COUNT]);
|
|
|
|
|
|
|
|
/* format_time_auto - return an auto ranged time string;
|
|
|
|
buffer: needs to be at least 25 characters for full range
|
|
|
|
|
|
|
|
unit_idx: specifies lowest or base index of the value
|
|
|
|
add | UNIT_LOCK_ to keep place holder of units that would normally be
|
|
|
|
discarded.. For instance, UNIT_LOCK_HR would keep the hours place, ex: string
|
|
|
|
00:10:10 (0 HRS 10 MINS 10 SECONDS) normally it would return as 10:10
|
|
|
|
add | UNIT_TRIM_ZERO to supress leading zero on the largest unit
|
|
|
|
|
|
|
|
value: should be passed in the same form as unit_idx
|
|
|
|
|
|
|
|
supress_unit: may be set to true and in this case the
|
|
|
|
hr, min, sec, ms identifiers will be left off the resulting string but
|
|
|
|
since right to left languages are handled it is advisable to leave units
|
|
|
|
as an indication of the text direction
|
|
|
|
*/
|
|
|
|
const char *format_time_auto(char *buffer, int buf_len, long value,
|
|
|
|
int unit_idx, bool supress_unit);
|
|
|
|
|
2007-02-17 13:36:44 +00:00
|
|
|
/* Format time into buf.
|
|
|
|
*
|
|
|
|
* buf - buffer to format to.
|
|
|
|
* buf_size - size of buffer.
|
|
|
|
* t - time to format, in milliseconds.
|
|
|
|
*/
|
|
|
|
void format_time(char* buf, int buf_size, long t);
|
|
|
|
|
2008-05-01 10:13:12 +00:00
|
|
|
/* Ask the user if they really want to erase the current dynamic playlist
|
|
|
|
* returns true if the playlist should be replaced */
|
|
|
|
bool warn_on_pl_erase(void);
|
|
|
|
|
2003-05-04 02:04:31 +00:00
|
|
|
/* Read (up to) a line of text from fd into buffer and return number of bytes
|
|
|
|
* read (which may be larger than the number of bytes stored in buffer). If
|
|
|
|
* an error occurs, -1 is returned (and buffer contains whatever could be
|
|
|
|
* read). A line is terminated by a LF char. Neither LF nor CR chars are
|
|
|
|
* stored in buffer.
|
|
|
|
*/
|
|
|
|
int read_line(int fd, char* buffer, int buffer_size);
|
2006-10-21 20:37:33 +00:00
|
|
|
int fast_readline(int fd, char *buf, int buf_size, void *parameters,
|
2011-06-23 20:22:00 +00:00
|
|
|
int (*callback)(int n, char *buf, void *parameters));
|
2004-06-30 13:31:14 +00:00
|
|
|
|
2004-07-05 11:15:50 +00:00
|
|
|
bool settings_parseline(char* line, char** name, char** value);
|
2005-02-07 22:56:37 +00:00
|
|
|
long default_event_handler_ex(long event, void (*callback)(void *), void *parameter);
|
|
|
|
long default_event_handler(long event);
|
2007-04-09 13:39:37 +00:00
|
|
|
bool list_stop_handler(void);
|
2011-12-19 20:12:52 +00:00
|
|
|
void car_adapter_mode_init(void) INIT_ATTR;
|
2004-07-05 11:15:50 +00:00
|
|
|
|
2011-12-20 08:15:36 +00:00
|
|
|
/* Unicode byte order mark sequences and lengths */
|
|
|
|
#define BOM_UTF_8 "\xef\xbb\xbf"
|
|
|
|
#define BOM_UTF_8_SIZE 3
|
|
|
|
#define BOM_UTF_16_LE "\xff\xfe"
|
|
|
|
#define BOM_UTF_16_BE "\xfe\xff"
|
|
|
|
#define BOM_UTF_16_SIZE 2
|
|
|
|
|
2012-07-18 21:26:21 +00:00
|
|
|
int split_string(char *str, const char needle, char *vector[], int vector_length);
|
2022-11-25 02:30:47 +00:00
|
|
|
#ifndef O_PATH
|
|
|
|
#define O_PATH 0x2000
|
|
|
|
#endif
|
2022-08-16 11:10:13 +00:00
|
|
|
|
|
|
|
void fix_path_part(char* path, int offset, int count);
|
2022-11-24 02:46:13 +00:00
|
|
|
int open_pathfmt(char *buf, size_t size, int oflag, const char *pathfmt, ...);
|
2008-08-02 20:39:03 +00:00
|
|
|
int open_utf8(const char* pathname, int flags);
|
2022-03-13 07:35:18 +00:00
|
|
|
int string_option(const char *option, const char *const oplist[], bool ignore_case);
|
2008-08-02 20:39:03 +00:00
|
|
|
|
2007-03-30 21:54:48 +00:00
|
|
|
#ifdef BOOTFILE
|
2009-11-25 22:54:36 +00:00
|
|
|
#if !defined(USB_NONE) && !defined(USB_HANDLED_BY_OF) \
|
|
|
|
|| defined(HAVE_HOTSWAP_STORAGE_AS_MAIN)
|
2007-03-30 21:54:48 +00:00
|
|
|
void check_bootfile(bool do_rolo);
|
|
|
|
#endif
|
2007-03-30 23:36:10 +00:00
|
|
|
#endif
|
2007-03-30 21:54:48 +00:00
|
|
|
|
2007-05-30 17:57:32 +00:00
|
|
|
/* check range, set volume and save settings */
|
|
|
|
void setvol(void);
|
|
|
|
|
2007-06-17 21:16:34 +00:00
|
|
|
#ifdef HAVE_LCD_COLOR
|
2008-03-21 13:41:35 +00:00
|
|
|
int hex_to_rgb(const char* hex, int* color);
|
2007-06-17 21:16:34 +00:00
|
|
|
#endif
|
|
|
|
|
2022-11-25 04:09:26 +00:00
|
|
|
int confirm_delete_yesno(const char *name);
|
|
|
|
|
2007-11-18 14:12:01 +00:00
|
|
|
char* strrsplt(char* str, int c);
|
2009-02-08 11:09:55 +00:00
|
|
|
char* skip_whitespace(char* const str);
|
2007-11-21 21:28:27 +00:00
|
|
|
|
2008-01-18 10:02:03 +00:00
|
|
|
/*
|
|
|
|
* removes the extension of filename (if it doesn't start with a .)
|
|
|
|
* puts the result in buffer
|
|
|
|
*/
|
2008-02-06 19:51:19 +00:00
|
|
|
char *strip_extension(char* buffer, int buffer_size, const char *filename);
|
2007-11-21 21:28:27 +00:00
|
|
|
|
2010-08-10 14:15:03 +00:00
|
|
|
bool parse_color(enum screen_type screen, char *text, int *value);
|
2008-03-21 13:41:35 +00:00
|
|
|
|
2009-10-23 13:29:19 +00:00
|
|
|
/* only used in USB HID and set_time screen */
|
|
|
|
#if defined(USB_ENABLE_HID) || (CONFIG_RTC != 0)
|
|
|
|
int clamp_value_wrap(int value, int max, int min);
|
|
|
|
#endif
|
|
|
|
|
2011-06-01 14:41:49 +00:00
|
|
|
enum current_activity {
|
|
|
|
ACTIVITY_UNKNOWN = 0,
|
|
|
|
ACTIVITY_MAINMENU,
|
|
|
|
ACTIVITY_WPS,
|
|
|
|
ACTIVITY_RECORDING,
|
|
|
|
ACTIVITY_FM,
|
|
|
|
ACTIVITY_PLAYLISTVIEWER,
|
|
|
|
ACTIVITY_SETTINGS,
|
|
|
|
ACTIVITY_FILEBROWSER,
|
|
|
|
ACTIVITY_DATABASEBROWSER,
|
|
|
|
ACTIVITY_PLUGINBROWSER,
|
|
|
|
ACTIVITY_QUICKSCREEN,
|
|
|
|
ACTIVITY_PITCHSCREEN,
|
2011-07-20 14:11:15 +00:00
|
|
|
ACTIVITY_OPTIONSELECT,
|
2011-08-04 13:40:24 +00:00
|
|
|
ACTIVITY_PLAYLISTBROWSER,
|
2011-08-05 00:47:11 +00:00
|
|
|
ACTIVITY_PLUGIN,
|
2011-08-07 08:39:56 +00:00
|
|
|
ACTIVITY_CONTEXTMENU,
|
|
|
|
ACTIVITY_SYSTEMSCREEN,
|
|
|
|
ACTIVITY_TIMEDATESCREEN,
|
2011-11-15 13:22:02 +00:00
|
|
|
ACTIVITY_BOOKMARKSLIST,
|
2012-03-03 04:30:07 +00:00
|
|
|
ACTIVITY_SHORTCUTSMENU,
|
2014-01-15 23:26:45 +00:00
|
|
|
ACTIVITY_ID3SCREEN,
|
|
|
|
ACTIVITY_USBSCREEN
|
2011-06-01 14:41:49 +00:00
|
|
|
};
|
2011-07-08 22:31:15 +00:00
|
|
|
|
2023-01-10 17:50:05 +00:00
|
|
|
/* custom string representation of activity */
|
|
|
|
#define MAKE_ACT_STR(act) ((char[3]){'>', 'A'+ (act), 0x0})
|
|
|
|
|
2011-07-08 22:31:15 +00:00
|
|
|
void beep_play(unsigned int frequency, unsigned int duration,
|
|
|
|
unsigned int amplitude);
|
|
|
|
|
|
|
|
enum system_sound
|
|
|
|
{
|
|
|
|
SOUND_KEYCLICK = 0,
|
|
|
|
SOUND_TRACK_SKIP,
|
|
|
|
SOUND_TRACK_NO_MORE,
|
2018-12-16 00:15:28 +00:00
|
|
|
SOUND_LIST_EDGE_BEEP_WRAP,
|
|
|
|
SOUND_LIST_EDGE_BEEP_NOWRAP,
|
2011-07-08 22:31:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Play a standard sound */
|
|
|
|
void system_sound_play(enum system_sound sound);
|
|
|
|
|
2012-01-12 11:28:36 +00:00
|
|
|
typedef bool (*keyclick_callback)(int action, void* data);
|
|
|
|
void keyclick_set_callback(keyclick_callback cb, void* data);
|
2011-07-08 22:31:15 +00:00
|
|
|
/* Produce keyclick based upon button and global settings */
|
2012-03-03 12:52:13 +00:00
|
|
|
void keyclick_click(bool rawbutton, int action);
|
2012-04-30 20:27:01 +00:00
|
|
|
|
|
|
|
/* Return current ReplayGain mode a file should have (REPLAYGAIN_TRACK or
|
|
|
|
* REPLAYGAIN_ALBUM) if ReplayGain processing is enabled, or -1 if no
|
|
|
|
* information present.
|
|
|
|
*/
|
|
|
|
struct mp3entry;
|
|
|
|
int id3_get_replaygain_mode(const struct mp3entry *id3);
|
|
|
|
void replaygain_update(void);
|
2011-07-08 22:31:15 +00:00
|
|
|
|
2011-06-01 14:41:49 +00:00
|
|
|
void push_current_activity(enum current_activity screen);
|
2022-12-12 02:49:06 +00:00
|
|
|
void push_activity_without_refresh(enum current_activity screen);
|
2022-12-14 08:06:04 +00:00
|
|
|
void pop_current_activity(void);
|
|
|
|
void pop_current_activity_without_refresh(void);
|
2011-06-01 14:41:49 +00:00
|
|
|
enum current_activity get_current_activity(void);
|
|
|
|
|
2017-09-18 10:00:05 +00:00
|
|
|
/* format a sound value like: -1.05 dB */
|
|
|
|
int format_sound_value(char *buf, size_t len, int snd, int val);
|
2011-06-01 14:41:49 +00:00
|
|
|
|
2022-12-20 02:12:07 +00:00
|
|
|
#ifndef PLUGIN
|
|
|
|
enum core_load_bmp_error
|
|
|
|
{
|
|
|
|
CLB_ALOC_ERR = 0,
|
|
|
|
CLB_READ_ERR = -1,
|
|
|
|
};
|
|
|
|
struct buflib_callbacks;
|
|
|
|
int core_load_bmp(const char *filename, struct bitmap *bm, const int bmformat,
|
|
|
|
ssize_t *buf_reqd, struct buflib_callbacks *ops);
|
|
|
|
#endif
|
|
|
|
|
2022-11-22 19:19:01 +00:00
|
|
|
/* Convert a volume (in tenth dB) in the range [min_vol, max_vol]
|
|
|
|
* to a normalized linear value in the range [0, max_norm]. */
|
|
|
|
long to_normalized_volume(long vol, long min_vol, long max_vol, long max_norm);
|
|
|
|
|
|
|
|
/* Inverse of to_normalized_volume(), returns the volume in tenth dB
|
|
|
|
* for the given normalized volume. */
|
|
|
|
long from_normalized_volume(long norm, long min_vol, long max_vol, long max_norm);
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif /* MISC_H */
|