diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2008-05-28 10:55:39 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2008-05-28 10:55:39 +0000 |
commit | ff469ab5733133bfaf8b1c1925be8bdefdb6212c (patch) | |
tree | 9099d834698d773003929906cbfd22288f041e09 | |
parent | 0f7f5f2267dd7447466f28946d57597b1c0b78c7 (diff) | |
download | rockbox-ff469ab5733133bfaf8b1c1925be8bdefdb6212c.tar.gz rockbox-ff469ab5733133bfaf8b1c1925be8bdefdb6212c.zip |
Updated recording trigger screen (seems to be a feature almost noone uses?)
problems/complaints in http://forums.rockbox.org/index.php?topic=16837.0
there is a known issue that on this screen the stop icon wont update, I dont know why and noone else wants to look at it, so hopefully this will force another set of eyes on it.. this is only a graphical issue... recordings still work fine
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17643 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/action.h | 1 | ||||
-rw-r--r-- | apps/gui/option_select.c | 14 | ||||
-rw-r--r-- | apps/gui/option_select.h | 7 | ||||
-rw-r--r-- | apps/gui/quickscreen.c | 17 | ||||
-rw-r--r-- | apps/keymaps/keymap-c200.c | 3 | ||||
-rw-r--r-- | apps/keymaps/keymap-cowond2.c | 1 | ||||
-rw-r--r-- | apps/keymaps/keymap-e200.c | 1 | ||||
-rw-r--r-- | apps/keymaps/keymap-h10.c | 1 | ||||
-rw-r--r-- | apps/keymaps/keymap-h1x0_h3x0.c | 2 | ||||
-rw-r--r-- | apps/keymaps/keymap-ipod.c | 1 | ||||
-rw-r--r-- | apps/keymaps/keymap-m3.c | 1 | ||||
-rw-r--r-- | apps/keymaps/keymap-ondio.c | 1 | ||||
-rw-r--r-- | apps/keymaps/keymap-recorder.c | 1 | ||||
-rw-r--r-- | apps/keymaps/keymap-x5.c | 1 | ||||
-rw-r--r-- | apps/menus/recording_menu.c | 566 | ||||
-rw-r--r-- | apps/recorder/peakmeter.c | 5 | ||||
-rw-r--r-- | apps/recorder/peakmeter.h | 3 | ||||
-rw-r--r-- | apps/recorder/recording.c | 56 | ||||
-rw-r--r-- | apps/settings.h | 25 | ||||
-rw-r--r-- | apps/settings_list.c | 59 | ||||
-rw-r--r-- | apps/sound_menu.h | 2 |
21 files changed, 251 insertions, 517 deletions
diff --git a/apps/action.h b/apps/action.h index 96e8086baa..deb3681dd2 100644 --- a/apps/action.h +++ b/apps/action.h | |||
@@ -58,6 +58,7 @@ enum { | |||
58 | CONTEXT_SETTINGS_EQ, | 58 | CONTEXT_SETTINGS_EQ, |
59 | CONTEXT_SETTINGS_COLOURCHOOSER, | 59 | CONTEXT_SETTINGS_COLOURCHOOSER, |
60 | CONTEXT_SETTINGS_TIME, | 60 | CONTEXT_SETTINGS_TIME, |
61 | CONTEXT_SETTINGS_RECTRIGGER, | ||
61 | 62 | ||
62 | /* The following contexts should use ACTION_STD_[NEXT|PREV] | 63 | /* The following contexts should use ACTION_STD_[NEXT|PREV] |
63 | and (possibly) ACTION_SETTINGS_[INC|DEC] | 64 | and (possibly) ACTION_SETTINGS_[INC|DEC] |
diff --git a/apps/gui/option_select.c b/apps/gui/option_select.c index 023f9b47e5..0e4ed8deac 100644 --- a/apps/gui/option_select.c +++ b/apps/gui/option_select.c | |||
@@ -44,7 +44,16 @@ | |||
44 | #endif | 44 | #endif |
45 | 45 | ||
46 | static int selection_to_val(const struct settings_list *setting, int selection); | 46 | static int selection_to_val(const struct settings_list *setting, int selection); |
47 | 47 | int option_value_as_int(const struct settings_list *setting) | |
48 | { | ||
49 | int type = (setting->flags & F_T_MASK); | ||
50 | int temp = 0; | ||
51 | if (type == F_T_BOOL) | ||
52 | temp = *(bool*)setting->setting?1:0; | ||
53 | else if (type == F_T_UINT || type == F_T_INT) | ||
54 | temp = *(int*)setting->setting; | ||
55 | return temp; | ||
56 | } | ||
48 | static const char *unit_strings[] = | 57 | static const char *unit_strings[] = |
49 | { | 58 | { |
50 | [UNIT_INT] = "", [UNIT_MS] = "ms", | 59 | [UNIT_INT] = "", [UNIT_MS] = "ms", |
@@ -214,7 +223,8 @@ static int option_talk(int selected_item, void * data) | |||
214 | return 0; | 223 | return 0; |
215 | } | 224 | } |
216 | 225 | ||
217 | #ifdef HAVE_QUICKSCREEN /* only the quickscreen uses this so far */ | 226 | #if defined(HAVE_QUICKSCREEN) || defined(HAVE_RECORDING) |
227 | /* only the quickscreen and recording trigger needs this */ | ||
218 | void option_select_next_val(const struct settings_list *setting, | 228 | void option_select_next_val(const struct settings_list *setting, |
219 | bool previous, bool apply) | 229 | bool previous, bool apply) |
220 | { | 230 | { |
diff --git a/apps/gui/option_select.h b/apps/gui/option_select.h index 16465cf7f7..ed7b6ae6d6 100644 --- a/apps/gui/option_select.h +++ b/apps/gui/option_select.h | |||
@@ -27,11 +27,16 @@ bool option_screen(const struct settings_list *setting, | |||
27 | struct viewport parent[NB_SCREENS], | 27 | struct viewport parent[NB_SCREENS], |
28 | bool use_temp_var, unsigned char* option_title); | 28 | bool use_temp_var, unsigned char* option_title); |
29 | 29 | ||
30 | 30 | #if defined(HAVE_QUICKSCREEN) || defined(HAVE_RECORDING) | |
31 | void option_select_next_val(const struct settings_list *setting, | 31 | void option_select_next_val(const struct settings_list *setting, |
32 | bool previous, bool apply); | 32 | bool previous, bool apply); |
33 | #endif | ||
33 | char *option_get_valuestring(const struct settings_list *setting, | 34 | char *option_get_valuestring(const struct settings_list *setting, |
34 | char *buffer, int buf_len, | 35 | char *buffer, int buf_len, |
35 | intptr_t temp_var); | 36 | intptr_t temp_var); |
36 | void option_talk_value(const struct settings_list *setting, int value, bool enqueue); | 37 | void option_talk_value(const struct settings_list *setting, int value, bool enqueue); |
38 | |||
39 | /* only use this for int and bool settings */ | ||
40 | int option_value_as_int(const struct settings_list *setting); | ||
41 | |||
37 | #endif /* _GUI_OPTION_SELECT_H_ */ | 42 | #endif /* _GUI_OPTION_SELECT_H_ */ |
diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index 261b1ca8ac..ddc02c1103 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c | |||
@@ -200,10 +200,7 @@ static void gui_quickscreen_draw(struct gui_quickscreen *qs, | |||
200 | 200 | ||
201 | title = P2STR(ID2P(qs->items[i]->lang_id)); | 201 | title = P2STR(ID2P(qs->items[i]->lang_id)); |
202 | setting = qs->items[i]->setting; | 202 | setting = qs->items[i]->setting; |
203 | if ((qs->items[i]->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | 203 | temp = option_value_as_int(qs->items[i]); |
204 | temp = *(bool*)setting?1:0; | ||
205 | else | ||
206 | temp = *(int*)setting; | ||
207 | value = option_get_valuestring((struct settings_list*)qs->items[i], | 204 | value = option_get_valuestring((struct settings_list*)qs->items[i], |
208 | buf, MAX_PATH, temp); | 205 | buf, MAX_PATH, temp); |
209 | 206 | ||
@@ -235,23 +232,13 @@ static void gui_quickscreen_draw(struct gui_quickscreen *qs, | |||
235 | display->set_viewport(NULL); | 232 | display->set_viewport(NULL); |
236 | } | 233 | } |
237 | 234 | ||
238 | static int option_value(const struct settings_list *setting) | ||
239 | { | ||
240 | if ((setting->flags & F_BOOL_SETTING) == F_BOOL_SETTING) | ||
241 | { | ||
242 | return *(bool*)setting->setting==true?1:0; | ||
243 | } | ||
244 | else | ||
245 | return *(int*)setting->setting; | ||
246 | } | ||
247 | |||
248 | static void talk_qs_option(struct settings_list *opt, bool enqueue) | 235 | static void talk_qs_option(struct settings_list *opt, bool enqueue) |
249 | { | 236 | { |
250 | if (global_settings.talk_menu) { | 237 | if (global_settings.talk_menu) { |
251 | if(!enqueue) | 238 | if(!enqueue) |
252 | talk_shutup(); | 239 | talk_shutup(); |
253 | talk_id(opt->lang_id, true); | 240 | talk_id(opt->lang_id, true); |
254 | option_talk_value(opt, option_value(opt), true); | 241 | option_talk_value(opt, option_value_as_int(opt), true); |
255 | } | 242 | } |
256 | } | 243 | } |
257 | 244 | ||
diff --git a/apps/keymaps/keymap-c200.c b/apps/keymaps/keymap-c200.c index d3b0593954..81efc4ca5b 100644 --- a/apps/keymaps/keymap-c200.c +++ b/apps/keymaps/keymap-c200.c | |||
@@ -5,7 +5,7 @@ | |||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id:$ | 8 | * $Id$ |
9 | * | 9 | * |
10 | * Copyright (C) 2007 Mark Arigo | 10 | * Copyright (C) 2007 Mark Arigo |
11 | * | 11 | * |
@@ -307,6 +307,7 @@ const struct button_mapping* get_context_mapping(int context) | |||
307 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: | 307 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: |
308 | case CONTEXT_SETTINGS_COLOURCHOOSER: | 308 | case CONTEXT_SETTINGS_COLOURCHOOSER: |
309 | case CONTEXT_SETTINGS_EQ: | 309 | case CONTEXT_SETTINGS_EQ: |
310 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
310 | return button_context_settings_right_is_inc; | 311 | return button_context_settings_right_is_inc; |
311 | 312 | ||
312 | case CONTEXT_YESNOSCREEN: | 313 | case CONTEXT_YESNOSCREEN: |
diff --git a/apps/keymaps/keymap-cowond2.c b/apps/keymaps/keymap-cowond2.c index 59ca7cb123..8dbc299527 100644 --- a/apps/keymaps/keymap-cowond2.c +++ b/apps/keymaps/keymap-cowond2.c | |||
@@ -152,6 +152,7 @@ const struct button_mapping* target_get_context_mapping(int context) | |||
152 | case CONTEXT_SETTINGS: | 152 | case CONTEXT_SETTINGS: |
153 | return button_context_settings; | 153 | return button_context_settings; |
154 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: | 154 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: |
155 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
155 | return button_context_settings_right_is_inc; | 156 | return button_context_settings_right_is_inc; |
156 | 157 | ||
157 | case CONTEXT_SETTINGS_COLOURCHOOSER: | 158 | case CONTEXT_SETTINGS_COLOURCHOOSER: |
diff --git a/apps/keymaps/keymap-e200.c b/apps/keymaps/keymap-e200.c index 1c11f3f917..e51ca7c5e2 100644 --- a/apps/keymaps/keymap-e200.c +++ b/apps/keymaps/keymap-e200.c | |||
@@ -293,6 +293,7 @@ const struct button_mapping* get_context_mapping(int context) | |||
293 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: | 293 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: |
294 | case CONTEXT_SETTINGS_COLOURCHOOSER: | 294 | case CONTEXT_SETTINGS_COLOURCHOOSER: |
295 | case CONTEXT_SETTINGS_EQ: | 295 | case CONTEXT_SETTINGS_EQ: |
296 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
296 | return button_context_settings_right_is_inc; | 297 | return button_context_settings_right_is_inc; |
297 | 298 | ||
298 | case CONTEXT_SETTINGS_TIME: | 299 | case CONTEXT_SETTINGS_TIME: |
diff --git a/apps/keymaps/keymap-h10.c b/apps/keymaps/keymap-h10.c index 2ea934bd9a..a264b8a844 100644 --- a/apps/keymaps/keymap-h10.c +++ b/apps/keymaps/keymap-h10.c | |||
@@ -391,6 +391,7 @@ const struct button_mapping* get_context_mapping(int context) | |||
391 | case CONTEXT_SETTINGS_COLOURCHOOSER: | 391 | case CONTEXT_SETTINGS_COLOURCHOOSER: |
392 | case CONTEXT_SETTINGS_EQ: | 392 | case CONTEXT_SETTINGS_EQ: |
393 | case CONTEXT_SETTINGS_TIME: | 393 | case CONTEXT_SETTINGS_TIME: |
394 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
394 | return button_context_settings_right_is_inc; | 395 | return button_context_settings_right_is_inc; |
395 | 396 | ||
396 | case CONTEXT_YESNOSCREEN: | 397 | case CONTEXT_YESNOSCREEN: |
diff --git a/apps/keymaps/keymap-h1x0_h3x0.c b/apps/keymaps/keymap-h1x0_h3x0.c index f674e2cab7..37c08824c0 100644 --- a/apps/keymaps/keymap-h1x0_h3x0.c +++ b/apps/keymaps/keymap-h1x0_h3x0.c | |||
@@ -889,6 +889,7 @@ static const struct button_mapping* get_context_mapping_remote(int context) | |||
889 | case CONTEXT_CUSTOM|CONTEXT_TREE: | 889 | case CONTEXT_CUSTOM|CONTEXT_TREE: |
890 | return remote_btn_ctxt_tree; | 890 | return remote_btn_ctxt_tree; |
891 | case CONTEXT_SETTINGS_TIME: | 891 | case CONTEXT_SETTINGS_TIME: |
892 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
892 | return remote_btn_ctxt_settingsgrph; | 893 | return remote_btn_ctxt_settingsgrph; |
893 | 894 | ||
894 | case CONTEXT_SETTINGS: | 895 | case CONTEXT_SETTINGS: |
@@ -939,6 +940,7 @@ const struct button_mapping* get_context_mapping(int context) | |||
939 | case CONTEXT_SETTINGS: | 940 | case CONTEXT_SETTINGS: |
940 | return button_context_settings; | 941 | return button_context_settings; |
941 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: | 942 | case CONTEXT_CUSTOM|CONTEXT_SETTINGS: |
943 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
942 | return button_context_settings_right_is_inc; | 944 | return button_context_settings_right_is_inc; |
943 | 945 | ||
944 | case CONTEXT_SETTINGS_COLOURCHOOSER: | 946 | case CONTEXT_SETTINGS_COLOURCHOOSER: |
diff --git a/apps/keymaps/keymap-ipod.c b/apps/keymaps/keymap-ipod.c index b05db02aae..e162f0e621 100644 --- a/apps/keymaps/keymap-ipod.c +++ b/apps/keymaps/keymap-ipod.c | |||
@@ -196,6 +196,7 @@ const struct button_mapping* get_context_mapping(int context) | |||
196 | case CONTEXT_SETTINGS_COLOURCHOOSER: | 196 | case CONTEXT_SETTINGS_COLOURCHOOSER: |
197 | case CONTEXT_SETTINGS_TIME: | 197 | case CONTEXT_SETTINGS_TIME: |
198 | case CONTEXT_SETTINGS: | 198 | case CONTEXT_SETTINGS: |
199 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
199 | return button_context_settings; | 200 | return button_context_settings; |
200 | case CONTEXT_YESNOSCREEN: | 201 | case CONTEXT_YESNOSCREEN: |
201 | return button_context_yesno; | 202 | return button_context_yesno; |
diff --git a/apps/keymaps/keymap-m3.c b/apps/keymaps/keymap-m3.c index 23d78e47b2..f18ec9371c 100644 --- a/apps/keymaps/keymap-m3.c +++ b/apps/keymaps/keymap-m3.c | |||
@@ -469,6 +469,7 @@ const struct button_mapping* get_context_mapping(int context) | |||
469 | return button_context_settings; | 469 | return button_context_settings; |
470 | 470 | ||
471 | case CONTEXT_SETTINGS_EQ: | 471 | case CONTEXT_SETTINGS_EQ: |
472 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
472 | return button_context_settings_r_is_inc; | 473 | return button_context_settings_r_is_inc; |
473 | 474 | ||
474 | case CONTEXT_TREE: | 475 | case CONTEXT_TREE: |
diff --git a/apps/keymaps/keymap-ondio.c b/apps/keymaps/keymap-ondio.c index cd64657730..2448d00a7c 100644 --- a/apps/keymaps/keymap-ondio.c +++ b/apps/keymaps/keymap-ondio.c | |||
@@ -204,6 +204,7 @@ const struct button_mapping* get_context_mapping( int context ) | |||
204 | case CONTEXT_CUSTOM|CONTEXT_TREE: | 204 | case CONTEXT_CUSTOM|CONTEXT_TREE: |
205 | return button_context_tree; | 205 | return button_context_tree; |
206 | case CONTEXT_RECSCREEN: | 206 | case CONTEXT_RECSCREEN: |
207 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
207 | return button_context_recscreen; | 208 | return button_context_recscreen; |
208 | case CONTEXT_KEYBOARD: | 209 | case CONTEXT_KEYBOARD: |
209 | return button_context_keyboard; | 210 | return button_context_keyboard; |
diff --git a/apps/keymaps/keymap-recorder.c b/apps/keymaps/keymap-recorder.c index 403ebbfd80..7160e0b4c9 100644 --- a/apps/keymaps/keymap-recorder.c +++ b/apps/keymaps/keymap-recorder.c | |||
@@ -294,6 +294,7 @@ const struct button_mapping* get_context_mapping( int context ) | |||
294 | return button_context_quickscreen; | 294 | return button_context_quickscreen; |
295 | 295 | ||
296 | case CONTEXT_RECSCREEN: | 296 | case CONTEXT_RECSCREEN: |
297 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
297 | return button_context_recscreen; | 298 | return button_context_recscreen; |
298 | case CONTEXT_KEYBOARD: | 299 | case CONTEXT_KEYBOARD: |
299 | return button_context_keyboard; | 300 | return button_context_keyboard; |
diff --git a/apps/keymaps/keymap-x5.c b/apps/keymaps/keymap-x5.c index 7acb84fbbd..ee64090be3 100644 --- a/apps/keymaps/keymap-x5.c +++ b/apps/keymaps/keymap-x5.c | |||
@@ -418,6 +418,7 @@ const struct button_mapping* get_context_mapping( int context ) | |||
418 | 418 | ||
419 | case CONTEXT_SETTINGS_COLOURCHOOSER: | 419 | case CONTEXT_SETTINGS_COLOURCHOOSER: |
420 | case CONTEXT_SETTINGS_EQ: | 420 | case CONTEXT_SETTINGS_EQ: |
421 | case CONTEXT_SETTINGS_RECTRIGGER: | ||
421 | return button_context_settings_r_is_inc; | 422 | return button_context_settings_r_is_inc; |
422 | 423 | ||
423 | case CONTEXT_SETTINGS_TIME: | 424 | case CONTEXT_SETTINGS_TIME: |
diff --git a/apps/menus/recording_menu.c b/apps/menus/recording_menu.c index 8a26be03e9..9dcdcf5d3e 100644 --- a/apps/menus/recording_menu.c +++ b/apps/menus/recording_menu.c | |||
@@ -63,7 +63,10 @@ | |||
63 | #include "action.h" | 63 | #include "action.h" |
64 | #include "recording.h" | 64 | #include "recording.h" |
65 | #include "sound_menu.h" | 65 | #include "sound_menu.h" |
66 | 66 | #include "option_select.h" | |
67 | #include "settings_list.h" | ||
68 | #include "list.h" | ||
69 | #include "viewport.h" | ||
67 | 70 | ||
68 | static bool no_source_in_menu = false; | 71 | static bool no_source_in_menu = false; |
69 | int recmenu_callback(int action,const struct menu_item_ex *this_item); | 72 | int recmenu_callback(int action,const struct menu_item_ex *this_item); |
@@ -381,477 +384,192 @@ enum trigger_menu_option | |||
381 | TRIG_OPTION_COUNT, | 384 | TRIG_OPTION_COUNT, |
382 | }; | 385 | }; |
383 | 386 | ||
384 | static char* create_thres_str(int threshold, long *voice_id) | 387 | static enum themable_icons trigger_get_icon(int selected_item, void * data) |
385 | { | 388 | { |
386 | static char retval[6]; | 389 | (void)data; |
387 | if (threshold < 0) { | 390 | if ((selected_item % 2) == 0) /* header */ |
388 | if (threshold < -88) { | 391 | return Icon_Menu_setting; |
389 | snprintf (retval, sizeof retval, "%s", str(LANG_DB_INF)); | 392 | return Icon_NOICON; |
390 | if(voice_id) | ||
391 | *voice_id = LANG_DB_INF; | ||
392 | } else { | ||
393 | snprintf (retval, sizeof retval, "%ddb", threshold + 1); | ||
394 | if(voice_id) | ||
395 | *voice_id = TALK_ID(threshold + 1, UNIT_DB); | ||
396 | } | ||
397 | } else { | ||
398 | snprintf (retval, sizeof retval, "%d%%", threshold); | ||
399 | if(voice_id) | ||
400 | *voice_id = TALK_ID(threshold, UNIT_PERCENT); | ||
401 | } | ||
402 | return retval; | ||
403 | } | 393 | } |
404 | 394 | ||
405 | #define INF_DB (-89) | 395 | static char * trigger_get_name(int selected_item, void * data, |
406 | static void change_threshold(int *threshold, int change) | 396 | char * buffer, size_t buffer_len) |
407 | { | 397 | { |
408 | if (global_settings.peak_meter_dbfs) { | 398 | const struct settings_list **settings = |
409 | if (*threshold >= 0) { | 399 | (const struct settings_list **)data; |
410 | int db = (calc_db(*threshold * MAX_PEAK / 100) - 9000) / 100; | 400 | const struct settings_list *s = settings[selected_item / 2]; |
411 | *threshold = db; | 401 | if ((selected_item % 2) == 0) /* header */ |
412 | } | 402 | return P2STR(ID2P(s->lang_id)); |
413 | *threshold += change; | 403 | else |
414 | if (*threshold > -1) { | 404 | { |
415 | *threshold = INF_DB; | 405 | int temp; |
416 | } else if (*threshold < INF_DB) { | 406 | temp = option_value_as_int(s); |
417 | *threshold = -1; | 407 | if ((selected_item / 2 == START_THRESHOLD || |
418 | } | 408 | selected_item / 2 == STOP_THRESHOLD) && |
419 | } else { | 409 | temp == 0) |
420 | if (*threshold < 0) { | 410 | { |
421 | *threshold = peak_meter_db2sample(*threshold * 100) * 100 / MAX_PEAK; | 411 | return str(LANG_OFF); |
422 | } | ||
423 | *threshold += change; | ||
424 | if (*threshold > 100) { | ||
425 | *threshold = 0; | ||
426 | } else if (*threshold < 0) { | ||
427 | *threshold = 100; | ||
428 | } | 412 | } |
413 | return option_get_valuestring(s, buffer, buffer_len, temp); | ||
429 | } | 414 | } |
430 | } | 415 | } |
431 | 416 | static void trigger_speak_item(const struct settings_list *s, bool title) | |
432 | /** | ||
433 | * Displays a menu for editing the trigger settings. | ||
434 | */ | ||
435 | bool rectrigger(void) | ||
436 | { | 417 | { |
437 | int exit_request = false; | 418 | int temp; |
438 | enum trigger_menu_option selected = TRIGGER_MODE; | 419 | if (!global_settings.talk_menu) |
439 | bool retval = false; | 420 | return; |
440 | int old_x_margin[NB_SCREENS]; | 421 | temp = option_value_as_int(s); |
441 | int old_y_margin[NB_SCREENS]; | 422 | if (title) |
442 | 423 | talk_id(s->lang_id, false); | |
443 | #define TRIGGER_MODE_COUNT 3 | 424 | option_talk_value(s, temp, title?true:false); |
444 | static const unsigned char *trigger_modes[] = { | 425 | } |
445 | ID2P(LANG_OFF), | 426 | int rectrigger(void) |
446 | ID2P(LANG_RECORD_TRIG_NOREARM), | 427 | { |
447 | ID2P(LANG_REPEAT) | 428 | struct viewport vp[NB_SCREENS]; |
448 | }; | 429 | struct gui_synclist lists; |
449 | 430 | int i, action = ACTION_REDRAW; | |
450 | #define PRERECORD_TIMES_COUNT 31 | 431 | bool done = false, changed = true; |
451 | static const struct opt_items prerecord_times[] = { | 432 | const struct settings_list *settings[TRIG_OPTION_COUNT]; |
452 | { STR(LANG_OFF) }, | 433 | |
453 | #define T(x) { (unsigned char *)(#x "s"), TALK_ID(x, UNIT_SEC) } | 434 | int pm_y[NB_SCREENS]; |
454 | T(1), T(2), T(3), T(4), T(5), T(6), T(7), T(8), T(9), T(10), | 435 | int trig_xpos[NB_SCREENS]; |
455 | T(11), T(12), T(13), T(14), T(15), T(16), T(17), T(18), T(19), T(20), | 436 | int trig_ypos[NB_SCREENS]; |
456 | T(21), T(22), T(23), T(24), T(25), T(26), T(27), T(28), T(29), T(30), | 437 | int trig_width[NB_SCREENS]; |
457 | #undef T | 438 | |
458 | }; | 439 | int old_start_thres_db = global_settings.rec_start_thres_db; |
459 | 440 | int old_start_thres_linear = global_settings.rec_start_thres_linear; | |
460 | #define TRIGGER_TYPE_COUNT 3 | ||
461 | static const unsigned char *trigger_types[] = { | ||
462 | ID2P(LANG_RECORD_TRIGGER_STOP), | ||
463 | ID2P(LANG_PAUSE), | ||
464 | ID2P(LANG_RECORD_TRIGGER_NEWFILESTP), | ||
465 | }; | ||
466 | |||
467 | static const unsigned char *option_name[] = { | ||
468 | [TRIGGER_MODE] = ID2P(LANG_RECORD_TRIGGER), | ||
469 | [TRIGGER_TYPE] = ID2P(LANG_RECORD_TRIGGER_TYPE), | ||
470 | [PRERECORD_TIME] = ID2P(LANG_RECORD_PRERECORD_TIME), | ||
471 | [START_THRESHOLD] = ID2P(LANG_RECORD_START_THRESHOLD), | ||
472 | [START_DURATION] = ID2P(LANG_MIN_DURATION), | ||
473 | [STOP_THRESHOLD] = ID2P(LANG_RECORD_STOP_THRESHOLD), | ||
474 | [STOP_POSTREC] = ID2P(LANG_MIN_DURATION), | ||
475 | [STOP_GAP] = ID2P(LANG_RECORD_STOP_GAP) | ||
476 | }; | ||
477 | |||
478 | int old_start_thres = global_settings.rec_start_thres; | ||
479 | int old_start_duration = global_settings.rec_start_duration; | 441 | int old_start_duration = global_settings.rec_start_duration; |
480 | int old_prerecord_time = global_settings.rec_prerecord_time; | 442 | int old_prerecord_time = global_settings.rec_prerecord_time; |
481 | int old_stop_thres = global_settings.rec_stop_thres; | 443 | int old_stop_thres_db = global_settings.rec_stop_thres_db; |
444 | int old_stop_thres_linear = global_settings.rec_stop_thres_linear; | ||
482 | int old_stop_postrec = global_settings.rec_stop_postrec; | 445 | int old_stop_postrec = global_settings.rec_stop_postrec; |
483 | int old_stop_gap = global_settings.rec_stop_gap; | 446 | int old_stop_gap = global_settings.rec_stop_gap; |
484 | int old_trigger_mode = global_settings.rec_trigger_mode; | 447 | int old_trigger_mode = global_settings.rec_trigger_mode; |
485 | int old_trigger_type = global_settings.rec_trigger_type; | 448 | int old_trigger_type = global_settings.rec_trigger_type; |
486 | 449 | ||
487 | int offset[NB_SCREENS]; | ||
488 | int option_lines[NB_SCREENS]; | ||
489 | int w, h, i; | ||
490 | int stat_height = gui_statusbar_height(); | ||
491 | int pm_y[NB_SCREENS]; | ||
492 | |||
493 | int trig_xpos[NB_SCREENS]; | ||
494 | int trig_ypos[NB_SCREENS]; | ||
495 | int trig_width[NB_SCREENS]; | ||
496 | |||
497 | bool say_field = true, say_value = true; | ||
498 | |||
499 | FOR_NB_SCREENS(i) | 450 | FOR_NB_SCREENS(i) |
500 | { | 451 | { |
501 | offset[i] = 0; | 452 | screens[i].clear_display(); |
453 | screens[i].update(); | ||
454 | viewport_set_defaults(&vp[i], i); | ||
455 | vp[i].height -= SYSFONT_HEIGHT*2; | ||
502 | trig_xpos[i] = 0; | 456 | trig_xpos[i] = 0; |
503 | trig_ypos[i] = screens[i].height - stat_height - TRIG_HEIGHT; | 457 | trig_ypos[i] = vp[i].y + vp[i].height; |
504 | pm_y[i] = screens[i].height - stat_height; | 458 | pm_y[i] = screens[i].height - SYSFONT_HEIGHT; |
505 | trig_width[i] = screens[i].width; | 459 | trig_width[i] = screens[i].width; |
506 | } | 460 | } |
507 | 461 | /* TODO: what to do if there is < 4 lines on the screen? */ | |
462 | |||
463 | settings[TRIGGER_MODE] = | ||
464 | find_setting(&global_settings.rec_trigger_mode, NULL); | ||
465 | settings[TRIGGER_TYPE] = | ||
466 | find_setting(&global_settings.rec_trigger_type, NULL); | ||
467 | settings[PRERECORD_TIME] = | ||
468 | find_setting(&global_settings.rec_prerecord_time, NULL); | ||
469 | settings[START_DURATION] = | ||
470 | find_setting(&global_settings.rec_start_duration, NULL); | ||
471 | settings[STOP_POSTREC] = | ||
472 | find_setting(&global_settings.rec_stop_postrec, NULL); | ||
473 | settings[STOP_GAP] = | ||
474 | find_setting(&global_settings.rec_stop_gap, NULL); | ||
475 | if (global_settings.peak_meter_dbfs) /* show the dB settings */ | ||
476 | { | ||
477 | settings[START_THRESHOLD] = | ||
478 | find_setting(&global_settings.rec_start_thres_db, NULL); | ||
479 | settings[STOP_THRESHOLD] = | ||
480 | find_setting(&global_settings.rec_stop_thres_db, NULL); | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | settings[START_THRESHOLD] = | ||
485 | find_setting(&global_settings.rec_start_thres_linear, NULL); | ||
486 | settings[STOP_THRESHOLD] = | ||
487 | find_setting(&global_settings.rec_stop_thres_linear, NULL); | ||
488 | } | ||
489 | gui_synclist_init(&lists, trigger_get_name, settings, false, 2, vp); | ||
490 | gui_synclist_set_nb_items(&lists, TRIG_OPTION_COUNT*2); | ||
491 | gui_synclist_set_icon_callback(&lists, trigger_get_icon); | ||
508 | /* restart trigger with new values */ | 492 | /* restart trigger with new values */ |
509 | settings_apply_trigger(); | 493 | settings_apply_trigger(); |
510 | peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF); | 494 | peak_meter_trigger (global_settings.rec_trigger_mode != TRIG_MODE_OFF); |
495 | |||
496 | trigger_speak_item(settings[0], true); | ||
511 | 497 | ||
512 | FOR_NB_SCREENS(i) | 498 | while (!done) |
513 | { | 499 | { |
514 | screens[i].clear_display(); | 500 | if (changed) |
515 | |||
516 | old_x_margin[i] = screens[i].getxmargin(); | ||
517 | old_y_margin[i] = screens[i].getymargin(); | ||
518 | if(global_settings.statusbar) | ||
519 | screens[i].setmargins(0, STATUSBAR_HEIGHT); | ||
520 | else | ||
521 | screens[i].setmargins(0, 0); | ||
522 | |||
523 | screens[i].getstringsize("M", &w, &h); | ||
524 | |||
525 | // 16 pixels are reserved for peak meter and trigger status | ||
526 | option_lines[i] = MIN(((screens[i].height) - | ||
527 | stat_height - 16)/h, | ||
528 | TRIG_OPTION_COUNT); | ||
529 | } | ||
530 | |||
531 | while (!exit_request) { | ||
532 | int button, k; | ||
533 | const char *str; | ||
534 | char option_value[TRIG_OPTION_COUNT][16]; | ||
535 | |||
536 | snprintf( | ||
537 | option_value[TRIGGER_MODE], | ||
538 | sizeof option_value[TRIGGER_MODE], | ||
539 | "%s", | ||
540 | P2STR(trigger_modes[global_settings.rec_trigger_mode])); | ||
541 | |||
542 | snprintf( | ||
543 | option_value[TRIGGER_TYPE], | ||
544 | sizeof option_value[TRIGGER_TYPE], | ||
545 | "%s", | ||
546 | P2STR(trigger_types[global_settings.rec_trigger_type])); | ||
547 | |||
548 | snprintf ( | ||
549 | option_value[PRERECORD_TIME], | ||
550 | sizeof option_value[PRERECORD_TIME], | ||
551 | "%s", | ||
552 | P2STR(prerecord_times[global_settings.rec_prerecord_time].string)); | ||
553 | |||
554 | /* due to value range shift (peak_meter_define_trigger) -1 is 0db */ | ||
555 | if (global_settings.rec_start_thres == -1) { | ||
556 | str = str(LANG_OFF); | ||
557 | } else { | ||
558 | str = create_thres_str(global_settings.rec_start_thres, NULL); | ||
559 | } | ||
560 | snprintf( | ||
561 | option_value[START_THRESHOLD], | ||
562 | sizeof option_value[START_THRESHOLD], | ||
563 | "%s", | ||
564 | str); | ||
565 | |||
566 | snprintf( | ||
567 | option_value[START_DURATION], | ||
568 | sizeof option_value[START_DURATION], | ||
569 | "%s", | ||
570 | trig_durations[global_settings.rec_start_duration].string); | ||
571 | |||
572 | if (global_settings.rec_stop_thres <= INF_DB) { | ||
573 | str = str(LANG_OFF); | ||
574 | } else { | ||
575 | str = create_thres_str(global_settings.rec_stop_thres, NULL); | ||
576 | } | ||
577 | snprintf( | ||
578 | option_value[STOP_THRESHOLD], | ||
579 | sizeof option_value[STOP_THRESHOLD], | ||
580 | "%s", | ||
581 | str); | ||
582 | |||
583 | snprintf( | ||
584 | option_value[STOP_POSTREC], | ||
585 | sizeof option_value[STOP_POSTREC], | ||
586 | "%s", | ||
587 | trig_durations[global_settings.rec_stop_postrec].string); | ||
588 | |||
589 | snprintf( | ||
590 | option_value[STOP_GAP], | ||
591 | sizeof option_value[STOP_GAP], | ||
592 | "%s", | ||
593 | trig_durations[global_settings.rec_stop_gap].string); | ||
594 | |||
595 | FOR_NB_SCREENS(i) | ||
596 | { | 501 | { |
597 | screens[i].set_drawmode(DRMODE_SOLID|DRMODE_INVERSEVID); | 502 | gui_synclist_draw(&lists); |
598 | screens[i].fillrect(0, stat_height, screens[i].width, | 503 | gui_syncstatusbar_draw(&statusbars, true); |
599 | screens[i].height - stat_height); | 504 | peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF); |
600 | screens[i].set_drawmode(DRMODE_SOLID); | 505 | settings_apply_trigger(); |
506 | changed = false; | ||
601 | } | 507 | } |
602 | 508 | ||
603 | gui_syncstatusbar_draw(&statusbars, true); | ||
604 | |||
605 | /* reselect FONT_SYSFONT as status_draw has changed the font */ | ||
606 | /*lcd_setfont(FONT_SYSFIXED);*/ | ||
607 | |||
608 | FOR_NB_SCREENS(i) | ||
609 | { | ||
610 | for (k = 0; k < option_lines[i]; k++) { | ||
611 | int x, y; | ||
612 | |||
613 | str = P2STR(option_name[k + offset[i]]); | ||
614 | screens[i].putsxy((option_lines[i] < TRIG_OPTION_COUNT) ? 5 : 0, | ||
615 | stat_height + k * h, str); | ||
616 | |||
617 | str = option_value[k + offset[i]]; | ||
618 | screens[i].getstringsize(str, &w, &h); | ||
619 | y = stat_height + k * h; | ||
620 | x = screens[i].width - w; | ||
621 | screens[i].putsxy(x, y, str); | ||
622 | if ((int)selected == (k + offset[i])) { | ||
623 | screens[i].set_drawmode(DRMODE_COMPLEMENT); | ||
624 | screens[i].fillrect(x, y, w, h); | ||
625 | screens[i].set_drawmode(DRMODE_SOLID); | ||
626 | } | ||
627 | } | ||
628 | if (option_lines[i] < TRIG_OPTION_COUNT) | ||
629 | gui_scrollbar_draw(&screens[i], 0, stat_height, | ||
630 | 4, screens[i].height - 16 - stat_height, | ||
631 | TRIG_OPTION_COUNT, offset[i], offset[i] + option_lines[i], | ||
632 | VERTICAL); | ||
633 | } | ||
634 | |||
635 | bool enqueue = false; | ||
636 | if(say_field) { | ||
637 | talk_id(P2ID(option_name[selected]), enqueue); | ||
638 | enqueue = true; | ||
639 | } | ||
640 | if(say_value) { | ||
641 | long id; | ||
642 | switch(selected) { | ||
643 | case TRIGGER_MODE: | ||
644 | id = P2ID(trigger_modes[global_settings.rec_trigger_mode]); | ||
645 | break; | ||
646 | case TRIGGER_TYPE: | ||
647 | id = P2ID(trigger_types[global_settings.rec_trigger_type]); | ||
648 | break; | ||
649 | case PRERECORD_TIME: | ||
650 | id = prerecord_times[global_settings.rec_prerecord_time] | ||
651 | .voice_id; | ||
652 | break; | ||
653 | case START_THRESHOLD: | ||
654 | if (global_settings.rec_start_thres == -1) | ||
655 | id = LANG_OFF; | ||
656 | else create_thres_str(global_settings.rec_start_thres, &id); | ||
657 | break; | ||
658 | case START_DURATION: | ||
659 | id = trig_durations[global_settings.rec_start_duration] | ||
660 | .voice_id; | ||
661 | break; | ||
662 | case STOP_THRESHOLD: | ||
663 | if (global_settings.rec_stop_thres <= INF_DB) | ||
664 | id = LANG_OFF; | ||
665 | else create_thres_str(global_settings.rec_stop_thres, &id); | ||
666 | break; | ||
667 | case STOP_POSTREC: | ||
668 | id = trig_durations[global_settings.rec_stop_postrec].voice_id; | ||
669 | break; | ||
670 | case STOP_GAP: | ||
671 | id = trig_durations[global_settings.rec_stop_gap].voice_id; | ||
672 | break; | ||
673 | case TRIG_OPTION_COUNT: | ||
674 | // avoid compiler warnings | ||
675 | break; | ||
676 | }; | ||
677 | talk_id(id, enqueue); | ||
678 | } | ||
679 | say_field = say_value = false; | ||
680 | |||
681 | peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS); | 509 | peak_meter_draw_trig(trig_xpos, trig_ypos, trig_width, NB_SCREENS); |
682 | button = peak_meter_draw_get_btn(0, pm_y, 8, NB_SCREENS); | 510 | action = peak_meter_draw_get_btn(CONTEXT_SETTINGS_RECTRIGGER, 0, pm_y, |
683 | 511 | SYSFONT_HEIGHT, NB_SCREENS); | |
684 | FOR_NB_SCREENS(i) | 512 | FOR_NB_SCREENS(i) |
685 | screens[i].update(); | 513 | screens[i].update(); |
686 | 514 | i = gui_synclist_get_sel_pos(&lists); | |
687 | switch (button) { | 515 | switch (action) |
516 | { | ||
688 | case ACTION_STD_CANCEL: | 517 | case ACTION_STD_CANCEL: |
689 | gui_syncsplash(50, str(LANG_CANCEL)); | 518 | gui_syncsplash(HZ/2, str(LANG_CANCEL)); |
690 | global_settings.rec_start_thres = old_start_thres; | 519 | global_settings.rec_start_thres_db = old_start_thres_db; |
520 | global_settings.rec_start_thres_linear = old_start_thres_linear; | ||
691 | global_settings.rec_start_duration = old_start_duration; | 521 | global_settings.rec_start_duration = old_start_duration; |
692 | global_settings.rec_prerecord_time = old_prerecord_time; | 522 | global_settings.rec_prerecord_time = old_prerecord_time; |
693 | global_settings.rec_stop_thres = old_stop_thres; | 523 | global_settings.rec_stop_thres_db = old_stop_thres_db; |
524 | global_settings.rec_stop_thres_linear = old_stop_thres_linear; | ||
694 | global_settings.rec_stop_postrec = old_stop_postrec; | 525 | global_settings.rec_stop_postrec = old_stop_postrec; |
695 | global_settings.rec_stop_gap = old_stop_gap; | 526 | global_settings.rec_stop_gap = old_stop_gap; |
696 | global_settings.rec_trigger_mode = old_trigger_mode; | 527 | global_settings.rec_trigger_mode = old_trigger_mode; |
697 | global_settings.rec_trigger_type = old_trigger_type; | 528 | global_settings.rec_trigger_type = old_trigger_type; |
698 | exit_request = true; | ||
699 | break; | ||
700 | |||
701 | case ACTION_REC_PAUSE: | ||
702 | exit_request = true; | ||
703 | break; | ||
704 | |||
705 | case ACTION_STD_PREV: | ||
706 | selected += TRIG_OPTION_COUNT - 1; | ||
707 | selected %= TRIG_OPTION_COUNT; | ||
708 | FOR_NB_SCREENS(i) | ||
709 | { | ||
710 | offset[i] = MIN(offset[i], (int)selected); | ||
711 | offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1); | ||
712 | } | ||
713 | say_field = say_value = true; | ||
714 | break; | ||
715 | |||
716 | case ACTION_STD_NEXT: | ||
717 | selected ++; | ||
718 | selected %= TRIG_OPTION_COUNT; | ||
719 | FOR_NB_SCREENS(i) | ||
720 | { | ||
721 | offset[i] = MIN(offset[i], (int)selected); | ||
722 | offset[i] = MAX(offset[i], (int)selected - option_lines[i] + 1); | ||
723 | } | ||
724 | say_field = say_value = true; | ||
725 | break; | ||
726 | |||
727 | case ACTION_SETTINGS_INC: | ||
728 | switch (selected) { | ||
729 | case TRIGGER_MODE: | ||
730 | global_settings.rec_trigger_mode ++; | ||
731 | global_settings.rec_trigger_mode %= TRIGGER_MODE_COUNT; | ||
732 | break; | ||
733 | |||
734 | case TRIGGER_TYPE: | ||
735 | global_settings.rec_trigger_type ++; | ||
736 | global_settings.rec_trigger_type %= TRIGGER_TYPE_COUNT; | ||
737 | break; | ||
738 | |||
739 | case PRERECORD_TIME: | ||
740 | global_settings.rec_prerecord_time ++; | ||
741 | global_settings.rec_prerecord_time %= PRERECORD_TIMES_COUNT; | ||
742 | break; | ||
743 | |||
744 | case START_THRESHOLD: | ||
745 | change_threshold(&global_settings.rec_start_thres, 1); | ||
746 | break; | ||
747 | |||
748 | case START_DURATION: | ||
749 | global_settings.rec_start_duration ++; | ||
750 | global_settings.rec_start_duration %= TRIG_DURATION_COUNT; | ||
751 | break; | ||
752 | |||
753 | case STOP_THRESHOLD: | ||
754 | change_threshold(&global_settings.rec_stop_thres, 1); | ||
755 | break; | ||
756 | |||
757 | case STOP_POSTREC: | ||
758 | global_settings.rec_stop_postrec ++; | ||
759 | global_settings.rec_stop_postrec %= TRIG_DURATION_COUNT; | ||
760 | break; | ||
761 | |||
762 | case STOP_GAP: | ||
763 | global_settings.rec_stop_gap ++; | ||
764 | global_settings.rec_stop_gap %= TRIG_DURATION_COUNT; | ||
765 | break; | ||
766 | |||
767 | case TRIG_OPTION_COUNT: | ||
768 | // avoid compiler warnings | ||
769 | break; | ||
770 | } | ||
771 | peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF); | 529 | peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF); |
772 | settings_apply_trigger(); | 530 | settings_apply_trigger(); |
773 | say_value = true; | 531 | done = true; |
532 | break; | ||
533 | case ACTION_STD_OK: | ||
534 | done = true; | ||
774 | break; | 535 | break; |
775 | |||
776 | case ACTION_SETTINGS_DEC: | 536 | case ACTION_SETTINGS_DEC: |
777 | switch (selected) { | 537 | case ACTION_SETTINGS_DECREPEAT: |
778 | case TRIGGER_MODE: | 538 | option_select_next_val(settings[i/2], true, false); |
779 | global_settings.rec_trigger_mode+=TRIGGER_MODE_COUNT-1; | 539 | trigger_speak_item(settings[i/2], false); |
780 | global_settings.rec_trigger_mode %= TRIGGER_MODE_COUNT; | 540 | changed = true; |
781 | break; | ||
782 | |||
783 | case TRIGGER_TYPE: | ||
784 | global_settings.rec_trigger_type+=TRIGGER_TYPE_COUNT-1; | ||
785 | global_settings.rec_trigger_type %= TRIGGER_TYPE_COUNT; | ||
786 | break; | ||
787 | |||
788 | case PRERECORD_TIME: | ||
789 | global_settings.rec_prerecord_time += PRERECORD_TIMES_COUNT - 1; | ||
790 | global_settings.rec_prerecord_time %= PRERECORD_TIMES_COUNT; | ||
791 | break; | ||
792 | |||
793 | case START_THRESHOLD: | ||
794 | change_threshold(&global_settings.rec_start_thres, -1); | ||
795 | break; | ||
796 | |||
797 | case START_DURATION: | ||
798 | global_settings.rec_start_duration += TRIG_DURATION_COUNT-1; | ||
799 | global_settings.rec_start_duration %= TRIG_DURATION_COUNT; | ||
800 | break; | ||
801 | |||
802 | case STOP_THRESHOLD: | ||
803 | change_threshold(&global_settings.rec_stop_thres, -1); | ||
804 | break; | ||
805 | |||
806 | case STOP_POSTREC: | ||
807 | global_settings.rec_stop_postrec += | ||
808 | TRIG_DURATION_COUNT - 1; | ||
809 | global_settings.rec_stop_postrec %= | ||
810 | TRIG_DURATION_COUNT; | ||
811 | break; | ||
812 | |||
813 | case STOP_GAP: | ||
814 | global_settings.rec_stop_gap += | ||
815 | TRIG_DURATION_COUNT - 1; | ||
816 | global_settings.rec_stop_gap %= TRIG_DURATION_COUNT; | ||
817 | break; | ||
818 | |||
819 | case TRIG_OPTION_COUNT: | ||
820 | // avoid compiler warnings | ||
821 | break; | ||
822 | } | ||
823 | peak_meter_trigger(global_settings.rec_trigger_mode!=TRIG_OFF); | ||
824 | settings_apply_trigger(); | ||
825 | say_value = true; | ||
826 | break; | 541 | break; |
827 | 542 | case ACTION_SETTINGS_INC: | |
828 | case ACTION_REC_F2: | 543 | case ACTION_SETTINGS_INCREPEAT: |
829 | peak_meter_trigger(true); | 544 | option_select_next_val(settings[i/2], false, false); |
545 | trigger_speak_item(settings[i/2], false); | ||
546 | changed = true; | ||
830 | break; | 547 | break; |
831 | 548 | case ACTION_STD_PREV: | |
832 | case SYS_USB_CONNECTED: | 549 | case ACTION_STD_PREVREPEAT: |
833 | if(default_event_handler(button) == SYS_USB_CONNECTED) { | 550 | i -= 2; |
834 | retval = true; | 551 | if (i<0) |
835 | exit_request = true; | 552 | i = (TRIG_OPTION_COUNT*2) - 2; |
836 | } | 553 | gui_synclist_select_item(&lists, i); |
554 | i = gui_synclist_get_sel_pos(&lists); | ||
555 | trigger_speak_item(settings[i/2], true); | ||
556 | changed = true; | ||
557 | break; | ||
558 | case ACTION_STD_NEXT: | ||
559 | case ACTION_STD_NEXTREPEAT: | ||
560 | gui_synclist_select_item(&lists, (i+2) % (TRIG_OPTION_COUNT*2)); | ||
561 | i = gui_synclist_get_sel_pos(&lists); | ||
562 | trigger_speak_item(settings[i/2], true); | ||
563 | changed = true; | ||
837 | break; | 564 | break; |
838 | } | 565 | } |
839 | } | 566 | } |
840 | |||
841 | peak_meter_trigger(false); | 567 | peak_meter_trigger(false); |
842 | FOR_NB_SCREENS(i) | 568 | settings_save(); |
843 | { | 569 | return 0; |
844 | screens[i].setfont(FONT_UI); | ||
845 | screens[i].setmargins(old_x_margin[i], old_y_margin[i]); | ||
846 | } | ||
847 | return retval; | ||
848 | } | 570 | } |
849 | |||
850 | MENUITEM_FUNCTION(rectrigger_item, 0, ID2P(LANG_RECORD_TRIGGER), | 571 | MENUITEM_FUNCTION(rectrigger_item, 0, ID2P(LANG_RECORD_TRIGGER), |
851 | (int(*)(void))rectrigger, NULL, NULL, Icon_Menu_setting); | 572 | rectrigger, NULL, NULL, Icon_Menu_setting); |
852 | |||
853 | |||
854 | |||
855 | 573 | ||
856 | 574 | ||
857 | 575 | ||
diff --git a/apps/recorder/peakmeter.c b/apps/recorder/peakmeter.c index 3e85fd5509..9014e5c351 100644 --- a/apps/recorder/peakmeter.c +++ b/apps/recorder/peakmeter.c | |||
@@ -1318,7 +1318,8 @@ void peak_meter_draw_trig(int xpos[], int ypos[], int trig_width[], int nb_scree | |||
1318 | } | 1318 | } |
1319 | #endif | 1319 | #endif |
1320 | 1320 | ||
1321 | int peak_meter_draw_get_btn(int x, int y[], int height, int nb_screens) | 1321 | int peak_meter_draw_get_btn(int action_context, int x, int y[], |
1322 | int height, int nb_screens) | ||
1322 | { | 1323 | { |
1323 | int button = BUTTON_NONE; | 1324 | int button = BUTTON_NONE; |
1324 | long next_refresh = current_tick; | 1325 | long next_refresh = current_tick; |
@@ -1337,7 +1338,7 @@ int peak_meter_draw_get_btn(int x, int y[], int height, int nb_screens) | |||
1337 | bool dopeek = true; | 1338 | bool dopeek = true; |
1338 | 1339 | ||
1339 | while (TIME_BEFORE(current_tick, next_big_refresh)) { | 1340 | while (TIME_BEFORE(current_tick, next_big_refresh)) { |
1340 | button = get_action(CONTEXT_RECSCREEN, TIMEOUT_NOBLOCK); | 1341 | button = get_action(action_context, TIMEOUT_NOBLOCK); |
1341 | if (button != BUTTON_NONE) { | 1342 | if (button != BUTTON_NONE) { |
1342 | break; | 1343 | break; |
1343 | } | 1344 | } |
diff --git a/apps/recorder/peakmeter.h b/apps/recorder/peakmeter.h index 9aa32905c1..2d63aefa75 100644 --- a/apps/recorder/peakmeter.h +++ b/apps/recorder/peakmeter.h | |||
@@ -33,7 +33,8 @@ extern void pm_activate_clipcount(bool active); | |||
33 | extern bool peak_meter_enabled; | 33 | extern bool peak_meter_enabled; |
34 | 34 | ||
35 | extern void peak_meter_playback(bool playback); | 35 | extern void peak_meter_playback(bool playback); |
36 | extern int peak_meter_draw_get_btn(int x, int y[], int height, int nb_screens); | 36 | extern int peak_meter_draw_get_btn(int action_context, int x, int y[], |
37 | int height, int nb_screens); | ||
37 | extern void peak_meter_set_clip_hold(int time); | 38 | extern void peak_meter_set_clip_hold(int time); |
38 | extern void peak_meter_peek(void); | 39 | extern void peak_meter_peek(void); |
39 | extern void peak_meter_init_range( bool dbfs, int range_min, int range_max); | 40 | extern void peak_meter_init_range( bool dbfs, int range_min, int range_max); |
diff --git a/apps/recorder/recording.c b/apps/recorder/recording.c index c2b2360df1..28b3a44b3a 100644 --- a/apps/recorder/recording.c +++ b/apps/recorder/recording.c | |||
@@ -121,37 +121,28 @@ static unsigned long rec_sizesplit_bytes(void) | |||
121 | { | 121 | { |
122 | return rec_size_bytes[global_settings.rec_sizesplit]; | 122 | return rec_size_bytes[global_settings.rec_sizesplit]; |
123 | } | 123 | } |
124 | /* | ||
125 | * Time strings used for the trigger durations. | ||
126 | * Keep synchronous to trigger_times in settings_apply_trigger | ||
127 | */ | ||
128 | const struct opt_items trig_durations[TRIG_DURATION_COUNT] = | ||
129 | { | ||
130 | #define TS(x) { (unsigned char *)(#x "s"), TALK_ID(x, UNIT_SEC) } | ||
131 | #define TM(x) { (unsigned char *)(#x "min"), TALK_ID(x, UNIT_MIN) } | ||
132 | TS(0), TS(1), TS(2), TS(5), | ||
133 | TS(10), TS(15), TS(20), TS(25), TS(30), | ||
134 | TM(1), TM(2), TM(5), TM(10) | ||
135 | #undef TS | ||
136 | #undef TM | ||
137 | }; | ||
138 | 124 | ||
139 | void settings_apply_trigger(void) | 125 | void settings_apply_trigger(void) |
140 | { | 126 | { |
141 | /* Keep synchronous to trig_durations and trig_durations_conf*/ | 127 | int start_thres, stop_thres; |
142 | static const long trigger_times[TRIG_DURATION_COUNT] = { | 128 | if (global_settings.peak_meter_dbfs) |
143 | 0, HZ, 2*HZ, 5*HZ, | 129 | { |
144 | 10*HZ, 15*HZ, 20*HZ, 25*HZ, 30*HZ, | 130 | start_thres = global_settings.rec_start_thres_db - 1; |
145 | 60*HZ, 2*60*HZ, 5*60*HZ, 10*60*HZ | 131 | stop_thres = global_settings.rec_stop_thres_db - 1; |
146 | }; | 132 | } |
133 | else | ||
134 | { | ||
135 | start_thres = global_settings.rec_start_thres_linear; | ||
136 | stop_thres = global_settings.rec_stop_thres_linear; | ||
137 | } | ||
147 | 138 | ||
148 | peak_meter_define_trigger( | 139 | peak_meter_define_trigger( |
149 | global_settings.rec_start_thres, | 140 | start_thres, |
150 | trigger_times[global_settings.rec_start_duration], | 141 | global_settings.rec_start_duration*HZ, |
151 | MIN(trigger_times[global_settings.rec_start_duration] / 2, 2*HZ), | 142 | MIN(global_settings.rec_start_duration*HZ / 2, 2*HZ), |
152 | global_settings.rec_stop_thres, | 143 | stop_thres, |
153 | trigger_times[global_settings.rec_stop_postrec], | 144 | global_settings.rec_stop_postrec*HZ, |
154 | trigger_times[global_settings.rec_stop_gap] | 145 | global_settings.rec_stop_gap*HZ |
155 | ); | 146 | ); |
156 | } | 147 | } |
157 | /* recording screen status flags */ | 148 | /* recording screen status flags */ |
@@ -784,12 +775,12 @@ static void trigger_listener(int trigger_status) | |||
784 | else | 775 | else |
785 | { | 776 | { |
786 | if((audio_status() & AUDIO_STATUS_PAUSE) && | 777 | if((audio_status() & AUDIO_STATUS_PAUSE) && |
787 | (global_settings.rec_trigger_type == 1)) | 778 | (global_settings.rec_trigger_type == TRIG_TYPE_PAUSE)) |
788 | { | 779 | { |
789 | rec_command(RECORDING_CMD_RESUME); | 780 | rec_command(RECORDING_CMD_RESUME); |
790 | } | 781 | } |
791 | /* New file on trig start*/ | 782 | /* New file on trig start*/ |
792 | else if (global_settings.rec_trigger_type != 2) | 783 | else if (global_settings.rec_trigger_type != TRIG_TYPE_NEW_FILE) |
793 | { | 784 | { |
794 | rec_command(RECORDING_CMD_START_NEWFILE); | 785 | rec_command(RECORDING_CMD_START_NEWFILE); |
795 | /* tell recording_screen to reset the time */ | 786 | /* tell recording_screen to reset the time */ |
@@ -804,15 +795,15 @@ static void trigger_listener(int trigger_status) | |||
804 | { | 795 | { |
805 | switch(global_settings.rec_trigger_type) | 796 | switch(global_settings.rec_trigger_type) |
806 | { | 797 | { |
807 | case 0: /* Stop */ | 798 | case TRIG_TYPE_STOP: /* Stop */ |
808 | rec_command(RECORDING_CMD_STOP); | 799 | rec_command(RECORDING_CMD_STOP); |
809 | break; | 800 | break; |
810 | 801 | ||
811 | case 1: /* Pause */ | 802 | case TRIG_TYPE_PAUSE: /* Pause */ |
812 | rec_command(RECORDING_CMD_PAUSE); | 803 | rec_command(RECORDING_CMD_PAUSE); |
813 | break; | 804 | break; |
814 | 805 | ||
815 | case 2: /* New file on trig stop*/ | 806 | case TRIG_TYPE_NEW_FILE: /* New file on trig stop*/ |
816 | rec_command(RECORDING_CMD_START_NEWFILE); | 807 | rec_command(RECORDING_CMD_START_NEWFILE); |
817 | /* tell recording_screen to reset the time */ | 808 | /* tell recording_screen to reset the time */ |
818 | last_seconds = 0; | 809 | last_seconds = 0; |
@@ -1036,7 +1027,8 @@ bool recording_screen(bool no_source) | |||
1036 | #endif /* CONFIG_LED */ | 1027 | #endif /* CONFIG_LED */ |
1037 | 1028 | ||
1038 | /* Wait for a button a while (HZ/10) drawing the peak meter */ | 1029 | /* Wait for a button a while (HZ/10) drawing the peak meter */ |
1039 | button = peak_meter_draw_get_btn(pm_x, pm_y, h * PM_HEIGHT, | 1030 | button = peak_meter_draw_get_btn(CONTEXT_RECSCREEN, |
1031 | pm_x, pm_y, h * PM_HEIGHT, | ||
1040 | screen_update); | 1032 | screen_update); |
1041 | 1033 | ||
1042 | if (last_audio_stat != audio_stat) | 1034 | if (last_audio_stat != audio_stat) |
diff --git a/apps/settings.h b/apps/settings.h index 9a9169a74f..320e2b0517 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -90,12 +90,19 @@ struct opt_items { | |||
90 | #define BOOKMARK_RECENT_ONLY_YES 3 | 90 | #define BOOKMARK_RECENT_ONLY_YES 3 |
91 | #define BOOKMARK_RECENT_ONLY_ASK 4 | 91 | #define BOOKMARK_RECENT_ONLY_ASK 4 |
92 | 92 | ||
93 | #define TRIG_MODE_OFF 0 | 93 | enum |
94 | #define TRIG_MODE_NOREARM 1 | 94 | { |
95 | #define TRIG_MODE_REARM 2 | 95 | TRIG_MODE_OFF = 0, |
96 | TRIG_MODE_NOREARM, | ||
97 | TRIG_MODE_REARM | ||
98 | }; | ||
96 | 99 | ||
97 | #define TRIG_DURATION_COUNT 13 | 100 | enum |
98 | extern const struct opt_items trig_durations[TRIG_DURATION_COUNT]; | 101 | { |
102 | TRIG_TYPE_STOP = 0, | ||
103 | TRIG_TYPE_PAUSE, | ||
104 | TRIG_TYPE_NEW_FILE | ||
105 | }; | ||
99 | 106 | ||
100 | #define CROSSFADE_ENABLE_SHUFFLE 1 | 107 | #define CROSSFADE_ENABLE_SHUFFLE 1 |
101 | #define CROSSFADE_ENABLE_TRACKSKIP 2 | 108 | #define CROSSFADE_ENABLE_TRACKSKIP 2 |
@@ -354,10 +361,12 @@ struct user_settings | |||
354 | 2 = main and remote lcd | 361 | 2 = main and remote lcd |
355 | 3 = remote lcd */ | 362 | 3 = remote lcd */ |
356 | 363 | ||
357 | int rec_start_thres; /* negative: db, positive: % range -87 .. 100 */ | 364 | int rec_start_thres_db; |
365 | int rec_start_thres_linear; | ||
358 | int rec_start_duration; /* index of trig_durations */ | 366 | int rec_start_duration; /* index of trig_durations */ |
359 | int rec_stop_thres; /* negative: db, positive: % */ | 367 | int rec_stop_thres_db; |
360 | int rec_stop_postrec; /* negative: db, positive: % range -87 .. 100 */ | 368 | int rec_stop_thres_linear; |
369 | int rec_stop_postrec; | ||
361 | int rec_stop_gap; /* index of trig_durations */ | 370 | int rec_stop_gap; /* index of trig_durations */ |
362 | int rec_trigger_mode; /* see TRIG_MODE_XXX constants */ | 371 | int rec_trigger_mode; /* see TRIG_MODE_XXX constants */ |
363 | int rec_trigger_type; /* what to do when trigger released */ | 372 | int rec_trigger_type; /* what to do when trigger released */ |
diff --git a/apps/settings_list.c b/apps/settings_list.c index 17ca714e76..8576c5b926 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c | |||
@@ -207,10 +207,6 @@ static const char graphic_numeric[] = "graphic,numeric"; | |||
207 | #define DEFAULT_BACKDROP "cabbiev2" | 207 | #define DEFAULT_BACKDROP "cabbiev2" |
208 | 208 | ||
209 | #ifdef HAVE_RECORDING | 209 | #ifdef HAVE_RECORDING |
210 | /* keep synchronous to trig_durations and | ||
211 | trigger_times in settings_apply_trigger */ | ||
212 | static const char trig_durations_conf [] = | ||
213 | "0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min"; | ||
214 | /* these should be in the config.h files */ | 210 | /* these should be in the config.h files */ |
215 | #if CONFIG_CODEC == MAS3587F | 211 | #if CONFIG_CODEC == MAS3587F |
216 | # define DEFAULT_REC_MIC_GAIN 8 | 212 | # define DEFAULT_REC_MIC_GAIN 8 |
@@ -918,24 +914,35 @@ const struct settings_list settings[] = { | |||
918 | /** Encoder settings end **/ | 914 | /** Encoder settings end **/ |
919 | #endif /* CONFIG_CODEC == SWCODEC */ | 915 | #endif /* CONFIG_CODEC == SWCODEC */ |
920 | /* values for the trigger */ | 916 | /* values for the trigger */ |
921 | {F_T_INT|F_RECSETTING,&global_settings.rec_start_thres, | 917 | INT_SETTING(F_RECSETTING, rec_start_thres_db, LANG_RECORD_START_THRESHOLD, -35, |
922 | LANG_RECORD_START_THRESHOLD, INT(-35), | 918 | "trigger start threshold dB", UNIT_DB, VOLUME_MIN/10, 0, -1, NULL, NULL, NULL), |
923 | "trigger start threshold",NULL,UNUSED}, | 919 | INT_SETTING(F_RECSETTING, rec_start_thres_linear, LANG_RECORD_START_THRESHOLD, 5, |
924 | {F_T_INT|F_RECSETTING,&global_settings.rec_stop_thres, | 920 | "trigger start threshold linear", UNIT_PERCENT, 0, 100, 1, NULL, NULL, NULL), |
925 | LANG_RECORD_STOP_THRESHOLD,INT(-45), | 921 | INT_SETTING(F_RECSETTING, rec_stop_thres_db, LANG_RECORD_STOP_THRESHOLD, -45, |
926 | "trigger stop threshold",NULL,UNUSED}, | 922 | "trigger stop threshold dB", UNIT_DB, VOLUME_MIN/10, 0, -1, NULL, NULL, NULL), |
927 | {F_T_INT|F_RECSETTING,&global_settings.rec_start_duration, | 923 | INT_SETTING(F_RECSETTING, rec_stop_thres_linear, LANG_RECORD_STOP_THRESHOLD, 10, |
928 | LANG_MIN_DURATION,INT(0), | 924 | "trigger stop threshold linear", UNIT_PERCENT, 0, 100, 1, NULL, NULL, NULL), |
929 | "trigger start duration",trig_durations_conf,UNUSED}, | 925 | TABLE_SETTING(F_RECSETTING, rec_start_duration, LANG_MIN_DURATION, 0, |
930 | {F_T_INT|F_RECSETTING,&global_settings.rec_stop_postrec, | 926 | "trigger start duration", |
931 | LANG_MIN_DURATION,INT(2), | 927 | "0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min", |
932 | "trigger stop postrec",trig_durations_conf,UNUSED}, | 928 | UNIT_SEC, NULL, NULL, NULL, 13, |
933 | {F_T_INT|F_RECSETTING,&global_settings.rec_stop_gap, | 929 | 0,1,2,5,10,15,20,25,30,60,120,300,600), |
934 | LANG_RECORD_STOP_GAP,INT(1), | 930 | TABLE_SETTING(F_RECSETTING, rec_stop_postrec, LANG_MIN_DURATION, 0, |
935 | "trigger min gap",trig_durations_conf,UNUSED}, | 931 | "trigger stop duration", |
936 | {F_T_INT|F_RECSETTING,&global_settings.rec_trigger_mode, | 932 | "0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min", |
937 | LANG_RECORD_TRIGGER,INT(0), | 933 | UNIT_SEC, NULL, NULL, NULL, 13, |
938 | "trigger mode","off,once,repeat",UNUSED}, | 934 | 0,1,2,5,10,15,20,25,30,60,120,300,600), |
935 | TABLE_SETTING(F_RECSETTING, rec_stop_gap, LANG_RECORD_STOP_GAP, 1, | ||
936 | "trigger min gap", | ||
937 | "0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min", | ||
938 | UNIT_SEC, NULL, NULL, NULL, 13, | ||
939 | 0,1,2,5,10,15,20,25,30,60,120,300,600), | ||
940 | CHOICE_SETTING(F_RECSETTING, rec_trigger_mode, LANG_RECORD_TRIGGER, TRIG_MODE_OFF, | ||
941 | "trigger mode","off,once,repeat", NULL ,3, | ||
942 | ID2P(LANG_OFF), ID2P(LANG_RECORD_TRIG_NOREARM), ID2P(LANG_REPEAT)), | ||
943 | CHOICE_SETTING(F_RECSETTING, rec_trigger_type, LANG_RECORD_TRIGGER_TYPE, TRIG_TYPE_STOP, | ||
944 | "trigger mode","off,once,repeat", NULL ,3, | ||
945 | ID2P(LANG_RECORD_TRIGGER_STOP), ID2P(LANG_PAUSE), ID2P(LANG_RECORD_TRIGGER_NEWFILESTP)), | ||
939 | #endif /* HAVE_RECORDING */ | 946 | #endif /* HAVE_RECORDING */ |
940 | 947 | ||
941 | #ifdef HAVE_SPDIF_POWER | 948 | #ifdef HAVE_SPDIF_POWER |
@@ -1192,14 +1199,6 @@ const struct settings_list settings[] = { | |||
1192 | 1199 | ||
1193 | OFFON_SETTING(0, audioscrobbler, LANG_AUDIOSCROBBLER, false, | 1200 | OFFON_SETTING(0, audioscrobbler, LANG_AUDIOSCROBBLER, false, |
1194 | "Last.fm Logging", NULL), | 1201 | "Last.fm Logging", NULL), |
1195 | |||
1196 | #ifdef HAVE_RECORDING | ||
1197 | {F_T_INT|F_RECSETTING,&global_settings.rec_trigger_type, | ||
1198 | LANG_RECORD_TRIGGER_TYPE, INT(0), | ||
1199 | "trigger type","stop,pause,nf stp",UNUSED}, | ||
1200 | #endif | ||
1201 | |||
1202 | /** settings not in the old config blocks **/ | ||
1203 | #if CONFIG_TUNER | 1202 | #if CONFIG_TUNER |
1204 | FILENAME_SETTING(0, fmr_file, "fmr", "", | 1203 | FILENAME_SETTING(0, fmr_file, "fmr", "", |
1205 | FMPRESET_PATH "/", ".fmr", MAX_FILENAME+1), | 1204 | FMPRESET_PATH "/", ".fmr", MAX_FILENAME+1), |
diff --git a/apps/sound_menu.h b/apps/sound_menu.h index 2bf1016e4c..5f4cbb8afd 100644 --- a/apps/sound_menu.h +++ b/apps/sound_menu.h | |||
@@ -22,6 +22,6 @@ | |||
22 | #include "menu.h" | 22 | #include "menu.h" |
23 | 23 | ||
24 | bool recording_menu(bool no_source); | 24 | bool recording_menu(bool no_source); |
25 | bool rectrigger(void); | 25 | int rectrigger(void); |
26 | 26 | ||
27 | #endif | 27 | #endif |