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
44 static int filterfirstkeypress_callback(int action
,const struct menu_item_ex
*this_item
)
49 case ACTION_EXIT_MENUITEM
:
50 set_backlight_filter_keypress(global_settings
.bl_filter_first_keypress
);
51 #ifdef HAVE_REMOTE_LCD
52 set_remote_backlight_filter_keypress(
53 global_settings
.remote_bl_filter_first_keypress
);
62 static int flipdisplay_callback(int action
,const struct menu_item_ex
*this_item
)
67 case ACTION_EXIT_MENUITEM
:
68 button_set_flip(global_settings
.flip_display
);
69 lcd_set_flip(global_settings
.flip_display
);
71 #ifdef HAVE_REMOTE_LCD
72 lcd_remote_set_flip(global_settings
.remote_flip_display
);
81 /***********************************/
84 MENUITEM_SETTING(backlight_timeout
, &global_settings
.backlight_timeout
, NULL
);
86 MENUITEM_SETTING(backlight_timeout_plugged
,
87 &global_settings
.backlight_timeout_plugged
, NULL
);
89 #ifdef HAS_BUTTON_HOLD
90 MENUITEM_SETTING(backlight_on_button_hold
,
91 &global_settings
.backlight_on_button_hold
, NULL
);
93 MENUITEM_SETTING(caption_backlight
, &global_settings
.caption_backlight
, NULL
);
94 #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
95 || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
96 MENUITEM_SETTING(backlight_fade_in
, &global_settings
.backlight_fade_in
, NULL
);
97 MENUITEM_SETTING(backlight_fade_out
, &global_settings
.backlight_fade_out
, NULL
);
99 MENUITEM_SETTING(bl_filter_first_keypress
,
100 &global_settings
.bl_filter_first_keypress
,
101 filterfirstkeypress_callback
);
102 #ifdef HAVE_LCD_SLEEP_SETTING
103 MENUITEM_SETTING(lcd_sleep_after_backlight_off
,
104 &global_settings
.lcd_sleep_after_backlight_off
, NULL
);
106 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
107 MENUITEM_SETTING(brightness_item
, &global_settings
.brightness
, NULL
);
109 #endif /* HAVE_BACKLIGHT */
110 #ifdef HAVE_LCD_CONTRAST
111 MENUITEM_SETTING(contrast
, &global_settings
.contrast
, NULL
);
113 #ifdef HAVE_LCD_BITMAP
114 #ifdef HAVE_LCD_INVERT
115 MENUITEM_SETTING(invert
, &global_settings
.invert
, NULL
);
118 MENUITEM_SETTING(flip_display
, &global_settings
.flip_display
, flipdisplay_callback
);
120 #endif /* HAVE_LCD_BITMAP */
122 /* now the actual menu */
123 MAKE_MENU(lcd_settings
,ID2P(LANG_LCD_MENU
),
124 NULL
, Icon_Display_menu
125 #ifdef HAVE_BACKLIGHT
128 ,&backlight_timeout_plugged
130 # ifdef HAS_BUTTON_HOLD
131 ,&backlight_on_button_hold
134 #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
135 || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
136 ,&backlight_fade_in
, &backlight_fade_out
138 ,&bl_filter_first_keypress
139 # ifdef HAVE_LCD_SLEEP_SETTING
140 ,&lcd_sleep_after_backlight_off
142 # ifdef HAVE_BACKLIGHT_BRIGHTNESS
145 #endif /* HAVE_BACKLIGHT */
146 #ifdef HAVE_LCD_CONTRAST
149 #ifdef HAVE_LCD_BITMAP
150 # ifdef HAVE_LCD_INVERT
153 # ifdef HAVE_LCD_FLIP
156 #endif /* HAVE_LCD_BITMAP */
159 /***********************************/
162 /********************************/
163 /* Remote LCD settings menu */
164 #ifdef HAVE_REMOTE_LCD
165 MENUITEM_SETTING(remote_backlight_timeout
,
166 &global_settings
.remote_backlight_timeout
, NULL
);
169 MENUITEM_SETTING(remote_backlight_timeout_plugged
,
170 &global_settings
.remote_backlight_timeout_plugged
, NULL
);
173 #ifdef HAS_REMOTE_BUTTON_HOLD
174 MENUITEM_SETTING(remote_backlight_on_button_hold
,
175 &global_settings
.remote_backlight_on_button_hold
, NULL
);
178 MENUITEM_SETTING(remote_caption_backlight
,
179 &global_settings
.remote_caption_backlight
, NULL
);
180 MENUITEM_SETTING(remote_bl_filter_first_keypress
,
181 &global_settings
.remote_bl_filter_first_keypress
,
182 filterfirstkeypress_callback
);
183 MENUITEM_SETTING(remote_contrast
,
184 &global_settings
.remote_contrast
, NULL
);
185 MENUITEM_SETTING(remote_invert
,
186 &global_settings
.remote_invert
, NULL
);
189 MENUITEM_SETTING(remote_flip_display
,
190 &global_settings
.remote_flip_display
, flipdisplay_callback
);
193 #ifdef HAVE_REMOTE_LCD_TICKING
194 static int ticking_callback(int action
,const struct menu_item_ex
*this_item
)
199 case ACTION_EXIT_MENUITEM
:
200 lcd_remote_emireduce(global_settings
.remote_reduce_ticking
);
205 MENUITEM_SETTING(remote_reduce_ticking
,
206 &global_settings
.remote_reduce_ticking
, ticking_callback
);
209 MAKE_MENU(lcd_remote_settings
, ID2P(LANG_LCD_REMOTE_MENU
),
210 NULL
, Icon_Remote_Display_menu
,
211 &remote_backlight_timeout
,
213 &remote_backlight_timeout_plugged
,
215 #ifdef HAS_REMOTE_BUTTON_HOLD
216 &remote_backlight_on_button_hold
,
218 &remote_caption_backlight
, &remote_bl_filter_first_keypress
,
219 &remote_contrast
, &remote_invert
222 ,&remote_flip_display
224 #ifdef HAVE_REMOTE_LCD_TICKING
225 ,&remote_reduce_ticking
229 #endif /* HAVE_REMOTE_LCD */
230 /* Remote LCD settings menu */
231 /********************************/
233 /***********************************/
235 MENUITEM_SETTING_W_TEXT(scroll_speed
, &global_settings
.scroll_speed
,
236 ID2P(LANG_SCROLL
), NULL
);
237 MENUITEM_SETTING(scroll_delay
, &global_settings
.scroll_delay
, NULL
);
238 #ifdef HAVE_LCD_BITMAP
239 MENUITEM_SETTING_W_TEXT(scroll_step
, &global_settings
.scroll_step
,
240 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
242 MENUITEM_SETTING(bidir_limit
, &global_settings
.bidir_limit
, NULL
);
243 #ifdef HAVE_REMOTE_LCD
244 MENUITEM_SETTING_W_TEXT(remote_scroll_speed
, &global_settings
.remote_scroll_speed
,
245 ID2P(LANG_SCROLL
), NULL
);
246 MENUITEM_SETTING(remote_scroll_delay
, &global_settings
.remote_scroll_delay
, NULL
);
247 MENUITEM_SETTING_W_TEXT(remote_scroll_step
, &global_settings
.remote_scroll_step
,
248 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
249 MENUITEM_SETTING(remote_bidir_limit
, &global_settings
.remote_bidir_limit
, NULL
);
251 MAKE_MENU(remote_scroll_sets
, ID2P(LANG_REMOTE_SCROLL_SETS
), 0, Icon_NOICON
,
252 &remote_scroll_speed
, &remote_scroll_delay
,
253 &remote_scroll_step
, &remote_bidir_limit
);
254 #endif /* HAVE_REMOTE_LCD */
255 #ifdef HAVE_LCD_CHARCELLS
256 MENUITEM_SETTING(jump_scroll
, &global_settings
.jump_scroll
, NULL
);
257 MENUITEM_SETTING(jump_scroll_delay
, &global_settings
.jump_scroll_delay
, NULL
);
259 /* list acceleration */
260 #ifndef HAVE_WHEEL_ACCELERATION
261 MENUITEM_SETTING(list_accel_start_delay
,
262 &global_settings
.list_accel_start_delay
, NULL
);
263 MENUITEM_SETTING(list_accel_wait
, &global_settings
.list_accel_wait
, NULL
);
264 #endif /* HAVE_WHEEL_ACCELERATION */
265 #ifdef HAVE_LCD_BITMAP
266 static int screenscroll_callback(int action
,const struct menu_item_ex
*this_item
)
271 case ACTION_EXIT_MENUITEM
:
272 gui_list_screen_scroll_out_of_view(global_settings
.offset_out_of_view
);
277 MENUITEM_SETTING(offset_out_of_view
, &global_settings
.offset_out_of_view
,
278 screenscroll_callback
);
279 MENUITEM_SETTING(screen_scroll_step
, &global_settings
.screen_scroll_step
, NULL
);
281 MENUITEM_SETTING(scroll_paginated
, &global_settings
.scroll_paginated
, NULL
);
283 MAKE_MENU(scroll_settings_menu
, ID2P(LANG_SCROLL_MENU
), 0, Icon_NOICON
,
284 &scroll_speed
, &scroll_delay
,
285 #ifdef HAVE_LCD_BITMAP
289 #ifdef HAVE_REMOTE_LCD
292 #ifdef HAVE_LCD_CHARCELLS
293 &jump_scroll
, &jump_scroll_delay
,
295 #ifdef HAVE_LCD_BITMAP
296 &offset_out_of_view
, &screen_scroll_step
,
299 #ifndef HAVE_WHEEL_ACCELERATION
300 &list_accel_start_delay
, &list_accel_wait
304 /***********************************/
306 /***********************************/
308 #ifdef HAVE_LCD_BITMAP
309 static int statusbar_callback(int action
,const struct menu_item_ex
*this_item
)
314 case ACTION_EXIT_MENUITEM
:
315 send_event(GUI_EVENT_STATUSBAR_TOGGLE
, NULL
);
316 /* this should be changed so only the viewports are reloaded */
317 settings_apply(false);
322 MENUITEM_SETTING(scrollbar_item
, &global_settings
.scrollbar
, NULL
);
323 MENUITEM_SETTING(statusbar
, &global_settings
.statusbar
, statusbar_callback
);
324 #ifdef HAVE_REMOTE_LCD
325 MENUITEM_SETTING(remote_statusbar
, &global_settings
.remote_statusbar
, statusbar_callback
);
327 #if CONFIG_KEYPAD == RECORDER_PAD
328 MENUITEM_SETTING(buttonbar
, &global_settings
.buttonbar
, NULL
);
330 MENUITEM_SETTING(volume_type
, &global_settings
.volume_type
, NULL
);
331 MENUITEM_SETTING(battery_display
, &global_settings
.battery_display
, NULL
);
332 MAKE_MENU(bars_menu
, ID2P(LANG_BARS_MENU
), 0, Icon_NOICON
,
333 &scrollbar_item
, &statusbar
,
334 #ifdef HAVE_REMOTE_LCD
337 #if CONFIG_KEYPAD == RECORDER_PAD
340 &volume_type
, &battery_display
);
341 #endif /* HAVE_LCD_BITMAP */
343 /***********************************/
346 /***********************************/
347 /* PEAK METER MENU */
349 #ifdef HAVE_LCD_BITMAP
350 static int peakmeter_callback(int action
,const struct menu_item_ex
*this_item
)
355 case ACTION_EXIT_MENUITEM
:
356 peak_meter_init_times(global_settings
.peak_meter_release
,
357 global_settings
.peak_meter_hold
,
358 global_settings
.peak_meter_clip_hold
);
363 MENUITEM_SETTING(peak_meter_hold
,
364 &global_settings
.peak_meter_hold
, peakmeter_callback
);
365 MENUITEM_SETTING(peak_meter_clip_hold
,
366 &global_settings
.peak_meter_clip_hold
, peakmeter_callback
);
367 #ifdef HAVE_RECORDING
368 MENUITEM_SETTING(peak_meter_clipcounter
,
369 &global_settings
.peak_meter_clipcounter
, NULL
);
371 MENUITEM_SETTING(peak_meter_release
,
372 &global_settings
.peak_meter_release
, peakmeter_callback
);
374 * Menu to select wether the scale of the meter
375 * displays dBfs of linear values.
377 static int peak_meter_scale(void) {
379 bool use_dbfs
= global_settings
.peak_meter_dbfs
;
380 retval
= set_bool_options(str(LANG_PM_SCALE
),
382 STR(LANG_PM_DBFS
), STR(LANG_PM_LINEAR
),
385 /* has the user really changed the scale? */
386 if (use_dbfs
!= global_settings
.peak_meter_dbfs
) {
388 /* store the change */
389 global_settings
.peak_meter_dbfs
= use_dbfs
;
390 peak_meter_set_use_dbfs(use_dbfs
);
392 /* If the user changed the scale mode the meaning of
393 peak_meter_min (peak_meter_max) has changed. Thus we have
394 to convert the values stored in global_settings. */
397 /* we only store -dBfs */
398 global_settings
.peak_meter_min
= -peak_meter_get_min() / 100;
399 global_settings
.peak_meter_max
= -peak_meter_get_max() / 100;
401 /* limit the returned value to the allowed range */
402 if(global_settings
.peak_meter_min
> 89)
403 global_settings
.peak_meter_min
= 89;
408 global_settings
.peak_meter_min
= peak_meter_get_min();
410 /* converting dBfs -> percent results in a precision loss.
411 I assume that the user doesn't bother that conversion
412 dBfs <-> percent isn't symmetrical for odd values but that
413 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
414 resulting from dBfs -> percent manually here */
415 max
= peak_meter_get_max();
416 global_settings
.peak_meter_max
= max
< 99 ? max
: 100;
418 settings_apply_pm_range();
424 * Adjust the min value of the value range that
425 * the peak meter shall visualize.
427 static int peak_meter_min(void) {
429 if (global_settings
.peak_meter_dbfs
) {
432 int range_max
= -global_settings
.peak_meter_max
;
433 int min
= -global_settings
.peak_meter_min
;
435 retval
= set_int(str(LANG_PM_MIN
), str(LANG_PM_DBFS
), UNIT_DB
,
436 &min
, NULL
, 1, -89, range_max
, NULL
);
438 global_settings
.peak_meter_min
= - min
;
441 /* for linear scale */
443 int min
= global_settings
.peak_meter_min
;
445 retval
= set_int(str(LANG_PM_MIN
), "%", UNIT_PERCENT
,
447 1, 0, global_settings
.peak_meter_max
- 1, NULL
);
449 global_settings
.peak_meter_min
= (unsigned char)min
;
452 settings_apply_pm_range();
458 * Adjust the max value of the value range that
459 * the peak meter shall visualize.
461 static int peak_meter_max(void) {
463 if (global_settings
.peak_meter_dbfs
) {
466 int range_min
= -global_settings
.peak_meter_min
;
467 int max
= -global_settings
.peak_meter_max
;
469 retval
= set_int(str(LANG_PM_MAX
), str(LANG_PM_DBFS
), UNIT_DB
,
470 &max
, NULL
, 1, range_min
, 0, NULL
);
472 global_settings
.peak_meter_max
= - max
;
476 /* for linear scale */
478 int max
= global_settings
.peak_meter_max
;
480 retval
= set_int(str(LANG_PM_MAX
), "%", UNIT_PERCENT
,
482 1, global_settings
.peak_meter_min
+ 1, 100, NULL
);
484 global_settings
.peak_meter_max
= (unsigned char)max
;
487 settings_apply_pm_range();
490 MENUITEM_FUNCTION(peak_meter_scale_item
, 0, ID2P(LANG_PM_SCALE
),
491 peak_meter_scale
, NULL
, NULL
, Icon_NOICON
);
492 MENUITEM_FUNCTION(peak_meter_min_item
, 0, ID2P(LANG_PM_MIN
),
493 peak_meter_min
, NULL
, NULL
, Icon_NOICON
);
494 MENUITEM_FUNCTION(peak_meter_max_item
, 0, ID2P(LANG_PM_MAX
),
495 peak_meter_max
, NULL
, NULL
, Icon_NOICON
);
496 MAKE_MENU(peak_meter_menu
, ID2P(LANG_PM_MENU
), NULL
, Icon_NOICON
,
497 &peak_meter_release
, &peak_meter_hold
,
498 &peak_meter_clip_hold
,
499 #ifdef HAVE_RECORDING
500 &peak_meter_clipcounter
,
502 &peak_meter_scale_item
, &peak_meter_min_item
, &peak_meter_max_item
);
503 #endif /* HAVE_LCD_BITMAP */
504 /* PEAK METER MENU */
505 /***********************************/
508 #ifdef HAVE_TOUCHSCREEN
509 static int touch_mode_callback(int action
,const struct menu_item_ex
*this_item
)
514 case ACTION_EXIT_MENUITEM
: /* on exit */
515 touchscreen_set_mode(global_settings
.touch_mode
);
520 MENUITEM_SETTING(touch_mode
, &global_settings
.touch_mode
, touch_mode_callback
);
522 MENUITEM_FUNCTION(touchscreen_menu_calibrate
, 0, ID2P(LANG_TOUCHSCREEN_CALIBRATE
), calibrate
,
523 NULL
, NULL
, Icon_NOICON
);
524 MENUITEM_FUNCTION(touchscreen_menu_reset_calibration
, 0, ID2P(LANG_TOUCHSCREEN_RESET_CALIBRATION
), reset_mapping
,
525 NULL
, NULL
, Icon_NOICON
);
527 MAKE_MENU(touchscreen_menu
, ID2P(LANG_TOUCHSCREEN_SETTINGS
), NULL
, Icon_NOICON
, &touch_mode
,
528 &touchscreen_menu_calibrate
, &touchscreen_menu_reset_calibration
);
532 MENUITEM_SETTING(codepage_setting
, &global_settings
.default_codepage
, NULL
);
535 MAKE_MENU(display_menu
, ID2P(LANG_DISPLAY
),
536 NULL
, Icon_Display_menu
,
538 #ifdef HAVE_REMOTE_LCD
539 &lcd_remote_settings
,
541 &scroll_settings_menu
,
542 #ifdef HAVE_LCD_BITMAP
543 &bars_menu
, &peak_meter_menu
,
546 #ifdef HAVE_TOUCHSCREEN