New way of defining menus and options allows to declare them static const, which saves the code to runtime-assemble them. Rockbox just got 6 KB smaller.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4931 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
15d04fdb00
commit
b1403ee024
15 changed files with 268 additions and 276 deletions
|
@ -93,10 +93,10 @@ bool bookmark_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_BOOKMARK_MENU_CREATE), bookmark_create_menu},
|
||||
{ STR(LANG_BOOKMARK_MENU_LIST), bookmark_load_menu},
|
||||
{ STR(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), bookmark_mrb_load},
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_BOOKMARK_MENU_CREATE), bookmark_create_menu},
|
||||
{ ID2P(LANG_BOOKMARK_MENU_LIST), bookmark_load_menu},
|
||||
{ ID2P(LANG_BOOKMARK_MENU_RECENT_BOOKMARKS), bookmark_mrb_load},
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof items / sizeof(struct menu_item), NULL,
|
||||
|
|
|
@ -1514,38 +1514,38 @@ bool debug_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ "Dump ROM contents", -1, dbg_save_roms },
|
||||
{ "View I/O ports", -1, dbg_ports },
|
||||
static const struct menu_item items[] = {
|
||||
{ "Dump ROM contents", dbg_save_roms },
|
||||
{ "View I/O ports", dbg_ports },
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#ifdef HAVE_RTC
|
||||
{ "View/clr RTC RAM", -1, dbg_rtc },
|
||||
{ "View/clr RTC RAM", dbg_rtc },
|
||||
#endif /* HAVE_RTC */
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
{ "View OS stacks", -1, dbg_os },
|
||||
{ "View OS stacks", dbg_os },
|
||||
#ifdef HAVE_MAS3507D
|
||||
{ "View MAS info", -1, dbg_mas_info },
|
||||
{ "View MAS info", dbg_mas_info },
|
||||
#endif
|
||||
{ "View MAS regs", -1, dbg_mas },
|
||||
{ "View MAS regs", dbg_mas },
|
||||
#ifdef HAVE_MAS3587F
|
||||
{ "View MAS codec", -1, dbg_mas_codec },
|
||||
{ "View MAS codec", dbg_mas_codec },
|
||||
#endif
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
{ "View battery", -1, view_battery },
|
||||
{ "Screendump", -1, dbg_screendump },
|
||||
{ "View battery", view_battery },
|
||||
{ "Screendump", dbg_screendump },
|
||||
#endif
|
||||
{ "View HW info", -1, dbg_hw_info },
|
||||
{ "View partitions", -1, dbg_partitions },
|
||||
{ "View disk info", -1, dbg_disk_info },
|
||||
{ "View HW info", dbg_hw_info },
|
||||
{ "View partitions", dbg_partitions },
|
||||
{ "View disk info", dbg_disk_info },
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
{ "View mpeg thread", -1, dbg_mpeg_thread },
|
||||
{ "View mpeg thread", dbg_mpeg_thread },
|
||||
#ifdef PM_DEBUG
|
||||
{ "pm histogram", -1, peak_meter_histogram},
|
||||
{ "pm histogram", peak_meter_histogram},
|
||||
#endif /* PM_DEBUG */
|
||||
#endif /* HAVE_LCD_BITMAP */
|
||||
{ "View runtime", -1, view_runtime },
|
||||
{ "View runtime", view_runtime },
|
||||
#ifdef HAVE_FMRADIO
|
||||
{ "FM Radio", -1, dbg_fm_radio },
|
||||
{ "FM Radio", dbg_fm_radio },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -278,9 +278,9 @@ bool rec_menu(void)
|
|||
bool result;
|
||||
|
||||
/* recording menu */
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_RECORDING_MENU), recording_screen },
|
||||
{ STR(LANG_RECORDING_SETTINGS), recording_settings},
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_RECORDING_MENU), recording_screen },
|
||||
{ ID2P(LANG_RECORDING_SETTINGS), recording_settings},
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -298,14 +298,14 @@ bool info_menu(void)
|
|||
bool result;
|
||||
|
||||
/* info menu */
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_MENU_SHOW_ID3_INFO), browse_id3 },
|
||||
{ STR(LANG_INFO_MENU), show_info },
|
||||
{ STR(LANG_VERSION), show_credits },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_MENU_SHOW_ID3_INFO), browse_id3 },
|
||||
{ ID2P(LANG_INFO_MENU), show_info },
|
||||
{ ID2P(LANG_VERSION), show_credits },
|
||||
#ifndef SIMULATOR
|
||||
{ STR(LANG_DEBUG), debug_menu },
|
||||
{ ID2P(LANG_DEBUG), debug_menu },
|
||||
#else
|
||||
{ STR(LANG_USB), simulate_usb },
|
||||
{ ID2P(LANG_USB), simulate_usb },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -326,42 +326,34 @@ bool main_menu(void)
|
|||
/* main menu */
|
||||
struct menu_item items[8];
|
||||
|
||||
items[i].desc = str(LANG_BOOKMARK_MENU);
|
||||
items[i].voice_id = LANG_BOOKMARK_MENU;
|
||||
items[i].desc = ID2P(LANG_BOOKMARK_MENU);
|
||||
items[i++].function = bookmark_menu;
|
||||
|
||||
items[i].desc = str(LANG_SOUND_SETTINGS);
|
||||
items[i].voice_id = LANG_SOUND_SETTINGS;
|
||||
items[i].desc = ID2P(LANG_SOUND_SETTINGS);
|
||||
items[i++].function = sound_menu;
|
||||
|
||||
items[i].desc = str(LANG_GENERAL_SETTINGS);
|
||||
items[i].voice_id = LANG_GENERAL_SETTINGS;
|
||||
items[i].desc = ID2P(LANG_GENERAL_SETTINGS);
|
||||
items[i++].function = settings_menu;
|
||||
|
||||
#ifdef HAVE_FMRADIO
|
||||
if(radio_hardware_present()) {
|
||||
items[i].desc = str(LANG_FM_RADIO);
|
||||
items[i].voice_id = LANG_FM_RADIO;
|
||||
items[i].desc = ID2P(LANG_FM_RADIO);
|
||||
items[i++].function = radio_screen;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MAS3587F
|
||||
items[i].desc = str(LANG_RECORDING);
|
||||
items[i].voice_id = LANG_RECORDING;
|
||||
items[i].desc = ID2P(LANG_RECORDING);
|
||||
items[i++].function = rec_menu;
|
||||
#endif
|
||||
|
||||
items[i].desc = str(LANG_PLAYLIST_MENU);
|
||||
items[i].voice_id = LANG_PLAYLIST_MENU;
|
||||
items[i].desc = ID2P(LANG_PLAYLIST_MENU);
|
||||
items[i++].function = playlist_menu;
|
||||
|
||||
items[i].desc = str(LANG_PLUGINS);
|
||||
items[i].voice_id = LANG_PLUGINS;
|
||||
items[i].desc = ID2P(LANG_PLUGINS);
|
||||
items[i++].function = plugin_browse;
|
||||
|
||||
items[i].desc = str(LANG_INFO);
|
||||
items[i].voice_id = LANG_INFO;
|
||||
items[i].desc = ID2P(LANG_INFO);
|
||||
items[i++].function = info_menu;
|
||||
|
||||
m=menu_init( items, i, NULL, NULL, NULL, NULL );
|
||||
|
|
19
apps/menu.c
19
apps/menu.c
|
@ -33,6 +33,7 @@
|
|||
#include "status.h"
|
||||
#include "screens.h"
|
||||
#include "talk.h"
|
||||
#include "lang.h"
|
||||
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
#include "icons.h"
|
||||
|
@ -177,12 +178,12 @@ void menu_draw(int m)
|
|||
#ifdef HAVE_LCD_BITMAP
|
||||
if (global_settings.invert_cursor)
|
||||
lcd_puts_scroll_style(LINE_X, i-menus[m].top,
|
||||
menus[m].items[i].desc, STYLE_INVERT);
|
||||
P2STR(menus[m].items[i].desc), STYLE_INVERT);
|
||||
else
|
||||
#endif
|
||||
lcd_puts_scroll(LINE_X, i-menus[m].top, menus[m].items[i].desc);
|
||||
lcd_puts_scroll(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc));
|
||||
else
|
||||
lcd_puts(LINE_X, i-menus[m].top, menus[m].items[i].desc);
|
||||
lcd_puts(LINE_X, i-menus[m].top, P2STR(menus[m].items[i].desc));
|
||||
}
|
||||
|
||||
/* place the cursor */
|
||||
|
@ -216,13 +217,13 @@ static void put_cursor(int m, int target)
|
|||
/* "say" the entry under the cursor */
|
||||
if(global_settings.talk_menu)
|
||||
{
|
||||
voice_id = menus[m].items[menus[m].cursor].voice_id;
|
||||
voice_id = P2ID(menus[m].items[menus[m].cursor].desc);
|
||||
if (voice_id >= 0) /* valid ID given? */
|
||||
talk_id(voice_id, false); /* say it */
|
||||
}
|
||||
}
|
||||
|
||||
int menu_init(struct menu_item* mitems, int count, int (*callback)(int, int),
|
||||
int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, int),
|
||||
char *button1, char *button2, char *button3)
|
||||
{
|
||||
int i;
|
||||
|
@ -237,7 +238,7 @@ int menu_init(struct menu_item* mitems, int count, int (*callback)(int, int),
|
|||
DEBUGF("Out of menus!\n");
|
||||
return -1;
|
||||
}
|
||||
menus[i].items = mitems;
|
||||
menus[i].items = (struct menu_item*)mitems; /* de-const */
|
||||
menus[i].itemcount = count;
|
||||
menus[i].top = 0;
|
||||
menus[i].cursor = 0;
|
||||
|
@ -417,7 +418,7 @@ int menu_cursor(int menu)
|
|||
|
||||
char* menu_description(int menu, int position)
|
||||
{
|
||||
return menus[menu].items[position].desc;
|
||||
return P2STR(menus[menu].items[position].desc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -440,8 +441,7 @@ void menu_delete(int menu, int position)
|
|||
menus[menu].cursor = menus[menu].itemcount - 1;
|
||||
}
|
||||
|
||||
void menu_insert(int menu, int position, char *desc, int voice_id,
|
||||
bool (*function) (void))
|
||||
void menu_insert(int menu, int position, char *desc, bool (*function) (void))
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -457,7 +457,6 @@ void menu_insert(int menu, int position, char *desc, int voice_id,
|
|||
|
||||
/* Update the current item */
|
||||
menus[menu].items[position].desc = desc;
|
||||
menus[menu].items[position].voice_id = voice_id;
|
||||
menus[menu].items[position].function = function;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,12 +23,11 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
struct menu_item {
|
||||
unsigned char *desc; /* string */
|
||||
int voice_id; /* the associated voice clip, -1 if none */
|
||||
unsigned char *desc; /* string or ID */
|
||||
bool (*function) (void); /* return true if USB was connected */
|
||||
};
|
||||
|
||||
int menu_init(struct menu_item* mitems, int count, int (*callback)(int, int),
|
||||
int menu_init(const struct menu_item* mitems, int count, int (*callback)(int, int),
|
||||
char *button1, char *button2, char *button3);
|
||||
void menu_exit(int menu);
|
||||
|
||||
|
@ -47,7 +46,6 @@ int menu_count(int menu);
|
|||
bool menu_moveup(int menu);
|
||||
bool menu_movedown(int menu);
|
||||
void menu_draw(int menu);
|
||||
void menu_insert(int menu, int position, char *desc, int voice_id,
|
||||
bool (*function) (void));
|
||||
void menu_insert(int menu, int position, char *desc, bool (*function) (void));
|
||||
|
||||
#endif /* End __MENU_H__ */
|
||||
|
|
|
@ -174,8 +174,7 @@ static bool playlist_options(void)
|
|||
|
||||
if ((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_M3U)
|
||||
{
|
||||
items[i].desc = str(LANG_VIEW);
|
||||
items[i].voice_id = LANG_VIEW;
|
||||
items[i].desc = ID2P(LANG_VIEW);
|
||||
items[i].function = view_playlist;
|
||||
i++;
|
||||
pstart++;
|
||||
|
@ -183,38 +182,32 @@ static bool playlist_options(void)
|
|||
|
||||
if (mpeg_status() & MPEG_STATUS_PLAY)
|
||||
{
|
||||
items[i].desc = str(LANG_INSERT);
|
||||
items[i].voice_id = LANG_INSERT;
|
||||
items[i].desc = ID2P(LANG_INSERT);
|
||||
args[i].position = PLAYLIST_INSERT;
|
||||
args[i].queue = false;
|
||||
i++;
|
||||
|
||||
items[i].desc = str(LANG_INSERT_FIRST);
|
||||
items[i].voice_id = LANG_INSERT_FIRST;
|
||||
items[i].desc = ID2P(LANG_INSERT_FIRST);
|
||||
args[i].position = PLAYLIST_INSERT_FIRST;
|
||||
args[i].queue = false;
|
||||
i++;
|
||||
|
||||
items[i].desc = str(LANG_INSERT_LAST);
|
||||
items[i].voice_id = LANG_INSERT_LAST;
|
||||
items[i].desc = ID2P(LANG_INSERT_LAST);
|
||||
args[i].position = PLAYLIST_INSERT_LAST;
|
||||
args[i].queue = false;
|
||||
i++;
|
||||
|
||||
items[i].desc = str(LANG_QUEUE);
|
||||
items[i].voice_id = LANG_QUEUE;
|
||||
items[i].desc = ID2P(LANG_QUEUE);
|
||||
args[i].position = PLAYLIST_INSERT;
|
||||
args[i].queue = true;
|
||||
i++;
|
||||
|
||||
items[i].desc = str(LANG_QUEUE_FIRST);
|
||||
items[i].voice_id = LANG_QUEUE_FIRST;
|
||||
items[i].desc = ID2P(LANG_QUEUE_FIRST);
|
||||
args[i].position = PLAYLIST_INSERT_FIRST;
|
||||
args[i].queue = true;
|
||||
i++;
|
||||
|
||||
items[i].desc = str(LANG_QUEUE_LAST);
|
||||
items[i].voice_id = LANG_QUEUE_LAST;
|
||||
items[i].desc = ID2P(LANG_QUEUE_LAST);
|
||||
args[i].position = PLAYLIST_INSERT_LAST;
|
||||
args[i].queue = true;
|
||||
i++;
|
||||
|
@ -222,8 +215,7 @@ static bool playlist_options(void)
|
|||
else if (((selected_file_attr & TREE_ATTR_MASK) == TREE_ATTR_MPA) ||
|
||||
(selected_file_attr & ATTR_DIRECTORY))
|
||||
{
|
||||
items[i].desc = str(LANG_INSERT);
|
||||
items[i].voice_id = LANG_INSERT;
|
||||
items[i].desc = ID2P(LANG_INSERT);
|
||||
args[i].position = PLAYLIST_INSERT;
|
||||
args[i].queue = false;
|
||||
i++;
|
||||
|
@ -419,8 +411,7 @@ int onplay(char* file, int attr)
|
|||
|
||||
if (!(attr & ATTR_DIRECTORY))
|
||||
{
|
||||
items[i].desc = str(LANG_ONPLAY_OPEN_WITH);
|
||||
items[i].voice_id = LANG_ONPLAY_OPEN_WITH;
|
||||
items[i].desc = ID2P(LANG_ONPLAY_OPEN_WITH);
|
||||
items[i].function = list_viewers;
|
||||
i++;
|
||||
}
|
||||
|
@ -429,35 +420,30 @@ int onplay(char* file, int attr)
|
|||
(attr & ATTR_DIRECTORY) ||
|
||||
((attr & TREE_ATTR_MASK) == TREE_ATTR_M3U))
|
||||
{
|
||||
items[i].desc = str(LANG_PLAYINDICES_PLAYLIST);
|
||||
items[i].voice_id = LANG_PLAYINDICES_PLAYLIST;
|
||||
items[i].desc = ID2P(LANG_PLAYINDICES_PLAYLIST);
|
||||
items[i].function = playlist_options;
|
||||
i++;
|
||||
}
|
||||
|
||||
items[i].desc = str(LANG_RENAME);
|
||||
items[i].voice_id = LANG_RENAME;
|
||||
items[i].desc = ID2P(LANG_RENAME);
|
||||
items[i].function = rename_file;
|
||||
i++;
|
||||
|
||||
if (!(attr & ATTR_DIRECTORY))
|
||||
{
|
||||
items[i].desc = str(LANG_DELETE);
|
||||
items[i].voice_id = LANG_DELETE;
|
||||
items[i].desc = ID2P(LANG_DELETE);
|
||||
items[i].function = delete_file;
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
items[i].desc = str(LANG_DELETE_DIR);
|
||||
items[i].voice_id = LANG_DELETE_DIR;
|
||||
items[i].desc = ID2P(LANG_DELETE_DIR);
|
||||
items[i].function = delete_dir;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
items[i].desc = str(LANG_CREATE_DIR);
|
||||
items[i].voice_id = LANG_CREATE_DIR;
|
||||
items[i].desc = ID2P(LANG_CREATE_DIR);
|
||||
items[i].function = create_dir;
|
||||
i++;
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ static bool save_playlist(void)
|
|||
|
||||
static bool recurse_directory(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ STR(LANG_ON) },
|
||||
{ STR(LANG_RESUME_SETTING_ASK)},
|
||||
|
@ -66,11 +66,11 @@ bool playlist_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_CREATE_PLAYLIST), create_playlist },
|
||||
{ STR(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer },
|
||||
{ STR(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist },
|
||||
{ STR(LANG_RECURSE_DIRECTORY), recurse_directory },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_CREATE_PLAYLIST), create_playlist },
|
||||
{ ID2P(LANG_VIEW_DYNAMIC_PLAYLIST), playlist_viewer },
|
||||
{ ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist },
|
||||
{ ID2P(LANG_RECURSE_DIRECTORY), recurse_directory },
|
||||
};
|
||||
|
||||
m = menu_init( items, sizeof items / sizeof(struct menu_item), NULL,
|
||||
|
|
|
@ -681,16 +681,13 @@ static int onplay_menu(int index)
|
|||
int m, i=0, result, ret = 0;
|
||||
bool current = (tracks[index].index == viewer.current_playing_track);
|
||||
|
||||
items[i].desc = str(LANG_REMOVE);
|
||||
items[i].voice_id = LANG_REMOVE;
|
||||
items[i].desc = ID2P(LANG_REMOVE);
|
||||
i++;
|
||||
|
||||
items[i].desc = str(LANG_MOVE);
|
||||
items[i].voice_id = LANG_MOVE;
|
||||
items[i].desc = ID2P(LANG_MOVE);
|
||||
i++;
|
||||
|
||||
items[i].desc = str(LANG_FILE_OPTIONS);
|
||||
items[i].voice_id = LANG_FILE_OPTIONS;
|
||||
items[i].desc = ID2P(LANG_FILE_OPTIONS);
|
||||
i++;
|
||||
|
||||
m = menu_init(items, i, NULL, NULL, NULL, NULL);
|
||||
|
@ -757,11 +754,11 @@ static bool viewer_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_SHOW_ICONS), show_icons },
|
||||
{ STR(LANG_SHOW_INDICES), show_indices },
|
||||
{ STR(LANG_TRACK_DISPLAY), track_display },
|
||||
{ STR(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_SHOW_ICONS), show_icons },
|
||||
{ ID2P(LANG_SHOW_INDICES), show_indices },
|
||||
{ ID2P(LANG_TRACK_DISPLAY), track_display },
|
||||
{ ID2P(LANG_SAVE_DYNAMIC_PLAYLIST), save_playlist },
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -791,7 +788,7 @@ static bool show_indices(void)
|
|||
/* How to display a track */
|
||||
static bool track_display(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_DISPLAY_TRACK_NAME_ONLY) },
|
||||
{ STR(LANG_DISPLAY_FULL_PATH) }
|
||||
};
|
||||
|
|
|
@ -641,7 +641,7 @@ static bool radio_add_preset(void)
|
|||
strcpy(presets[num_presets].name, buf);
|
||||
presets[num_presets].frequency = curr_freq;
|
||||
menu_insert(preset_menu, -1,
|
||||
presets[num_presets].name, 0, 0);
|
||||
presets[num_presets].name, 0);
|
||||
/* We must still rebuild the menu table, since the
|
||||
item name pointers must be updated */
|
||||
rebuild_preset_menu();
|
||||
|
@ -832,12 +832,11 @@ bool radio_menu(void)
|
|||
m = menu_init(items, 0, NULL, NULL, NULL, NULL);
|
||||
|
||||
create_monomode_menu();
|
||||
menu_insert(m, -1, monomode_menu_string, LANG_FM_MONO_MODE,
|
||||
toggle_mono_mode);
|
||||
menu_insert(m, -1, STR(LANG_SOUND_SETTINGS), sound_menu);
|
||||
menu_insert(m, -1, monomode_menu_string, toggle_mono_mode);
|
||||
menu_insert(m, -1, ID2P(LANG_SOUND_SETTINGS), sound_menu);
|
||||
|
||||
#ifndef SIMULATOR
|
||||
menu_insert(m, -1, STR(LANG_RECORDING_SETTINGS), fm_recording_settings);
|
||||
menu_insert(m, -1, ID2P(LANG_RECORDING_SETTINGS), fm_recording_settings);
|
||||
#endif
|
||||
|
||||
result = menu_run(m);
|
||||
|
|
|
@ -1390,7 +1390,7 @@ bool set_int(char* string,
|
|||
code. */
|
||||
|
||||
bool set_option(char* string, void* variable, enum optiontype type,
|
||||
struct opt_items* options, int numoptions, void (*function)(int))
|
||||
const struct opt_items* options, int numoptions, void (*function)(int))
|
||||
{
|
||||
bool done = false;
|
||||
int button;
|
||||
|
@ -1416,7 +1416,7 @@ bool set_option(char* string, void* variable, enum optiontype type,
|
|||
|
||||
while ( !done ) {
|
||||
index = type==INT ? *intvar : (int)*boolvar;
|
||||
lcd_puts(0, 1, options[index].string);
|
||||
lcd_puts(0, 1, P2STR(options[index].string));
|
||||
if (global_settings.talk_menu && index != oldindex)
|
||||
{
|
||||
talk_id(options[index].voice_id, false);
|
||||
|
|
|
@ -62,6 +62,30 @@
|
|||
#define FF_REWIND_60000 13
|
||||
|
||||
|
||||
/* These define "virtual pointers", which could either be a literal string,
|
||||
or a mean a string ID if the pointer is in a certain range.
|
||||
This helps to save space for menus and options. */
|
||||
|
||||
#define VIRT_SIZE 0xFFFF /* more than enough for our string ID range */
|
||||
#ifdef SIMULATOR
|
||||
/* a space which is defined in stubs.c */
|
||||
extern unsigned char vp_dummy[VIRT_SIZE];
|
||||
#define VIRT_PTR vp_dummy
|
||||
#else
|
||||
/* a location where we won't store strings, 0 is the fastest */
|
||||
#define VIRT_PTR ((unsigned char*)0)
|
||||
#endif
|
||||
|
||||
/* form a "virtual pointer" out of a language ID */
|
||||
#define ID2P(id) (VIRT_PTR + id)
|
||||
|
||||
/* resolve a pointer which could be a virtualized ID or a literal */
|
||||
#define P2STR(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? str(p-VIRT_PTR) : p)
|
||||
|
||||
/* get the string ID from a virtual pointer, -1 if not virtual */
|
||||
#define P2ID(p) ((p>=VIRT_PTR && p<=VIRT_PTR+VIRT_SIZE) ? p-VIRT_PTR : -1)
|
||||
|
||||
|
||||
struct user_settings
|
||||
{
|
||||
/* audio settings */
|
||||
|
@ -224,7 +248,7 @@ struct user_settings
|
|||
enum optiontype { INT, BOOL };
|
||||
|
||||
struct opt_items {
|
||||
char* string;
|
||||
unsigned char* string;
|
||||
int voice_id;
|
||||
};
|
||||
|
||||
|
@ -247,7 +271,7 @@ bool set_bool_options(char* string, bool* variable,
|
|||
|
||||
bool set_bool(char* string, bool* variable );
|
||||
bool set_option(char* string, void* variable, enum optiontype type,
|
||||
struct opt_items* options, int numoptions, void (*function)(int));
|
||||
const struct opt_items* options, int numoptions, void (*function)(int));
|
||||
bool set_int(char* string, char* unit, int voice_unit, int* variable,
|
||||
void (*function)(int), int step, int min, int max );
|
||||
bool set_time_screen(char* string, struct tm *tm);
|
||||
|
|
|
@ -136,7 +136,7 @@ static bool flip_display(void)
|
|||
*/
|
||||
static bool battery_type(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_DISPLAY_GRAPHIC) },
|
||||
{ STR(LANG_DISPLAY_NUMERIC) }
|
||||
};
|
||||
|
@ -149,7 +149,7 @@ static bool battery_type(void)
|
|||
*/
|
||||
static bool volume_type(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_DISPLAY_GRAPHIC) },
|
||||
{ STR(LANG_DISPLAY_NUMERIC) }
|
||||
};
|
||||
|
@ -172,7 +172,7 @@ static bool peak_meter_fps_menu(void) {
|
|||
*/
|
||||
static bool peak_meter_hold(void) {
|
||||
bool retval = false;
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ "200 ms " , TALK_ID(200, UNIT_MS) },
|
||||
{ "300 ms " , TALK_ID(300, UNIT_MS) },
|
||||
|
@ -209,7 +209,7 @@ static bool peak_meter_hold(void) {
|
|||
static bool peak_meter_clip_hold(void) {
|
||||
bool retval = false;
|
||||
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_PM_ETERNAL) },
|
||||
{ "1s " , TALK_ID(1, UNIT_SEC) },
|
||||
{ "2s " , TALK_ID(2, UNIT_SEC) },
|
||||
|
@ -409,17 +409,17 @@ static bool peak_meter_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_PM_RELEASE) , peak_meter_release },
|
||||
{ STR(LANG_PM_PEAK_HOLD), peak_meter_hold },
|
||||
{ STR(LANG_PM_CLIP_HOLD), peak_meter_clip_hold },
|
||||
{ STR(LANG_PM_PERFORMANCE), peak_meter_performance },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_PM_RELEASE) , peak_meter_release },
|
||||
{ ID2P(LANG_PM_PEAK_HOLD), peak_meter_hold },
|
||||
{ ID2P(LANG_PM_CLIP_HOLD), peak_meter_clip_hold },
|
||||
{ ID2P(LANG_PM_PERFORMANCE), peak_meter_performance },
|
||||
#ifdef PM_DEBUG
|
||||
{ "Refresh rate" , -1 , peak_meter_fps_menu },
|
||||
#endif
|
||||
{ STR(LANG_PM_SCALE) , peak_meter_scale },
|
||||
{ STR(LANG_PM_MIN) , peak_meter_min },
|
||||
{ STR(LANG_PM_MAX) , peak_meter_max },
|
||||
{ ID2P(LANG_PM_SCALE) , peak_meter_scale },
|
||||
{ ID2P(LANG_PM_MIN) , peak_meter_min },
|
||||
{ ID2P(LANG_PM_MAX) , peak_meter_max },
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -438,7 +438,7 @@ static bool shuffle(void)
|
|||
static bool repeat_mode(void)
|
||||
{
|
||||
bool result;
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ STR(LANG_REPEAT_ALL) },
|
||||
{ STR(LANG_REPEAT_ONE) }
|
||||
|
@ -461,7 +461,7 @@ static bool play_selected(void)
|
|||
|
||||
static bool dir_filter(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_FILTER_ALL) },
|
||||
{ STR(LANG_FILTER_SUPPORTED) },
|
||||
{ STR(LANG_FILTER_MUSIC) },
|
||||
|
@ -480,7 +480,7 @@ static bool sort_file(void)
|
|||
{
|
||||
int oldval = global_settings.sort_file;
|
||||
bool ret;
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_SORT_ALPHA) },
|
||||
{ STR(LANG_SORT_DATE) },
|
||||
{ STR(LANG_SORT_DATE_REVERSE) },
|
||||
|
@ -497,7 +497,7 @@ static bool sort_dir(void)
|
|||
{
|
||||
int oldval = global_settings.sort_dir;
|
||||
bool ret;
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_SORT_ALPHA) },
|
||||
{ STR(LANG_SORT_DATE) },
|
||||
{ STR(LANG_SORT_DATE_REVERSE) }
|
||||
|
@ -511,7 +511,7 @@ static bool sort_dir(void)
|
|||
|
||||
static bool resume(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_SET_BOOL_NO) },
|
||||
{ STR(LANG_RESUME_SETTING_ASK) },
|
||||
{ STR(LANG_RESUME_SETTING_ASK_ONCE) },
|
||||
|
@ -524,7 +524,7 @@ static bool resume(void)
|
|||
static bool autocreatebookmark(void)
|
||||
{
|
||||
bool retval = false;
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_SET_BOOL_NO) },
|
||||
{ STR(LANG_SET_BOOL_YES) },
|
||||
{ STR(LANG_RESUME_SETTING_ASK) },
|
||||
|
@ -547,7 +547,7 @@ static bool autocreatebookmark(void)
|
|||
|
||||
static bool autoloadbookmark(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_SET_BOOL_NO) },
|
||||
{ STR(LANG_SET_BOOL_YES) },
|
||||
{ STR(LANG_RESUME_SETTING_ASK) }
|
||||
|
@ -559,7 +559,7 @@ static bool autoloadbookmark(void)
|
|||
|
||||
static bool useMRB(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_SET_BOOL_NO) },
|
||||
{ STR(LANG_SET_BOOL_YES) },
|
||||
{ STR(LANG_BOOKMARK_SETTINGS_UNIQUE_ONLY) }
|
||||
|
@ -578,7 +578,7 @@ static bool backlight_on_when_charging(void)
|
|||
|
||||
static bool backlight_timer(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ STR(LANG_ON) },
|
||||
{ "1s ", TALK_ID(1, UNIT_SEC) },
|
||||
|
@ -605,7 +605,7 @@ static bool backlight_timer(void)
|
|||
|
||||
static bool poweroff_idle_timer(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ "1m ", TALK_ID(1, UNIT_MIN) },
|
||||
{ "2m ", TALK_ID(2, UNIT_MIN) },
|
||||
|
@ -663,7 +663,7 @@ static bool bidir_limit(void)
|
|||
#ifdef HAVE_LCD_CHARCELLS
|
||||
static bool jump_scroll(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ STR(LANG_ONE_TIME) },
|
||||
{ "2", TALK_ID(2, UNIT_INT) },
|
||||
|
@ -758,7 +758,7 @@ static bool timedate_set(void)
|
|||
|
||||
static bool timeformat_set(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_24_HOUR_CLOCK) },
|
||||
{ STR(LANG_12_HOUR_CLOCK) }
|
||||
};
|
||||
|
@ -815,7 +815,7 @@ static bool buffer_margin(void)
|
|||
|
||||
static bool ff_rewind_min_step(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ "1s", TALK_ID(1, UNIT_SEC) },
|
||||
{ "2s", TALK_ID(2, UNIT_SEC) },
|
||||
{ "3s", TALK_ID(3, UNIT_SEC) },
|
||||
|
@ -843,7 +843,7 @@ static bool set_fade_on_stop(void)
|
|||
|
||||
static bool ff_rewind_accel(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ "2x/1s", TALK_ID(1, UNIT_SEC) },
|
||||
{ "2x/2s", TALK_ID(2, UNIT_SEC) },
|
||||
|
@ -899,7 +899,7 @@ static bool voice_menus(void)
|
|||
|
||||
static bool voice_dirs(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ STR(LANG_VOICE_NUMBER) },
|
||||
{ STR(LANG_VOICE_SPELL) },
|
||||
|
@ -912,7 +912,7 @@ static bool voice_dirs(void)
|
|||
|
||||
static bool voice_files(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ STR(LANG_VOICE_NUMBER) },
|
||||
{ STR(LANG_VOICE_SPELL) }
|
||||
|
@ -926,10 +926,10 @@ static bool voice_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_VOICE_MENU), voice_menus },
|
||||
{ STR(LANG_VOICE_DIR), voice_dirs },
|
||||
{ STR(LANG_VOICE_FILE), voice_files }
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_VOICE_MENU), voice_menus },
|
||||
{ ID2P(LANG_VOICE_DIR), voice_dirs },
|
||||
{ ID2P(LANG_VOICE_FILE), voice_files }
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -966,9 +966,9 @@ static bool ff_rewind_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_FFRW_STEP), ff_rewind_min_step },
|
||||
{ STR(LANG_FFRW_ACCEL), ff_rewind_accel },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_FFRW_STEP), ff_rewind_min_step },
|
||||
{ ID2P(LANG_FFRW_ACCEL), ff_rewind_accel },
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -984,14 +984,14 @@ static bool playback_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_SHUFFLE), shuffle },
|
||||
{ STR(LANG_REPEAT), repeat_mode },
|
||||
{ STR(LANG_PLAY_SELECTED), play_selected },
|
||||
{ STR(LANG_RESUME), resume },
|
||||
{ STR(LANG_WIND_MENU), ff_rewind_settings_menu },
|
||||
{ STR(LANG_MP3BUFFER_MARGIN), buffer_margin },
|
||||
{ STR(LANG_FADE_ON_STOP), set_fade_on_stop },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_SHUFFLE), shuffle },
|
||||
{ ID2P(LANG_REPEAT), repeat_mode },
|
||||
{ ID2P(LANG_PLAY_SELECTED), play_selected },
|
||||
{ ID2P(LANG_RESUME), resume },
|
||||
{ ID2P(LANG_WIND_MENU), ff_rewind_settings_menu },
|
||||
{ ID2P(LANG_MP3BUFFER_MARGIN), buffer_margin },
|
||||
{ ID2P(LANG_FADE_ON_STOP), set_fade_on_stop },
|
||||
};
|
||||
|
||||
bool old_shuffle = global_settings.playlist_shuffle;
|
||||
|
@ -1020,10 +1020,10 @@ static bool bookmark_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark},
|
||||
{ STR(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark},
|
||||
{ STR(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB},
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_BOOKMARK_SETTINGS_AUTOCREATE), autocreatebookmark},
|
||||
{ ID2P(LANG_BOOKMARK_SETTINGS_AUTOLOAD), autoloadbookmark},
|
||||
{ ID2P(LANG_BOOKMARK_SETTINGS_MAINTAIN_RECENT_BOOKMARKS), useMRB},
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -1088,13 +1088,13 @@ static bool fileview_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_SORT_CASE), sort_case },
|
||||
{ STR(LANG_SORT_DIR), sort_dir },
|
||||
{ STR(LANG_SORT_FILE), sort_file },
|
||||
{ STR(LANG_FILTER), dir_filter },
|
||||
{ STR(LANG_FOLLOW), browse_current },
|
||||
{ STR(LANG_SHOW_ICONS), show_icons },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_SORT_CASE), sort_case },
|
||||
{ ID2P(LANG_SORT_DIR), sort_dir },
|
||||
{ ID2P(LANG_SORT_FILE), sort_file },
|
||||
{ ID2P(LANG_FILTER), dir_filter },
|
||||
{ ID2P(LANG_FOLLOW), browse_current },
|
||||
{ ID2P(LANG_SHOW_ICONS), show_icons },
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -1110,16 +1110,16 @@ static bool scroll_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_SCROLL_SPEED), scroll_speed },
|
||||
{ STR(LANG_SCROLL_DELAY), scroll_delay },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_SCROLL_SPEED), scroll_speed },
|
||||
{ ID2P(LANG_SCROLL_DELAY), scroll_delay },
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
{ STR(LANG_SCROLL_STEP), scroll_step },
|
||||
{ ID2P(LANG_SCROLL_STEP), scroll_step },
|
||||
#endif
|
||||
{ STR(LANG_BIDIR_SCROLL), bidir_limit },
|
||||
{ ID2P(LANG_BIDIR_SCROLL), bidir_limit },
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
{ STR(LANG_JUMP_SCROLL), jump_scroll },
|
||||
{ STR(LANG_JUMP_SCROLL_DELAY), jump_scroll_delay },
|
||||
{ ID2P(LANG_JUMP_SCROLL), jump_scroll },
|
||||
{ ID2P(LANG_JUMP_SCROLL_DELAY), jump_scroll_delay },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -1135,15 +1135,15 @@ static bool lcd_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_BACKLIGHT), backlight_timer },
|
||||
{ STR(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging },
|
||||
{ STR(LANG_CAPTION_BACKLIGHT), caption_backlight },
|
||||
{ STR(LANG_CONTRAST), contrast },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_BACKLIGHT), backlight_timer },
|
||||
{ ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging },
|
||||
{ ID2P(LANG_CAPTION_BACKLIGHT), caption_backlight },
|
||||
{ ID2P(LANG_CONTRAST), contrast },
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
{ STR(LANG_INVERT), invert },
|
||||
{ STR(LANG_FLIP_DISPLAY), flip_display },
|
||||
{ STR(LANG_INVERT_CURSOR), invert_cursor },
|
||||
{ ID2P(LANG_INVERT), invert },
|
||||
{ ID2P(LANG_FLIP_DISPLAY), flip_display },
|
||||
{ ID2P(LANG_INVERT_CURSOR), invert_cursor },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -1160,12 +1160,12 @@ static bool bars_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_SCROLL_BAR), scroll_bar },
|
||||
{ STR(LANG_STATUS_BAR), status_bar },
|
||||
{ STR(LANG_BUTTON_BAR), button_bar },
|
||||
{ STR(LANG_VOLUME_DISPLAY), volume_type },
|
||||
{ STR(LANG_BATTERY_DISPLAY), battery_type },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_SCROLL_BAR), scroll_bar },
|
||||
{ ID2P(LANG_STATUS_BAR), status_bar },
|
||||
{ ID2P(LANG_BUTTON_BAR), button_bar },
|
||||
{ ID2P(LANG_VOLUME_DISPLAY), volume_type },
|
||||
{ ID2P(LANG_BATTERY_DISPLAY), battery_type },
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -1182,16 +1182,16 @@ static bool display_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
static const struct menu_item items[] = {
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
{ STR(LANG_CUSTOM_FONT), font_browse },
|
||||
{ ID2P(LANG_CUSTOM_FONT), font_browse },
|
||||
#endif
|
||||
{ STR(LANG_WHILE_PLAYING), custom_wps_browse },
|
||||
{ STR(LANG_LCD_MENU), lcd_settings_menu },
|
||||
{ STR(LANG_SCROLL_MENU), scroll_settings_menu },
|
||||
{ ID2P(LANG_WHILE_PLAYING), custom_wps_browse },
|
||||
{ ID2P(LANG_LCD_MENU), lcd_settings_menu },
|
||||
{ ID2P(LANG_SCROLL_MENU), scroll_settings_menu },
|
||||
#ifdef HAVE_LCD_BITMAP
|
||||
{ STR(LANG_BARS_MENU), bars_settings_menu },
|
||||
{ STR(LANG_PM_MENU), peak_meter_menu },
|
||||
{ ID2P(LANG_BARS_MENU), bars_settings_menu },
|
||||
{ ID2P(LANG_PM_MENU), peak_meter_menu },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -1213,16 +1213,16 @@ static bool battery_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
static const struct menu_item items[] = {
|
||||
#ifdef HAVE_CHARGE_CTRL
|
||||
{ STR(LANG_DISCHARGE), deep_discharge },
|
||||
{ STR(LANG_TRICKLE_CHARGE), trickle_charge },
|
||||
{ ID2P(LANG_DISCHARGE), deep_discharge },
|
||||
{ ID2P(LANG_TRICKLE_CHARGE), trickle_charge },
|
||||
#endif
|
||||
#ifndef SIMULATOR
|
||||
{ STR(LANG_BATTERY_CAPACITY), battery_capacity },
|
||||
{ ID2P(LANG_BATTERY_CAPACITY), battery_capacity },
|
||||
#else
|
||||
#ifndef HAVE_CHARGE_CTRL
|
||||
{ "Dummy", -1, NULL }, /* to have an entry at all, in the simulator */
|
||||
{ "Dummy", NULL }, /* to have an entry at all, in the simulator */
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
@ -1239,10 +1239,10 @@ static bool disk_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_SPINDOWN), spindown },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_SPINDOWN), spindown },
|
||||
#ifdef HAVE_ATA_POWER_OFF
|
||||
{ STR(LANG_POWEROFF), poweroff },
|
||||
{ ID2P(LANG_POWEROFF), poweroff },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -1259,9 +1259,9 @@ static bool time_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_TIME), timedate_set },
|
||||
{ STR(LANG_TIMEFORMAT), timeformat_set },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_TIME), timedate_set },
|
||||
{ ID2P(LANG_TIMEFORMAT), timeformat_set },
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -1277,11 +1277,11 @@ static bool manage_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_CUSTOM_CFG), custom_cfg_browse },
|
||||
{ STR(LANG_FIRMWARE), firmware_browse },
|
||||
{ STR(LANG_RESET), reset_settings },
|
||||
{ STR(LANG_SAVE_SETTINGS), settings_save_config },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_CUSTOM_CFG), custom_cfg_browse },
|
||||
{ ID2P(LANG_FIRMWARE), firmware_browse },
|
||||
{ ID2P(LANG_RESET), reset_settings },
|
||||
{ ID2P(LANG_SAVE_SETTINGS), settings_save_config },
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -1296,9 +1296,9 @@ static bool limits_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_MAX_FILES_IN_DIR), max_files_in_dir },
|
||||
{ STR(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_MAX_FILES_IN_DIR), max_files_in_dir },
|
||||
{ ID2P(LANG_MAX_FILES_IN_PLAYLIST), max_files_in_playlist },
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -1314,23 +1314,23 @@ static bool system_settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_BATTERY_MENU), battery_settings_menu },
|
||||
{ STR(LANG_DISK_MENU), disk_settings_menu },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_BATTERY_MENU), battery_settings_menu },
|
||||
{ ID2P(LANG_DISK_MENU), disk_settings_menu },
|
||||
#ifdef HAVE_RTC
|
||||
{ STR(LANG_TIME_MENU), time_settings_menu },
|
||||
{ ID2P(LANG_TIME_MENU), time_settings_menu },
|
||||
#endif
|
||||
{ STR(LANG_POWEROFF_IDLE), poweroff_idle_timer },
|
||||
{ STR(LANG_SLEEP_TIMER), sleeptimer_screen },
|
||||
{ ID2P(LANG_POWEROFF_IDLE), poweroff_idle_timer },
|
||||
{ ID2P(LANG_SLEEP_TIMER), sleeptimer_screen },
|
||||
#ifdef HAVE_ALARM_MOD
|
||||
{ STR(LANG_ALARM_MOD_ALARM_MENU), alarm_screen },
|
||||
{ ID2P(LANG_ALARM_MOD_ALARM_MENU), alarm_screen },
|
||||
#endif
|
||||
{ STR(LANG_LIMITS_MENU), limits_settings_menu },
|
||||
{ ID2P(LANG_LIMITS_MENU), limits_settings_menu },
|
||||
#ifdef HAVE_MAS3507D
|
||||
{ STR(LANG_LINE_IN), line_in },
|
||||
{ ID2P(LANG_LINE_IN), line_in },
|
||||
#endif
|
||||
{ STR(LANG_CAR_ADAPTER_MODE), car_adapter_mode },
|
||||
{ STR(LANG_MANAGE_MENU), manage_settings_menu },
|
||||
{ ID2P(LANG_CAR_ADAPTER_MODE), car_adapter_mode },
|
||||
{ ID2P(LANG_MANAGE_MENU), manage_settings_menu },
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
@ -1345,14 +1345,14 @@ bool settings_menu(void)
|
|||
int m;
|
||||
bool result;
|
||||
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_PLAYBACK), playback_settings_menu },
|
||||
{ STR(LANG_FILE), fileview_settings_menu },
|
||||
{ STR(LANG_DISPLAY), display_settings_menu },
|
||||
{ STR(LANG_SYSTEM), system_settings_menu },
|
||||
{ STR(LANG_BOOKMARK_SETTINGS),bookmark_settings_menu },
|
||||
{ STR(LANG_LANGUAGE), language_browse },
|
||||
{ STR(LANG_VOICE), voice_menu },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_PLAYBACK), playback_settings_menu },
|
||||
{ ID2P(LANG_FILE), fileview_settings_menu },
|
||||
{ ID2P(LANG_DISPLAY), display_settings_menu },
|
||||
{ ID2P(LANG_SYSTEM), system_settings_menu },
|
||||
{ ID2P(LANG_BOOKMARK_SETTINGS),bookmark_settings_menu },
|
||||
{ ID2P(LANG_LANGUAGE), language_browse },
|
||||
{ ID2P(LANG_VOICE), voice_menu },
|
||||
};
|
||||
|
||||
m=menu_init( items, sizeof(items) / sizeof(*items), NULL,
|
||||
|
|
|
@ -239,7 +239,7 @@ static void set_avc(int val)
|
|||
|
||||
static bool avc(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ "20ms", TALK_ID(20, UNIT_MS) },
|
||||
{ "2s", TALK_ID(2, UNIT_SEC) },
|
||||
|
@ -252,7 +252,7 @@ static bool avc(void)
|
|||
|
||||
static bool recsource(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_RECORDING_SRC_MIC) },
|
||||
{ STR(LANG_RECORDING_SRC_LINE) },
|
||||
{ STR(LANG_RECORDING_SRC_DIGITAL) }
|
||||
|
@ -264,7 +264,7 @@ static bool recsource(void)
|
|||
|
||||
static bool recfrequency(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ "44.1kHz", TALK_ID(44, UNIT_KHZ) },
|
||||
{ "48kHz", TALK_ID(48, UNIT_KHZ) },
|
||||
{ "32kHz", TALK_ID(32, UNIT_KHZ) },
|
||||
|
@ -279,7 +279,7 @@ static bool recfrequency(void)
|
|||
|
||||
static bool recchannels(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_CHANNEL_STEREO) },
|
||||
{ STR(LANG_CHANNEL_MONO) }
|
||||
};
|
||||
|
@ -303,7 +303,7 @@ static bool receditable(void)
|
|||
|
||||
static bool rectimesplit(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ "00:05" , TALK_ID(5, UNIT_MIN) },
|
||||
{ "00:10" , TALK_ID(10, UNIT_MIN) },
|
||||
|
@ -326,7 +326,7 @@ static bool rectimesplit(void)
|
|||
|
||||
static bool recprerecord(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_OFF) },
|
||||
{ "1s", TALK_ID(1, UNIT_SEC) },
|
||||
{ "2s", TALK_ID(2, UNIT_SEC) },
|
||||
|
@ -366,7 +366,7 @@ static bool recprerecord(void)
|
|||
|
||||
static bool recdirectory(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ rec_base_directory, -1 },
|
||||
{ STR(LANG_RECORD_CURRENT_DIR) }
|
||||
};
|
||||
|
@ -384,7 +384,7 @@ static void set_chanconf(int val)
|
|||
|
||||
static bool chanconf(void)
|
||||
{
|
||||
struct opt_items names[] = {
|
||||
static const struct opt_items names[] = {
|
||||
{ STR(LANG_CHANNEL_STEREO) },
|
||||
#ifdef HAVE_LCD_CHARCELLS
|
||||
{ STR(LANG_CHANNEL_STEREO_NARROW_PLAYER) },
|
||||
|
@ -405,21 +405,21 @@ bool sound_menu(void)
|
|||
{
|
||||
int m;
|
||||
bool result;
|
||||
struct menu_item items[] = {
|
||||
{ STR(LANG_VOLUME), volume },
|
||||
{ STR(LANG_BASS), bass },
|
||||
{ STR(LANG_TREBLE), treble },
|
||||
{ STR(LANG_BALANCE), balance },
|
||||
{ STR(LANG_CHANNEL_MENU), chanconf },
|
||||
static const struct menu_item items[] = {
|
||||
{ ID2P(LANG_VOLUME), volume },
|
||||
{ ID2P(LANG_BASS), bass },
|
||||
{ ID2P(LANG_TREBLE), treble },
|
||||
{ ID2P(LANG_BALANCE), balance },
|
||||
{ ID2P(LANG_CHANNEL_MENU), chanconf },
|
||||
#ifdef HAVE_MAS3587F
|
||||
{ STR(LANG_LOUDNESS), loudness },
|
||||
{ STR(LANG_AUTOVOL), avc },
|
||||
{ STR(LANG_SUPERBASS), superbass },
|
||||
{ STR(LANG_MDB_ENABLE), mdb_enable },
|
||||
{ STR(LANG_MDB_STRENGTH), mdb_strength },
|
||||
{ STR(LANG_MDB_HARMONICS), mdb_harmonics },
|
||||
{ STR(LANG_MDB_CENTER), mdb_center },
|
||||
{ STR(LANG_MDB_SHAPE), mdb_shape },
|
||||
{ ID2P(LANG_LOUDNESS), loudness },
|
||||
{ ID2P(LANG_AUTOVOL), avc },
|
||||
{ ID2P(LANG_SUPERBASS), superbass },
|
||||
{ ID2P(LANG_MDB_ENABLE), mdb_enable },
|
||||
{ ID2P(LANG_MDB_STRENGTH), mdb_strength },
|
||||
{ ID2P(LANG_MDB_HARMONICS), mdb_harmonics },
|
||||
{ ID2P(LANG_MDB_CENTER), mdb_center },
|
||||
{ ID2P(LANG_MDB_SHAPE), mdb_shape },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -439,31 +439,23 @@ bool recording_menu(bool no_source)
|
|||
struct menu_item items[8];
|
||||
bool result;
|
||||
|
||||
items[i].desc = str(LANG_RECORDING_QUALITY);
|
||||
items[i].voice_id = LANG_RECORDING_QUALITY;
|
||||
items[i].desc = ID2P(LANG_RECORDING_QUALITY);
|
||||
items[i++].function = recquality;
|
||||
items[i].desc = str(LANG_RECORDING_FREQUENCY);
|
||||
items[i].voice_id = LANG_RECORDING_FREQUENCY;
|
||||
items[i].desc = ID2P(LANG_RECORDING_FREQUENCY);
|
||||
items[i++].function = recfrequency;
|
||||
if(!no_source) {
|
||||
items[i].desc = str(LANG_RECORDING_SOURCE);
|
||||
items[i].voice_id = LANG_RECORDING_SOURCE;
|
||||
items[i].desc = ID2P(LANG_RECORDING_SOURCE);
|
||||
items[i++].function = recsource;
|
||||
}
|
||||
items[i].desc = str(LANG_RECORDING_CHANNELS);
|
||||
items[i].voice_id = LANG_RECORDING_CHANNELS;
|
||||
items[i].desc = ID2P(LANG_RECORDING_CHANNELS);
|
||||
items[i++].function = recchannels;
|
||||
items[i].desc = str(LANG_RECORDING_EDITABLE);
|
||||
items[i].voice_id = LANG_RECORDING_EDITABLE;
|
||||
items[i].desc = ID2P(LANG_RECORDING_EDITABLE);
|
||||
items[i++].function = receditable;
|
||||
items[i].desc = str(LANG_RECORD_TIMESPLIT);
|
||||
items[i].voice_id = LANG_RECORD_TIMESPLIT;
|
||||
items[i].desc = ID2P(LANG_RECORD_TIMESPLIT);
|
||||
items[i++].function = rectimesplit;
|
||||
items[i].desc = str(LANG_RECORD_PRERECORD_TIME);
|
||||
items[i].voice_id = LANG_RECORD_PRERECORD_TIME;
|
||||
items[i].desc = ID2P(LANG_RECORD_PRERECORD_TIME);
|
||||
items[i++].function = recprerecord;
|
||||
items[i].desc = str(LANG_RECORD_DIRECTORY);
|
||||
items[i].voice_id = LANG_RECORD_DIRECTORY;
|
||||
items[i].desc = ID2P(LANG_RECORD_DIRECTORY);
|
||||
items[i++].function = recdirectory;
|
||||
|
||||
m=menu_init( items, i, NULL, NULL, NULL, NULL);
|
||||
|
|
|
@ -51,8 +51,8 @@ enum {
|
|||
unit is upper 4 bits, number the remaining (in regular 2's complement) */
|
||||
#define TALK_ID(n,u) ((u)<<UNIT_SHIFT | ((n) & ~(-1<<UNIT_SHIFT)))
|
||||
|
||||
/* convenience macro to have both string and ID as arguments */
|
||||
#define STR(id) str(id), id
|
||||
/* convenience macro to have both virtual pointer and ID as arguments */
|
||||
#define STR(id) ID2P(id), id
|
||||
|
||||
/* publish this string, so it's stored only once (better than #define) */
|
||||
extern const char* dir_thumbnail_name;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "string.h"
|
||||
#include "lcd.h"
|
||||
#include "settings.h"
|
||||
|
||||
extern char having_new_lcd;
|
||||
|
||||
|
@ -277,3 +278,7 @@ void remove_thread(int threadnum)
|
|||
{
|
||||
(void)threadnum;
|
||||
}
|
||||
|
||||
/* assure an unused place to direct virtual pointers to */
|
||||
unsigned char vp_dummy[VIRT_SIZE];
|
||||
|
||||
|
|
Loading…
Reference in a new issue