1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Jonathan Gordon
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
26 #include "appevents.h"
33 #ifdef HAVE_LCD_BITMAP
34 #include "peakmeter.h"
38 #include "lcd-remote.h"
39 #ifdef HAVE_TOUCHSCREEN
43 #include "statusbar.h" /* statusbar_vals enum*/
46 static int filterfirstkeypress_callback(int action
,const struct menu_item_ex
*this_item
)
51 case ACTION_EXIT_MENUITEM
:
52 set_backlight_filter_keypress(global_settings
.bl_filter_first_keypress
);
53 #ifdef HAVE_REMOTE_LCD
54 set_remote_backlight_filter_keypress(
55 global_settings
.remote_bl_filter_first_keypress
);
64 static int flipdisplay_callback(int action
,const struct menu_item_ex
*this_item
)
69 case ACTION_EXIT_MENUITEM
:
70 button_set_flip(global_settings
.flip_display
);
71 lcd_set_flip(global_settings
.flip_display
);
73 #ifdef HAVE_REMOTE_LCD
74 lcd_remote_set_flip(global_settings
.remote_flip_display
);
83 /***********************************/
86 MENUITEM_SETTING(backlight_timeout
, &global_settings
.backlight_timeout
, NULL
);
88 MENUITEM_SETTING(backlight_timeout_plugged
,
89 &global_settings
.backlight_timeout_plugged
, NULL
);
91 #ifdef HAS_BUTTON_HOLD
92 MENUITEM_SETTING(backlight_on_button_hold
,
93 &global_settings
.backlight_on_button_hold
, NULL
);
95 MENUITEM_SETTING(caption_backlight
, &global_settings
.caption_backlight
, NULL
);
96 #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
97 || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
98 MENUITEM_SETTING(backlight_fade_in
, &global_settings
.backlight_fade_in
, NULL
);
99 MENUITEM_SETTING(backlight_fade_out
, &global_settings
.backlight_fade_out
, NULL
);
101 MENUITEM_SETTING(bl_filter_first_keypress
,
102 &global_settings
.bl_filter_first_keypress
,
103 filterfirstkeypress_callback
);
104 #ifdef HAVE_LCD_SLEEP_SETTING
105 MENUITEM_SETTING(lcd_sleep_after_backlight_off
,
106 &global_settings
.lcd_sleep_after_backlight_off
, NULL
);
108 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
109 MENUITEM_SETTING(brightness_item
, &global_settings
.brightness
, NULL
);
111 #endif /* HAVE_BACKLIGHT */
112 #ifdef HAVE_LCD_CONTRAST
113 MENUITEM_SETTING(contrast
, &global_settings
.contrast
, NULL
);
115 #ifdef HAVE_LCD_BITMAP
116 #ifdef HAVE_LCD_INVERT
117 MENUITEM_SETTING(invert
, &global_settings
.invert
, NULL
);
120 MENUITEM_SETTING(flip_display
, &global_settings
.flip_display
, flipdisplay_callback
);
122 #endif /* HAVE_LCD_BITMAP */
124 /* now the actual menu */
125 MAKE_MENU(lcd_settings
,ID2P(LANG_LCD_MENU
),
126 NULL
, Icon_Display_menu
127 #ifdef HAVE_BACKLIGHT
130 ,&backlight_timeout_plugged
132 # ifdef HAS_BUTTON_HOLD
133 ,&backlight_on_button_hold
136 #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
137 || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
138 ,&backlight_fade_in
, &backlight_fade_out
140 ,&bl_filter_first_keypress
141 # ifdef HAVE_LCD_SLEEP_SETTING
142 ,&lcd_sleep_after_backlight_off
144 # ifdef HAVE_BACKLIGHT_BRIGHTNESS
147 #endif /* HAVE_BACKLIGHT */
148 #ifdef HAVE_LCD_CONTRAST
151 #ifdef HAVE_LCD_BITMAP
152 # ifdef HAVE_LCD_INVERT
155 # ifdef HAVE_LCD_FLIP
158 #endif /* HAVE_LCD_BITMAP */
161 /***********************************/
164 /********************************/
165 /* Remote LCD settings menu */
166 #ifdef HAVE_REMOTE_LCD
167 MENUITEM_SETTING(remote_backlight_timeout
,
168 &global_settings
.remote_backlight_timeout
, NULL
);
171 MENUITEM_SETTING(remote_backlight_timeout_plugged
,
172 &global_settings
.remote_backlight_timeout_plugged
, NULL
);
175 #ifdef HAS_REMOTE_BUTTON_HOLD
176 MENUITEM_SETTING(remote_backlight_on_button_hold
,
177 &global_settings
.remote_backlight_on_button_hold
, NULL
);
180 MENUITEM_SETTING(remote_caption_backlight
,
181 &global_settings
.remote_caption_backlight
, NULL
);
182 MENUITEM_SETTING(remote_bl_filter_first_keypress
,
183 &global_settings
.remote_bl_filter_first_keypress
,
184 filterfirstkeypress_callback
);
185 MENUITEM_SETTING(remote_contrast
,
186 &global_settings
.remote_contrast
, NULL
);
187 MENUITEM_SETTING(remote_invert
,
188 &global_settings
.remote_invert
, NULL
);
191 MENUITEM_SETTING(remote_flip_display
,
192 &global_settings
.remote_flip_display
, flipdisplay_callback
);
195 #ifdef HAVE_REMOTE_LCD_TICKING
196 static int ticking_callback(int action
,const struct menu_item_ex
*this_item
)
201 case ACTION_EXIT_MENUITEM
:
202 lcd_remote_emireduce(global_settings
.remote_reduce_ticking
);
207 MENUITEM_SETTING(remote_reduce_ticking
,
208 &global_settings
.remote_reduce_ticking
, ticking_callback
);
211 MAKE_MENU(lcd_remote_settings
, ID2P(LANG_LCD_REMOTE_MENU
),
212 NULL
, Icon_Remote_Display_menu
,
213 &remote_backlight_timeout
,
215 &remote_backlight_timeout_plugged
,
217 #ifdef HAS_REMOTE_BUTTON_HOLD
218 &remote_backlight_on_button_hold
,
220 &remote_caption_backlight
, &remote_bl_filter_first_keypress
,
221 &remote_contrast
, &remote_invert
224 ,&remote_flip_display
226 #ifdef HAVE_REMOTE_LCD_TICKING
227 ,&remote_reduce_ticking
231 #endif /* HAVE_REMOTE_LCD */
232 /* Remote LCD settings menu */
233 /********************************/
235 /***********************************/
237 MENUITEM_SETTING_W_TEXT(scroll_speed
, &global_settings
.scroll_speed
,
238 ID2P(LANG_SCROLL
), NULL
);
239 MENUITEM_SETTING(scroll_delay
, &global_settings
.scroll_delay
, NULL
);
240 #ifdef HAVE_LCD_BITMAP
241 MENUITEM_SETTING_W_TEXT(scroll_step
, &global_settings
.scroll_step
,
242 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
244 MENUITEM_SETTING(bidir_limit
, &global_settings
.bidir_limit
, NULL
);
245 #ifdef HAVE_REMOTE_LCD
246 MENUITEM_SETTING_W_TEXT(remote_scroll_speed
, &global_settings
.remote_scroll_speed
,
247 ID2P(LANG_SCROLL
), NULL
);
248 MENUITEM_SETTING(remote_scroll_delay
, &global_settings
.remote_scroll_delay
, NULL
);
249 MENUITEM_SETTING_W_TEXT(remote_scroll_step
, &global_settings
.remote_scroll_step
,
250 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
251 MENUITEM_SETTING(remote_bidir_limit
, &global_settings
.remote_bidir_limit
, NULL
);
253 MAKE_MENU(remote_scroll_sets
, ID2P(LANG_REMOTE_SCROLL_SETS
), 0, Icon_NOICON
,
254 &remote_scroll_speed
, &remote_scroll_delay
,
255 &remote_scroll_step
, &remote_bidir_limit
);
256 #endif /* HAVE_REMOTE_LCD */
257 #ifdef HAVE_LCD_CHARCELLS
258 MENUITEM_SETTING(jump_scroll
, &global_settings
.jump_scroll
, NULL
);
259 MENUITEM_SETTING(jump_scroll_delay
, &global_settings
.jump_scroll_delay
, NULL
);
261 /* list acceleration */
262 #ifndef HAVE_WHEEL_ACCELERATION
263 MENUITEM_SETTING(list_accel_start_delay
,
264 &global_settings
.list_accel_start_delay
, NULL
);
265 MENUITEM_SETTING(list_accel_wait
, &global_settings
.list_accel_wait
, NULL
);
266 #endif /* HAVE_WHEEL_ACCELERATION */
267 #ifdef HAVE_LCD_BITMAP
268 static int screenscroll_callback(int action
,const struct menu_item_ex
*this_item
)
273 case ACTION_EXIT_MENUITEM
:
274 gui_list_screen_scroll_out_of_view(global_settings
.offset_out_of_view
);
279 MENUITEM_SETTING(offset_out_of_view
, &global_settings
.offset_out_of_view
,
280 screenscroll_callback
);
281 MENUITEM_SETTING(screen_scroll_step
, &global_settings
.screen_scroll_step
, NULL
);
283 MENUITEM_SETTING(scroll_paginated
, &global_settings
.scroll_paginated
, NULL
);
285 MAKE_MENU(scroll_settings_menu
, ID2P(LANG_SCROLL_MENU
), 0, Icon_NOICON
,
286 &scroll_speed
, &scroll_delay
,
287 #ifdef HAVE_LCD_BITMAP
291 #ifdef HAVE_REMOTE_LCD
294 #ifdef HAVE_LCD_CHARCELLS
295 &jump_scroll
, &jump_scroll_delay
,
297 #ifdef HAVE_LCD_BITMAP
298 &offset_out_of_view
, &screen_scroll_step
,
301 #ifndef HAVE_WHEEL_ACCELERATION
302 &list_accel_start_delay
, &list_accel_wait
306 /***********************************/
308 /***********************************/
310 #ifdef HAVE_LCD_BITMAP
311 static int statusbar_callback_ex(int action
,const struct menu_item_ex
*this_item
,
312 enum screen_type screen
)
315 /* we save the old statusbar value here, so the old statusbars can get
316 * removed and cleared from the display properly on exiting
317 * (in gui_statusbar_changed() ) */
318 static enum statusbar_values old_bar
[NB_SCREENS
];
321 case ACTION_ENTER_MENUITEM
:
322 #ifdef HAVE_REMOTE_LCD
323 if (screen
== SCREEN_REMOTE
)
324 old_bar
[screen
] = global_settings
.remote_statusbar
;
327 old_bar
[screen
] = global_settings
.statusbar
;
329 case ACTION_EXIT_MENUITEM
:
330 gui_statusbar_changed(screen
, old_bar
[screen
]);
331 send_event(GUI_EVENT_STATUSBAR_TOGGLE
, NULL
);
332 send_event(GUI_EVENT_ACTIONUPDATE
, (void*)true);
338 #ifdef HAVE_REMOTE_LCD
339 static int statusbar_callback_remote(int action
,const struct menu_item_ex
*this_item
)
341 return statusbar_callback_ex(action
, this_item
, SCREEN_REMOTE
);
344 static int statusbar_callback(int action
,const struct menu_item_ex
*this_item
)
346 return statusbar_callback_ex(action
, this_item
, SCREEN_MAIN
);
348 MENUITEM_SETTING(scrollbar_item
, &global_settings
.scrollbar
, NULL
);
349 MENUITEM_SETTING(scrollbar_width
, &global_settings
.scrollbar_width
, NULL
);
350 MENUITEM_SETTING(statusbar
, &global_settings
.statusbar
,
352 #ifdef HAVE_REMOTE_LCD
353 MENUITEM_SETTING(remote_statusbar
, &global_settings
.remote_statusbar
,
354 statusbar_callback_remote
);
356 #if CONFIG_KEYPAD == RECORDER_PAD
357 MENUITEM_SETTING(buttonbar
, &global_settings
.buttonbar
, NULL
);
359 MENUITEM_SETTING(volume_type
, &global_settings
.volume_type
, NULL
);
360 MENUITEM_SETTING(battery_display
, &global_settings
.battery_display
, NULL
);
361 MAKE_MENU(bars_menu
, ID2P(LANG_BARS_MENU
), 0, Icon_NOICON
,
362 &scrollbar_item
, &scrollbar_width
, &statusbar
,
363 #ifdef HAVE_REMOTE_LCD
366 #if CONFIG_KEYPAD == RECORDER_PAD
369 &volume_type
, &battery_display
);
370 #endif /* HAVE_LCD_BITMAP */
372 /***********************************/
375 /***********************************/
376 /* PEAK METER MENU */
378 #ifdef HAVE_LCD_BITMAP
379 static int peakmeter_callback(int action
,const struct menu_item_ex
*this_item
)
384 case ACTION_EXIT_MENUITEM
:
385 peak_meter_init_times(global_settings
.peak_meter_release
,
386 global_settings
.peak_meter_hold
,
387 global_settings
.peak_meter_clip_hold
);
392 MENUITEM_SETTING(peak_meter_hold
,
393 &global_settings
.peak_meter_hold
, peakmeter_callback
);
394 MENUITEM_SETTING(peak_meter_clip_hold
,
395 &global_settings
.peak_meter_clip_hold
, peakmeter_callback
);
396 #ifdef HAVE_RECORDING
397 MENUITEM_SETTING(peak_meter_clipcounter
,
398 &global_settings
.peak_meter_clipcounter
, NULL
);
400 MENUITEM_SETTING(peak_meter_release
,
401 &global_settings
.peak_meter_release
, peakmeter_callback
);
403 * Menu to select wether the scale of the meter
404 * displays dBfs of linear values.
406 static int peak_meter_scale(void) {
408 bool use_dbfs
= global_settings
.peak_meter_dbfs
;
409 retval
= set_bool_options(str(LANG_PM_SCALE
),
411 STR(LANG_PM_DBFS
), STR(LANG_PM_LINEAR
),
414 /* has the user really changed the scale? */
415 if (use_dbfs
!= global_settings
.peak_meter_dbfs
) {
417 /* store the change */
418 global_settings
.peak_meter_dbfs
= use_dbfs
;
419 peak_meter_set_use_dbfs(use_dbfs
);
421 /* If the user changed the scale mode the meaning of
422 peak_meter_min (peak_meter_max) has changed. Thus we have
423 to convert the values stored in global_settings. */
426 /* we only store -dBfs */
427 global_settings
.peak_meter_min
= -peak_meter_get_min() / 100;
428 global_settings
.peak_meter_max
= -peak_meter_get_max() / 100;
430 /* limit the returned value to the allowed range */
431 if(global_settings
.peak_meter_min
> 89)
432 global_settings
.peak_meter_min
= 89;
437 global_settings
.peak_meter_min
= peak_meter_get_min();
439 /* converting dBfs -> percent results in a precision loss.
440 I assume that the user doesn't bother that conversion
441 dBfs <-> percent isn't symmetrical for odd values but that
442 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
443 resulting from dBfs -> percent manually here */
444 max
= peak_meter_get_max();
445 global_settings
.peak_meter_max
= max
< 99 ? max
: 100;
447 settings_apply_pm_range();
453 * Adjust the min value of the value range that
454 * the peak meter shall visualize.
456 static int peak_meter_min(void) {
458 if (global_settings
.peak_meter_dbfs
) {
461 int range_max
= -global_settings
.peak_meter_max
;
462 int min
= -global_settings
.peak_meter_min
;
464 retval
= set_int(str(LANG_PM_MIN
), str(LANG_PM_DBFS
), UNIT_DB
,
465 &min
, NULL
, 1, -89, range_max
, NULL
);
467 global_settings
.peak_meter_min
= - min
;
470 /* for linear scale */
472 int min
= global_settings
.peak_meter_min
;
474 retval
= set_int(str(LANG_PM_MIN
), "%", UNIT_PERCENT
,
476 1, 0, global_settings
.peak_meter_max
- 1, NULL
);
478 global_settings
.peak_meter_min
= (unsigned char)min
;
481 settings_apply_pm_range();
487 * Adjust the max value of the value range that
488 * the peak meter shall visualize.
490 static int peak_meter_max(void) {
492 if (global_settings
.peak_meter_dbfs
) {
495 int range_min
= -global_settings
.peak_meter_min
;
496 int max
= -global_settings
.peak_meter_max
;
498 retval
= set_int(str(LANG_PM_MAX
), str(LANG_PM_DBFS
), UNIT_DB
,
499 &max
, NULL
, 1, range_min
, 0, NULL
);
501 global_settings
.peak_meter_max
= - max
;
505 /* for linear scale */
507 int max
= global_settings
.peak_meter_max
;
509 retval
= set_int(str(LANG_PM_MAX
), "%", UNIT_PERCENT
,
511 1, global_settings
.peak_meter_min
+ 1, 100, NULL
);
513 global_settings
.peak_meter_max
= (unsigned char)max
;
516 settings_apply_pm_range();
519 MENUITEM_FUNCTION(peak_meter_scale_item
, 0, ID2P(LANG_PM_SCALE
),
520 peak_meter_scale
, NULL
, NULL
, Icon_NOICON
);
521 MENUITEM_FUNCTION(peak_meter_min_item
, 0, ID2P(LANG_PM_MIN
),
522 peak_meter_min
, NULL
, NULL
, Icon_NOICON
);
523 MENUITEM_FUNCTION(peak_meter_max_item
, 0, ID2P(LANG_PM_MAX
),
524 peak_meter_max
, NULL
, NULL
, Icon_NOICON
);
525 MAKE_MENU(peak_meter_menu
, ID2P(LANG_PM_MENU
), NULL
, Icon_NOICON
,
526 &peak_meter_release
, &peak_meter_hold
,
527 &peak_meter_clip_hold
,
528 #ifdef HAVE_RECORDING
529 &peak_meter_clipcounter
,
531 &peak_meter_scale_item
, &peak_meter_min_item
, &peak_meter_max_item
);
532 #endif /* HAVE_LCD_BITMAP */
533 /* PEAK METER MENU */
534 /***********************************/
537 #ifdef HAVE_TOUCHSCREEN
538 static int touch_mode_callback(int action
,const struct menu_item_ex
*this_item
)
543 case ACTION_EXIT_MENUITEM
: /* on exit */
544 touchscreen_set_mode(global_settings
.touch_mode
);
549 MENUITEM_SETTING(touch_mode
, &global_settings
.touch_mode
, touch_mode_callback
);
551 MENUITEM_FUNCTION(touchscreen_menu_calibrate
, 0, ID2P(LANG_TOUCHSCREEN_CALIBRATE
), calibrate
,
552 NULL
, NULL
, Icon_NOICON
);
553 MENUITEM_FUNCTION(touchscreen_menu_reset_calibration
, 0, ID2P(LANG_TOUCHSCREEN_RESET_CALIBRATION
), reset_mapping
,
554 NULL
, NULL
, Icon_NOICON
);
556 MAKE_MENU(touchscreen_menu
, ID2P(LANG_TOUCHSCREEN_SETTINGS
), NULL
, Icon_NOICON
, &touch_mode
,
557 &touchscreen_menu_calibrate
, &touchscreen_menu_reset_calibration
);
561 MENUITEM_SETTING(codepage_setting
, &global_settings
.default_codepage
, NULL
);
564 MAKE_MENU(display_menu
, ID2P(LANG_DISPLAY
),
565 NULL
, Icon_Display_menu
,
567 #ifdef HAVE_REMOTE_LCD
568 &lcd_remote_settings
,
570 &scroll_settings_menu
,
571 #ifdef HAVE_LCD_BITMAP
572 &bars_menu
, &peak_meter_menu
,
575 #ifdef HAVE_TOUCHSCREEN