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 /***********************************/
309 /* PEAK METER MENU */
311 #ifdef HAVE_LCD_BITMAP
312 static int peakmeter_callback(int action
,const struct menu_item_ex
*this_item
)
317 case ACTION_EXIT_MENUITEM
:
318 peak_meter_init_times(global_settings
.peak_meter_release
,
319 global_settings
.peak_meter_hold
,
320 global_settings
.peak_meter_clip_hold
);
325 MENUITEM_SETTING(peak_meter_hold
,
326 &global_settings
.peak_meter_hold
, peakmeter_callback
);
327 MENUITEM_SETTING(peak_meter_clip_hold
,
328 &global_settings
.peak_meter_clip_hold
, peakmeter_callback
);
329 #ifdef HAVE_RECORDING
330 MENUITEM_SETTING(peak_meter_clipcounter
,
331 &global_settings
.peak_meter_clipcounter
, NULL
);
333 MENUITEM_SETTING(peak_meter_release
,
334 &global_settings
.peak_meter_release
, peakmeter_callback
);
336 * Menu to select wether the scale of the meter
337 * displays dBfs of linear values.
339 static int peak_meter_scale(void) {
341 bool use_dbfs
= global_settings
.peak_meter_dbfs
;
342 retval
= set_bool_options(str(LANG_PM_SCALE
),
344 STR(LANG_PM_DBFS
), STR(LANG_PM_LINEAR
),
347 /* has the user really changed the scale? */
348 if (use_dbfs
!= global_settings
.peak_meter_dbfs
) {
350 /* store the change */
351 global_settings
.peak_meter_dbfs
= use_dbfs
;
352 peak_meter_set_use_dbfs(use_dbfs
);
354 /* If the user changed the scale mode the meaning of
355 peak_meter_min (peak_meter_max) has changed. Thus we have
356 to convert the values stored in global_settings. */
359 /* we only store -dBfs */
360 global_settings
.peak_meter_min
= -peak_meter_get_min() / 100;
361 global_settings
.peak_meter_max
= -peak_meter_get_max() / 100;
363 /* limit the returned value to the allowed range */
364 if(global_settings
.peak_meter_min
> 89)
365 global_settings
.peak_meter_min
= 89;
370 global_settings
.peak_meter_min
= peak_meter_get_min();
372 /* converting dBfs -> percent results in a precision loss.
373 I assume that the user doesn't bother that conversion
374 dBfs <-> percent isn't symmetrical for odd values but that
375 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
376 resulting from dBfs -> percent manually here */
377 max
= peak_meter_get_max();
378 global_settings
.peak_meter_max
= max
< 99 ? max
: 100;
380 settings_apply_pm_range();
386 * Adjust the min value of the value range that
387 * the peak meter shall visualize.
389 static int peak_meter_min(void) {
391 if (global_settings
.peak_meter_dbfs
) {
394 int range_max
= -global_settings
.peak_meter_max
;
395 int min
= -global_settings
.peak_meter_min
;
397 retval
= set_int(str(LANG_PM_MIN
), str(LANG_PM_DBFS
), UNIT_DB
,
398 &min
, NULL
, 1, -89, range_max
, NULL
);
400 global_settings
.peak_meter_min
= - min
;
403 /* for linear scale */
405 int min
= global_settings
.peak_meter_min
;
407 retval
= set_int(str(LANG_PM_MIN
), "%", UNIT_PERCENT
,
409 1, 0, global_settings
.peak_meter_max
- 1, NULL
);
411 global_settings
.peak_meter_min
= (unsigned char)min
;
414 settings_apply_pm_range();
420 * Adjust the max value of the value range that
421 * the peak meter shall visualize.
423 static int peak_meter_max(void) {
425 if (global_settings
.peak_meter_dbfs
) {
428 int range_min
= -global_settings
.peak_meter_min
;
429 int max
= -global_settings
.peak_meter_max
;
431 retval
= set_int(str(LANG_PM_MAX
), str(LANG_PM_DBFS
), UNIT_DB
,
432 &max
, NULL
, 1, range_min
, 0, NULL
);
434 global_settings
.peak_meter_max
= - max
;
438 /* for linear scale */
440 int max
= global_settings
.peak_meter_max
;
442 retval
= set_int(str(LANG_PM_MAX
), "%", UNIT_PERCENT
,
444 1, global_settings
.peak_meter_min
+ 1, 100, NULL
);
446 global_settings
.peak_meter_max
= (unsigned char)max
;
449 settings_apply_pm_range();
452 MENUITEM_FUNCTION(peak_meter_scale_item
, 0, ID2P(LANG_PM_SCALE
),
453 peak_meter_scale
, NULL
, NULL
, Icon_NOICON
);
454 MENUITEM_FUNCTION(peak_meter_min_item
, 0, ID2P(LANG_PM_MIN
),
455 peak_meter_min
, NULL
, NULL
, Icon_NOICON
);
456 MENUITEM_FUNCTION(peak_meter_max_item
, 0, ID2P(LANG_PM_MAX
),
457 peak_meter_max
, NULL
, NULL
, Icon_NOICON
);
458 MAKE_MENU(peak_meter_menu
, ID2P(LANG_PM_MENU
), NULL
, Icon_NOICON
,
459 &peak_meter_release
, &peak_meter_hold
,
460 &peak_meter_clip_hold
,
461 #ifdef HAVE_RECORDING
462 &peak_meter_clipcounter
,
464 &peak_meter_scale_item
, &peak_meter_min_item
, &peak_meter_max_item
);
465 #endif /* HAVE_LCD_BITMAP */
466 /* PEAK METER MENU */
467 /***********************************/
470 #ifdef HAVE_TOUCHSCREEN
471 static int touch_mode_callback(int action
,const struct menu_item_ex
*this_item
)
476 case ACTION_EXIT_MENUITEM
: /* on exit */
477 touchscreen_set_mode(global_settings
.touch_mode
);
482 MENUITEM_SETTING(touch_mode
, &global_settings
.touch_mode
, touch_mode_callback
);
484 MENUITEM_FUNCTION(touchscreen_menu_calibrate
, 0, ID2P(LANG_TOUCHSCREEN_CALIBRATE
), calibrate
,
485 NULL
, NULL
, Icon_NOICON
);
486 MENUITEM_FUNCTION(touchscreen_menu_reset_calibration
, 0, ID2P(LANG_TOUCHSCREEN_RESET_CALIBRATION
), reset_mapping
,
487 NULL
, NULL
, Icon_NOICON
);
489 MAKE_MENU(touchscreen_menu
, ID2P(LANG_TOUCHSCREEN_SETTINGS
), NULL
, Icon_NOICON
, &touch_mode
,
490 &touchscreen_menu_calibrate
, &touchscreen_menu_reset_calibration
);
494 MENUITEM_SETTING(codepage_setting
, &global_settings
.default_codepage
, NULL
);
497 MAKE_MENU(display_menu
, ID2P(LANG_DISPLAY
),
498 NULL
, Icon_Display_menu
,
500 #ifdef HAVE_REMOTE_LCD
501 &lcd_remote_settings
,
503 &scroll_settings_menu
,
504 #ifdef HAVE_LCD_BITMAP
508 #ifdef HAVE_TOUCHSCREEN