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[];
|
|
|
|
extern const unsigned char * const * const kbyte_units;
|
|
|
|
|
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.*/
|
2006-11-06 18:07:30 +00:00
|
|
|
char *output_dyn_value(char *buf, int buf_size, int value,
|
2009-10-17 13:40:42 +00:00
|
|
|
const unsigned char * const *units, bool bin_scale);
|
2003-05-04 02:04:31 +00:00
|
|
|
|
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;
|
2005-09-02 05:39:09 +00:00
|
|
|
extern int show_logo(void);
|
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
|
|
|
|
|
2008-08-02 20:39:03 +00:00
|
|
|
int open_utf8(const char* pathname, int flags);
|
|
|
|
|
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
|
|
|
|
|
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
|
|
|
|
2009-10-23 13:29:19 +00:00
|
|
|
#ifdef HAVE_LCD_BITMAP
|
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
|
|
|
|
#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,
|
|
|
|
ACTIVITY_ID3SCREEN
|
2011-06-01 14:41:49 +00:00
|
|
|
};
|
2011-07-08 22:31:15 +00:00
|
|
|
|
|
|
|
#if CONFIG_CODEC == SWCODEC
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* 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);
|
|
|
|
#else
|
|
|
|
static inline void replaygain_update(void) {}
|
2011-07-08 22:31:15 +00:00
|
|
|
#endif /* CONFIG_CODEC == SWCODEC */
|
|
|
|
|
2011-06-01 14:41:49 +00:00
|
|
|
void push_current_activity(enum current_activity screen);
|
|
|
|
void pop_current_activity(void);
|
|
|
|
enum current_activity get_current_activity(void);
|
|
|
|
|
|
|
|
|
2006-11-06 18:07:30 +00:00
|
|
|
#endif /* MISC_H */
|