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
45 static int filterfirstkeypress_callback(int action
,const struct menu_item_ex
*this_item
)
50 case ACTION_EXIT_MENUITEM
:
51 set_backlight_filter_keypress(global_settings
.bl_filter_first_keypress
);
52 #ifdef HAVE_REMOTE_LCD
53 set_remote_backlight_filter_keypress(
54 global_settings
.remote_bl_filter_first_keypress
);
63 static int flipdisplay_callback(int action
,const struct menu_item_ex
*this_item
)
68 case ACTION_EXIT_MENUITEM
:
69 button_set_flip(global_settings
.flip_display
);
70 lcd_set_flip(global_settings
.flip_display
);
72 #ifdef HAVE_REMOTE_LCD
73 lcd_remote_set_flip(global_settings
.remote_flip_display
);
82 /***********************************/
85 MENUITEM_SETTING(backlight_timeout
, &global_settings
.backlight_timeout
, NULL
);
87 MENUITEM_SETTING(backlight_timeout_plugged
,
88 &global_settings
.backlight_timeout_plugged
, NULL
);
90 #ifdef HAS_BUTTON_HOLD
91 MENUITEM_SETTING(backlight_on_button_hold
,
92 &global_settings
.backlight_on_button_hold
, NULL
);
94 MENUITEM_SETTING(caption_backlight
, &global_settings
.caption_backlight
, NULL
);
95 #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
96 || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
97 MENUITEM_SETTING(backlight_fade_in
, &global_settings
.backlight_fade_in
, NULL
);
98 MENUITEM_SETTING(backlight_fade_out
, &global_settings
.backlight_fade_out
, NULL
);
100 MENUITEM_SETTING(bl_filter_first_keypress
,
101 &global_settings
.bl_filter_first_keypress
,
102 filterfirstkeypress_callback
);
103 #ifdef HAVE_LCD_SLEEP_SETTING
104 MENUITEM_SETTING(lcd_sleep_after_backlight_off
,
105 &global_settings
.lcd_sleep_after_backlight_off
, NULL
);
107 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
108 MENUITEM_SETTING(brightness_item
, &global_settings
.brightness
, NULL
);
110 #endif /* HAVE_BACKLIGHT */
111 #ifdef HAVE_LCD_CONTRAST
112 MENUITEM_SETTING(contrast
, &global_settings
.contrast
, NULL
);
114 #ifdef HAVE_LCD_BITMAP
115 #ifdef HAVE_LCD_INVERT
116 MENUITEM_SETTING(invert
, &global_settings
.invert
, NULL
);
119 MENUITEM_SETTING(flip_display
, &global_settings
.flip_display
, flipdisplay_callback
);
121 #endif /* HAVE_LCD_BITMAP */
123 /* now the actual menu */
124 MAKE_MENU(lcd_settings
,ID2P(LANG_LCD_MENU
),
125 NULL
, Icon_Display_menu
126 #ifdef HAVE_BACKLIGHT
129 ,&backlight_timeout_plugged
131 # ifdef HAS_BUTTON_HOLD
132 ,&backlight_on_button_hold
135 #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
136 || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
137 ,&backlight_fade_in
, &backlight_fade_out
139 ,&bl_filter_first_keypress
140 # ifdef HAVE_LCD_SLEEP_SETTING
141 ,&lcd_sleep_after_backlight_off
143 # ifdef HAVE_BACKLIGHT_BRIGHTNESS
146 #endif /* HAVE_BACKLIGHT */
147 #ifdef HAVE_LCD_CONTRAST
150 #ifdef HAVE_LCD_BITMAP
151 # ifdef HAVE_LCD_INVERT
154 # ifdef HAVE_LCD_FLIP
157 #endif /* HAVE_LCD_BITMAP */
160 /***********************************/
163 /********************************/
164 /* Remote LCD settings menu */
165 #ifdef HAVE_REMOTE_LCD
166 MENUITEM_SETTING(remote_backlight_timeout
,
167 &global_settings
.remote_backlight_timeout
, NULL
);
170 MENUITEM_SETTING(remote_backlight_timeout_plugged
,
171 &global_settings
.remote_backlight_timeout_plugged
, NULL
);
174 #ifdef HAS_REMOTE_BUTTON_HOLD
175 MENUITEM_SETTING(remote_backlight_on_button_hold
,
176 &global_settings
.remote_backlight_on_button_hold
, NULL
);
179 MENUITEM_SETTING(remote_caption_backlight
,
180 &global_settings
.remote_caption_backlight
, NULL
);
181 MENUITEM_SETTING(remote_bl_filter_first_keypress
,
182 &global_settings
.remote_bl_filter_first_keypress
,
183 filterfirstkeypress_callback
);
184 MENUITEM_SETTING(remote_contrast
,
185 &global_settings
.remote_contrast
, NULL
);
186 MENUITEM_SETTING(remote_invert
,
187 &global_settings
.remote_invert
, NULL
);
190 MENUITEM_SETTING(remote_flip_display
,
191 &global_settings
.remote_flip_display
, flipdisplay_callback
);
194 #ifdef HAVE_REMOTE_LCD_TICKING
195 static int ticking_callback(int action
,const struct menu_item_ex
*this_item
)
200 case ACTION_EXIT_MENUITEM
:
201 lcd_remote_emireduce(global_settings
.remote_reduce_ticking
);
206 MENUITEM_SETTING(remote_reduce_ticking
,
207 &global_settings
.remote_reduce_ticking
, ticking_callback
);
210 MAKE_MENU(lcd_remote_settings
, ID2P(LANG_LCD_REMOTE_MENU
),
211 NULL
, Icon_Remote_Display_menu
,
212 &remote_backlight_timeout
,
214 &remote_backlight_timeout_plugged
,
216 #ifdef HAS_REMOTE_BUTTON_HOLD
217 &remote_backlight_on_button_hold
,
219 &remote_caption_backlight
, &remote_bl_filter_first_keypress
,
220 &remote_contrast
, &remote_invert
223 ,&remote_flip_display
225 #ifdef HAVE_REMOTE_LCD_TICKING
226 ,&remote_reduce_ticking
230 #endif /* HAVE_REMOTE_LCD */
231 /* Remote LCD settings menu */
232 /********************************/
234 /***********************************/
236 MENUITEM_SETTING_W_TEXT(scroll_speed
, &global_settings
.scroll_speed
,
237 ID2P(LANG_SCROLL
), NULL
);
238 MENUITEM_SETTING(scroll_delay
, &global_settings
.scroll_delay
, NULL
);
239 #ifdef HAVE_LCD_BITMAP
240 MENUITEM_SETTING_W_TEXT(scroll_step
, &global_settings
.scroll_step
,
241 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
243 MENUITEM_SETTING(bidir_limit
, &global_settings
.bidir_limit
, NULL
);
244 #ifdef HAVE_REMOTE_LCD
245 MENUITEM_SETTING_W_TEXT(remote_scroll_speed
, &global_settings
.remote_scroll_speed
,
246 ID2P(LANG_SCROLL
), NULL
);
247 MENUITEM_SETTING(remote_scroll_delay
, &global_settings
.remote_scroll_delay
, NULL
);
248 MENUITEM_SETTING_W_TEXT(remote_scroll_step
, &global_settings
.remote_scroll_step
,
249 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
250 MENUITEM_SETTING(remote_bidir_limit
, &global_settings
.remote_bidir_limit
, NULL
);
252 MAKE_MENU(remote_scroll_sets
, ID2P(LANG_REMOTE_SCROLL_SETS
), 0, Icon_NOICON
,
253 &remote_scroll_speed
, &remote_scroll_delay
,
254 &remote_scroll_step
, &remote_bidir_limit
);
255 #endif /* HAVE_REMOTE_LCD */
256 #ifdef HAVE_LCD_CHARCELLS
257 MENUITEM_SETTING(jump_scroll
, &global_settings
.jump_scroll
, NULL
);
258 MENUITEM_SETTING(jump_scroll_delay
, &global_settings
.jump_scroll_delay
, NULL
);
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_CHARCELLS
294 &jump_scroll
, &jump_scroll_delay
,
296 #ifdef HAVE_LCD_BITMAP
297 &offset_out_of_view
, &screen_scroll_step
,
300 #ifndef HAVE_WHEEL_ACCELERATION
301 &list_accel_start_delay
, &list_accel_wait
305 /***********************************/
307 /***********************************/
309 #ifdef HAVE_LCD_BITMAP
310 static int statusbar_callback(int action
,const struct menu_item_ex
*this_item
)
315 case ACTION_EXIT_MENUITEM
:
316 send_event(GUI_EVENT_STATUSBAR_TOGGLE
, NULL
);
317 send_event(GUI_EVENT_ACTIONUPDATE
, (void*)true);
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