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 */
258 /* list acceleration */
259 #ifndef HAVE_WHEEL_ACCELERATION
260 MENUITEM_SETTING(list_accel_start_delay
,
261 &global_settings
.list_accel_start_delay
, NULL
);
262 MENUITEM_SETTING(list_accel_wait
, &global_settings
.list_accel_wait
, NULL
);
263 #endif /* HAVE_WHEEL_ACCELERATION */
264 #ifdef HAVE_LCD_BITMAP
265 static int screenscroll_callback(int action
,const struct menu_item_ex
*this_item
)
270 case ACTION_EXIT_MENUITEM
:
271 gui_list_screen_scroll_out_of_view(global_settings
.offset_out_of_view
);
276 MENUITEM_SETTING(offset_out_of_view
, &global_settings
.offset_out_of_view
,
277 screenscroll_callback
);
278 MENUITEM_SETTING(screen_scroll_step
, &global_settings
.screen_scroll_step
, NULL
);
280 MENUITEM_SETTING(scroll_paginated
, &global_settings
.scroll_paginated
, NULL
);
282 MAKE_MENU(scroll_settings_menu
, ID2P(LANG_SCROLL_MENU
), 0, Icon_NOICON
,
283 &scroll_speed
, &scroll_delay
,
284 #ifdef HAVE_LCD_BITMAP
288 #ifdef HAVE_REMOTE_LCD
291 #ifdef HAVE_LCD_BITMAP
292 &offset_out_of_view
, &screen_scroll_step
,
295 #ifndef HAVE_WHEEL_ACCELERATION
296 &list_accel_start_delay
, &list_accel_wait
300 /***********************************/
302 /***********************************/
303 /* PEAK METER MENU */
305 #ifdef HAVE_LCD_BITMAP
306 static int peakmeter_callback(int action
,const struct menu_item_ex
*this_item
)
311 case ACTION_EXIT_MENUITEM
:
312 peak_meter_init_times(global_settings
.peak_meter_release
,
313 global_settings
.peak_meter_hold
,
314 global_settings
.peak_meter_clip_hold
);
319 MENUITEM_SETTING(peak_meter_hold
,
320 &global_settings
.peak_meter_hold
, peakmeter_callback
);
321 MENUITEM_SETTING(peak_meter_clip_hold
,
322 &global_settings
.peak_meter_clip_hold
, peakmeter_callback
);
323 #ifdef HAVE_RECORDING
324 MENUITEM_SETTING(peak_meter_clipcounter
,
325 &global_settings
.peak_meter_clipcounter
, NULL
);
327 MENUITEM_SETTING(peak_meter_release
,
328 &global_settings
.peak_meter_release
, peakmeter_callback
);
330 * Menu to select wether the scale of the meter
331 * displays dBfs of linear values.
333 static int peak_meter_scale(void) {
335 bool use_dbfs
= global_settings
.peak_meter_dbfs
;
336 retval
= set_bool_options(str(LANG_PM_SCALE
),
338 STR(LANG_PM_DBFS
), STR(LANG_PM_LINEAR
),
341 /* has the user really changed the scale? */
342 if (use_dbfs
!= global_settings
.peak_meter_dbfs
) {
344 /* store the change */
345 global_settings
.peak_meter_dbfs
= use_dbfs
;
346 peak_meter_set_use_dbfs(use_dbfs
);
348 /* If the user changed the scale mode the meaning of
349 peak_meter_min (peak_meter_max) has changed. Thus we have
350 to convert the values stored in global_settings. */
353 /* we only store -dBfs */
354 global_settings
.peak_meter_min
= -peak_meter_get_min() / 100;
355 global_settings
.peak_meter_max
= -peak_meter_get_max() / 100;
357 /* limit the returned value to the allowed range */
358 if(global_settings
.peak_meter_min
> 89)
359 global_settings
.peak_meter_min
= 89;
364 global_settings
.peak_meter_min
= peak_meter_get_min();
366 /* converting dBfs -> percent results in a precision loss.
367 I assume that the user doesn't bother that conversion
368 dBfs <-> percent isn't symmetrical for odd values but that
369 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
370 resulting from dBfs -> percent manually here */
371 max
= peak_meter_get_max();
372 global_settings
.peak_meter_max
= max
< 99 ? max
: 100;
374 settings_apply_pm_range();
380 * Adjust the min value of the value range that
381 * the peak meter shall visualize.
383 static int peak_meter_min(void) {
385 if (global_settings
.peak_meter_dbfs
) {
388 int range_max
= -global_settings
.peak_meter_max
;
389 int min
= -global_settings
.peak_meter_min
;
391 retval
= set_int(str(LANG_PM_MIN
), str(LANG_PM_DBFS
), UNIT_DB
,
392 &min
, NULL
, 1, -89, range_max
, NULL
);
394 global_settings
.peak_meter_min
= - min
;
397 /* for linear scale */
399 int min
= global_settings
.peak_meter_min
;
401 retval
= set_int(str(LANG_PM_MIN
), "%", UNIT_PERCENT
,
403 1, 0, global_settings
.peak_meter_max
- 1, NULL
);
405 global_settings
.peak_meter_min
= (unsigned char)min
;
408 settings_apply_pm_range();
414 * Adjust the max value of the value range that
415 * the peak meter shall visualize.
417 static int peak_meter_max(void) {
419 if (global_settings
.peak_meter_dbfs
) {
422 int range_min
= -global_settings
.peak_meter_min
;
423 int max
= -global_settings
.peak_meter_max
;
425 retval
= set_int(str(LANG_PM_MAX
), str(LANG_PM_DBFS
), UNIT_DB
,
426 &max
, NULL
, 1, range_min
, 0, NULL
);
428 global_settings
.peak_meter_max
= - max
;
432 /* for linear scale */
434 int max
= global_settings
.peak_meter_max
;
436 retval
= set_int(str(LANG_PM_MAX
), "%", UNIT_PERCENT
,
438 1, global_settings
.peak_meter_min
+ 1, 100, NULL
);
440 global_settings
.peak_meter_max
= (unsigned char)max
;
443 settings_apply_pm_range();
446 MENUITEM_FUNCTION(peak_meter_scale_item
, 0, ID2P(LANG_PM_SCALE
),
447 peak_meter_scale
, NULL
, NULL
, Icon_NOICON
);
448 MENUITEM_FUNCTION(peak_meter_min_item
, 0, ID2P(LANG_PM_MIN
),
449 peak_meter_min
, NULL
, NULL
, Icon_NOICON
);
450 MENUITEM_FUNCTION(peak_meter_max_item
, 0, ID2P(LANG_PM_MAX
),
451 peak_meter_max
, NULL
, NULL
, Icon_NOICON
);
452 MAKE_MENU(peak_meter_menu
, ID2P(LANG_PM_MENU
), NULL
, Icon_NOICON
,
453 &peak_meter_release
, &peak_meter_hold
,
454 &peak_meter_clip_hold
,
455 #ifdef HAVE_RECORDING
456 &peak_meter_clipcounter
,
458 &peak_meter_scale_item
, &peak_meter_min_item
, &peak_meter_max_item
);
459 #endif /* HAVE_LCD_BITMAP */
460 /* PEAK METER MENU */
461 /***********************************/
464 #ifdef HAVE_TOUCHSCREEN
465 static int touch_mode_callback(int action
,const struct menu_item_ex
*this_item
)
470 case ACTION_EXIT_MENUITEM
: /* on exit */
471 touchscreen_set_mode(global_settings
.touch_mode
);
476 MENUITEM_SETTING(touch_mode
, &global_settings
.touch_mode
, touch_mode_callback
);
478 MENUITEM_FUNCTION(touchscreen_menu_calibrate
, 0, ID2P(LANG_TOUCHSCREEN_CALIBRATE
), calibrate
,
479 NULL
, NULL
, Icon_NOICON
);
480 MENUITEM_FUNCTION(touchscreen_menu_reset_calibration
, 0, ID2P(LANG_TOUCHSCREEN_RESET_CALIBRATION
), reset_mapping
,
481 NULL
, NULL
, Icon_NOICON
);
483 MAKE_MENU(touchscreen_menu
, ID2P(LANG_TOUCHSCREEN_SETTINGS
), NULL
, Icon_NOICON
, &touch_mode
,
484 &touchscreen_menu_calibrate
, &touchscreen_menu_reset_calibration
);
488 MENUITEM_SETTING(codepage_setting
, &global_settings
.default_codepage
, NULL
);
491 MAKE_MENU(display_menu
, ID2P(LANG_DISPLAY
),
492 NULL
, Icon_Display_menu
,
494 #ifdef HAVE_REMOTE_LCD
495 &lcd_remote_settings
,
497 &scroll_settings_menu
,
498 #ifdef HAVE_LCD_BITMAP
502 #ifdef HAVE_TOUCHSCREEN