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 #ifdef HAVE_REMOTE_LCD
39 #include "lcd-remote.h"
41 #ifdef HAVE_TOUCHSCREEN
45 #include "statusbar.h" /* statusbar_vals enum*/
48 static int filterfirstkeypress_callback(int action
,const struct menu_item_ex
*this_item
)
53 case ACTION_EXIT_MENUITEM
:
54 set_backlight_filter_keypress(global_settings
.bl_filter_first_keypress
);
55 #ifdef HAVE_REMOTE_LCD
56 set_remote_backlight_filter_keypress(
57 global_settings
.remote_bl_filter_first_keypress
);
66 static int flipdisplay_callback(int action
,const struct menu_item_ex
*this_item
)
71 case ACTION_EXIT_MENUITEM
:
72 button_set_flip(global_settings
.flip_display
);
73 lcd_set_flip(global_settings
.flip_display
);
75 #ifdef HAVE_REMOTE_LCD
76 lcd_remote_set_flip(global_settings
.remote_flip_display
);
85 /***********************************/
88 MENUITEM_SETTING(backlight_timeout
, &global_settings
.backlight_timeout
, NULL
);
90 MENUITEM_SETTING(backlight_timeout_plugged
,
91 &global_settings
.backlight_timeout_plugged
, NULL
);
93 #ifdef HAS_BUTTON_HOLD
94 MENUITEM_SETTING(backlight_on_button_hold
,
95 &global_settings
.backlight_on_button_hold
, NULL
);
97 MENUITEM_SETTING(caption_backlight
, &global_settings
.caption_backlight
, NULL
);
98 #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
99 || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
100 MENUITEM_SETTING(backlight_fade_in
, &global_settings
.backlight_fade_in
, NULL
);
101 MENUITEM_SETTING(backlight_fade_out
, &global_settings
.backlight_fade_out
, NULL
);
103 MENUITEM_SETTING(bl_filter_first_keypress
,
104 &global_settings
.bl_filter_first_keypress
,
105 filterfirstkeypress_callback
);
106 #ifdef HAVE_LCD_SLEEP_SETTING
107 MENUITEM_SETTING(lcd_sleep_after_backlight_off
,
108 &global_settings
.lcd_sleep_after_backlight_off
, NULL
);
110 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
111 MENUITEM_SETTING(brightness_item
, &global_settings
.brightness
, NULL
);
113 #endif /* HAVE_BACKLIGHT */
114 #ifdef HAVE_LCD_CONTRAST
115 MENUITEM_SETTING(contrast
, &global_settings
.contrast
, NULL
);
117 #ifdef HAVE_LCD_BITMAP
118 #ifdef HAVE_LCD_INVERT
119 MENUITEM_SETTING(invert
, &global_settings
.invert
, NULL
);
122 MENUITEM_SETTING(flip_display
, &global_settings
.flip_display
, flipdisplay_callback
);
124 #endif /* HAVE_LCD_BITMAP */
126 /* now the actual menu */
127 MAKE_MENU(lcd_settings
,ID2P(LANG_LCD_MENU
),
128 NULL
, Icon_Display_menu
129 #ifdef HAVE_BACKLIGHT
132 ,&backlight_timeout_plugged
134 # ifdef HAS_BUTTON_HOLD
135 ,&backlight_on_button_hold
138 #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
139 || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
140 ,&backlight_fade_in
, &backlight_fade_out
142 ,&bl_filter_first_keypress
143 # ifdef HAVE_LCD_SLEEP_SETTING
144 ,&lcd_sleep_after_backlight_off
146 # ifdef HAVE_BACKLIGHT_BRIGHTNESS
149 #endif /* HAVE_BACKLIGHT */
150 #ifdef HAVE_LCD_CONTRAST
153 #ifdef HAVE_LCD_BITMAP
154 # ifdef HAVE_LCD_INVERT
157 # ifdef HAVE_LCD_FLIP
160 #endif /* HAVE_LCD_BITMAP */
163 /***********************************/
166 /********************************/
167 /* Remote LCD settings menu */
168 #ifdef HAVE_REMOTE_LCD
169 MENUITEM_SETTING(remote_backlight_timeout
,
170 &global_settings
.remote_backlight_timeout
, NULL
);
173 MENUITEM_SETTING(remote_backlight_timeout_plugged
,
174 &global_settings
.remote_backlight_timeout_plugged
, NULL
);
177 #ifdef HAS_REMOTE_BUTTON_HOLD
178 MENUITEM_SETTING(remote_backlight_on_button_hold
,
179 &global_settings
.remote_backlight_on_button_hold
, NULL
);
182 MENUITEM_SETTING(remote_caption_backlight
,
183 &global_settings
.remote_caption_backlight
, NULL
);
184 MENUITEM_SETTING(remote_bl_filter_first_keypress
,
185 &global_settings
.remote_bl_filter_first_keypress
,
186 filterfirstkeypress_callback
);
187 MENUITEM_SETTING(remote_contrast
,
188 &global_settings
.remote_contrast
, NULL
);
189 MENUITEM_SETTING(remote_invert
,
190 &global_settings
.remote_invert
, NULL
);
193 MENUITEM_SETTING(remote_flip_display
,
194 &global_settings
.remote_flip_display
, flipdisplay_callback
);
197 #ifdef HAVE_REMOTE_LCD_TICKING
198 static int ticking_callback(int action
,const struct menu_item_ex
*this_item
)
203 case ACTION_EXIT_MENUITEM
:
204 lcd_remote_emireduce(global_settings
.remote_reduce_ticking
);
209 MENUITEM_SETTING(remote_reduce_ticking
,
210 &global_settings
.remote_reduce_ticking
, ticking_callback
);
213 MAKE_MENU(lcd_remote_settings
, ID2P(LANG_LCD_REMOTE_MENU
),
214 NULL
, Icon_Remote_Display_menu
,
215 &remote_backlight_timeout
,
217 &remote_backlight_timeout_plugged
,
219 #ifdef HAS_REMOTE_BUTTON_HOLD
220 &remote_backlight_on_button_hold
,
222 &remote_caption_backlight
, &remote_bl_filter_first_keypress
,
223 &remote_contrast
, &remote_invert
226 ,&remote_flip_display
228 #ifdef HAVE_REMOTE_LCD_TICKING
229 ,&remote_reduce_ticking
233 #endif /* HAVE_REMOTE_LCD */
234 /* Remote LCD settings menu */
235 /********************************/
237 /***********************************/
239 MENUITEM_SETTING_W_TEXT(scroll_speed
, &global_settings
.scroll_speed
,
240 ID2P(LANG_SCROLL
), NULL
);
241 MENUITEM_SETTING(scroll_delay
, &global_settings
.scroll_delay
, NULL
);
242 #ifdef HAVE_LCD_BITMAP
243 MENUITEM_SETTING_W_TEXT(scroll_step
, &global_settings
.scroll_step
,
244 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
246 MENUITEM_SETTING(bidir_limit
, &global_settings
.bidir_limit
, NULL
);
247 #ifdef HAVE_REMOTE_LCD
248 MENUITEM_SETTING_W_TEXT(remote_scroll_speed
, &global_settings
.remote_scroll_speed
,
249 ID2P(LANG_SCROLL
), NULL
);
250 MENUITEM_SETTING(remote_scroll_delay
, &global_settings
.remote_scroll_delay
, NULL
);
251 MENUITEM_SETTING_W_TEXT(remote_scroll_step
, &global_settings
.remote_scroll_step
,
252 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
253 MENUITEM_SETTING(remote_bidir_limit
, &global_settings
.remote_bidir_limit
, NULL
);
255 MAKE_MENU(remote_scroll_sets
, ID2P(LANG_REMOTE_SCROLL_SETS
), 0, Icon_NOICON
,
256 &remote_scroll_speed
, &remote_scroll_delay
,
257 &remote_scroll_step
, &remote_bidir_limit
);
258 #endif /* HAVE_REMOTE_LCD */
260 /* list acceleration */
261 #ifndef HAVE_WHEEL_ACCELERATION
262 MENUITEM_SETTING(list_accel_start_delay
,
263 &global_settings
.list_accel_start_delay
, NULL
);
264 MENUITEM_SETTING(list_accel_wait
, &global_settings
.list_accel_wait
, NULL
);
265 #endif /* HAVE_WHEEL_ACCELERATION */
266 #ifdef HAVE_LCD_BITMAP
267 static int screenscroll_callback(int action
,const struct menu_item_ex
*this_item
)
272 case ACTION_EXIT_MENUITEM
:
273 gui_list_screen_scroll_out_of_view(global_settings
.offset_out_of_view
);
278 MENUITEM_SETTING(offset_out_of_view
, &global_settings
.offset_out_of_view
,
279 screenscroll_callback
);
280 MENUITEM_SETTING(screen_scroll_step
, &global_settings
.screen_scroll_step
, NULL
);
282 MENUITEM_SETTING(scroll_paginated
, &global_settings
.scroll_paginated
, NULL
);
284 MAKE_MENU(scroll_settings_menu
, ID2P(LANG_SCROLL_MENU
), 0, Icon_NOICON
,
285 &scroll_speed
, &scroll_delay
,
286 #ifdef HAVE_LCD_BITMAP
290 #ifdef HAVE_REMOTE_LCD
293 #ifdef HAVE_LCD_BITMAP
294 &offset_out_of_view
, &screen_scroll_step
,
297 #ifndef HAVE_WHEEL_ACCELERATION
298 &list_accel_start_delay
, &list_accel_wait
302 /***********************************/
304 /***********************************/
305 /* PEAK METER MENU */
307 #ifdef HAVE_LCD_BITMAP
308 static int peakmeter_callback(int action
,const struct menu_item_ex
*this_item
)
313 case ACTION_EXIT_MENUITEM
:
314 peak_meter_init_times(global_settings
.peak_meter_release
,
315 global_settings
.peak_meter_hold
,
316 global_settings
.peak_meter_clip_hold
);
321 MENUITEM_SETTING(peak_meter_hold
,
322 &global_settings
.peak_meter_hold
, peakmeter_callback
);
323 MENUITEM_SETTING(peak_meter_clip_hold
,
324 &global_settings
.peak_meter_clip_hold
, peakmeter_callback
);
325 #ifdef HAVE_RECORDING
326 MENUITEM_SETTING(peak_meter_clipcounter
,
327 &global_settings
.peak_meter_clipcounter
, NULL
);
329 MENUITEM_SETTING(peak_meter_release
,
330 &global_settings
.peak_meter_release
, peakmeter_callback
);
332 * Menu to select wether the scale of the meter
333 * displays dBfs of linear values.
335 static int peak_meter_scale(void) {
337 bool use_dbfs
= global_settings
.peak_meter_dbfs
;
338 retval
= set_bool_options(str(LANG_PM_SCALE
),
340 STR(LANG_PM_DBFS
), STR(LANG_PM_LINEAR
),
343 /* has the user really changed the scale? */
344 if (use_dbfs
!= global_settings
.peak_meter_dbfs
) {
346 /* store the change */
347 global_settings
.peak_meter_dbfs
= use_dbfs
;
348 peak_meter_set_use_dbfs(use_dbfs
);
350 /* If the user changed the scale mode the meaning of
351 peak_meter_min (peak_meter_max) has changed. Thus we have
352 to convert the values stored in global_settings. */
355 /* we only store -dBfs */
356 global_settings
.peak_meter_min
= -peak_meter_get_min() / 100;
357 global_settings
.peak_meter_max
= -peak_meter_get_max() / 100;
359 /* limit the returned value to the allowed range */
360 if(global_settings
.peak_meter_min
> 89)
361 global_settings
.peak_meter_min
= 89;
366 global_settings
.peak_meter_min
= peak_meter_get_min();
368 /* converting dBfs -> percent results in a precision loss.
369 I assume that the user doesn't bother that conversion
370 dBfs <-> percent isn't symmetrical for odd values but that
371 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
372 resulting from dBfs -> percent manually here */
373 max
= peak_meter_get_max();
374 global_settings
.peak_meter_max
= max
< 99 ? max
: 100;
376 settings_apply_pm_range();
382 * Adjust the min value of the value range that
383 * the peak meter shall visualize.
385 static int peak_meter_min(void) {
387 if (global_settings
.peak_meter_dbfs
) {
390 int range_max
= -global_settings
.peak_meter_max
;
391 int min
= -global_settings
.peak_meter_min
;
393 retval
= set_int(str(LANG_PM_MIN
), str(LANG_PM_DBFS
), UNIT_DB
,
394 &min
, NULL
, 1, -89, range_max
, NULL
);
396 global_settings
.peak_meter_min
= - min
;
399 /* for linear scale */
401 int min
= global_settings
.peak_meter_min
;
403 retval
= set_int(str(LANG_PM_MIN
), "%", UNIT_PERCENT
,
405 1, 0, global_settings
.peak_meter_max
- 1, NULL
);
407 global_settings
.peak_meter_min
= (unsigned char)min
;
410 settings_apply_pm_range();
416 * Adjust the max value of the value range that
417 * the peak meter shall visualize.
419 static int peak_meter_max(void) {
421 if (global_settings
.peak_meter_dbfs
) {
424 int range_min
= -global_settings
.peak_meter_min
;
425 int max
= -global_settings
.peak_meter_max
;
427 retval
= set_int(str(LANG_PM_MAX
), str(LANG_PM_DBFS
), UNIT_DB
,
428 &max
, NULL
, 1, range_min
, 0, NULL
);
430 global_settings
.peak_meter_max
= - max
;
434 /* for linear scale */
436 int max
= global_settings
.peak_meter_max
;
438 retval
= set_int(str(LANG_PM_MAX
), "%", UNIT_PERCENT
,
440 1, global_settings
.peak_meter_min
+ 1, 100, NULL
);
442 global_settings
.peak_meter_max
= (unsigned char)max
;
445 settings_apply_pm_range();
449 #if defined(HAVE_HISTOGRAM)
450 static bool history_interval(void)
452 static const struct opt_items names
[] = {
453 { "0s", TALK_ID(0, UNIT_SEC
) },
454 { "1s", TALK_ID(1, UNIT_SEC
) },
455 { "2s", TALK_ID(2, UNIT_SEC
) },
456 { "4s", TALK_ID(4, UNIT_SEC
) }
459 /* reconfigure histogram settings here */
461 return set_option(str(LANG_HISTOGRAM_INTERVAL
),
462 &global_settings
.histogram_interval
,
463 INT
, names
, 4, NULL
);
466 MENUITEM_FUNCTION(histogram
, 0,
467 ID2P(LANG_HISTOGRAM_INTERVAL
),
468 history_interval
, NULL
, NULL
, Icon_Menu_setting
);
472 MENUITEM_FUNCTION(peak_meter_scale_item
, 0, ID2P(LANG_PM_SCALE
),
473 peak_meter_scale
, NULL
, NULL
, Icon_NOICON
);
474 MENUITEM_FUNCTION(peak_meter_min_item
, 0, ID2P(LANG_PM_MIN
),
475 peak_meter_min
, NULL
, NULL
, Icon_NOICON
);
476 MENUITEM_FUNCTION(peak_meter_max_item
, 0, ID2P(LANG_PM_MAX
),
477 peak_meter_max
, NULL
, NULL
, Icon_NOICON
);
478 MAKE_MENU(peak_meter_menu
, ID2P(LANG_PM_MENU
), NULL
, Icon_NOICON
,
479 &peak_meter_release
, &peak_meter_hold
,
480 &peak_meter_clip_hold
,
481 #ifdef HAVE_RECORDING
482 &peak_meter_clipcounter
,
484 #ifdef HAVE_HISTOGRAM
487 &peak_meter_scale_item
, &peak_meter_min_item
, &peak_meter_max_item
);
488 #endif /* HAVE_LCD_BITMAP */
489 /* PEAK METER MENU */
490 /***********************************/
493 #ifdef HAVE_TOUCHSCREEN
494 static int touch_mode_callback(int action
,const struct menu_item_ex
*this_item
)
499 case ACTION_EXIT_MENUITEM
: /* on exit */
500 touchscreen_set_mode(global_settings
.touch_mode
);
506 static int line_padding_callback(int action
,const struct menu_item_ex
*this_item
)
510 if (action
== ACTION_EXIT_MENUITEM
)
511 viewportmanager_theme_changed(THEME_LISTS
);
515 MENUITEM_SETTING(touch_mode
, &global_settings
.touch_mode
, touch_mode_callback
);
517 MENUITEM_FUNCTION(touchscreen_menu_calibrate
, 0, ID2P(LANG_TOUCHSCREEN_CALIBRATE
), calibrate
,
518 NULL
, NULL
, Icon_NOICON
);
519 MENUITEM_FUNCTION(touchscreen_menu_reset_calibration
, 0, ID2P(LANG_TOUCHSCREEN_RESET_CALIBRATION
), reset_mapping
,
520 NULL
, NULL
, Icon_NOICON
);
521 MENUITEM_SETTING(list_line_padding
, &global_settings
.list_line_padding
, line_padding_callback
);
523 MAKE_MENU(touchscreen_menu
, ID2P(LANG_TOUCHSCREEN_SETTINGS
), NULL
, Icon_NOICON
, &list_line_padding
, &touch_mode
,
524 &touchscreen_menu_calibrate
, &touchscreen_menu_reset_calibration
);
528 MENUITEM_SETTING(codepage_setting
, &global_settings
.default_codepage
, NULL
);
531 MAKE_MENU(display_menu
, ID2P(LANG_DISPLAY
),
532 NULL
, Icon_Display_menu
,
534 #ifdef HAVE_REMOTE_LCD
535 &lcd_remote_settings
,
537 &scroll_settings_menu
,
538 #ifdef HAVE_LCD_BITMAP
542 #ifdef HAVE_TOUCHSCREEN