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"
41 static int filterfirstkeypress_callback(int action
,const struct menu_item_ex
*this_item
)
46 case ACTION_EXIT_MENUITEM
:
47 set_backlight_filter_keypress(global_settings
.bl_filter_first_keypress
);
48 #ifdef HAVE_REMOTE_LCD
49 set_remote_backlight_filter_keypress(
50 global_settings
.remote_bl_filter_first_keypress
);
59 static int flipdisplay_callback(int action
,const struct menu_item_ex
*this_item
)
64 case ACTION_EXIT_MENUITEM
:
65 button_set_flip(global_settings
.flip_display
);
66 lcd_set_flip(global_settings
.flip_display
);
68 #ifdef HAVE_REMOTE_LCD
69 lcd_remote_set_flip(global_settings
.remote_flip_display
);
78 /***********************************/
81 MENUITEM_SETTING(backlight_timeout
, &global_settings
.backlight_timeout
, NULL
);
83 MENUITEM_SETTING(backlight_timeout_plugged
,
84 &global_settings
.backlight_timeout_plugged
, NULL
);
86 #ifdef HAS_BUTTON_HOLD
87 MENUITEM_SETTING(backlight_on_button_hold
,
88 &global_settings
.backlight_on_button_hold
, NULL
);
90 MENUITEM_SETTING(caption_backlight
, &global_settings
.caption_backlight
, NULL
);
91 #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
92 || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
93 MENUITEM_SETTING(backlight_fade_in
, &global_settings
.backlight_fade_in
, NULL
);
94 MENUITEM_SETTING(backlight_fade_out
, &global_settings
.backlight_fade_out
, NULL
);
96 MENUITEM_SETTING(bl_filter_first_keypress
,
97 &global_settings
.bl_filter_first_keypress
,
98 filterfirstkeypress_callback
);
99 #ifdef HAVE_LCD_SLEEP_SETTING
100 MENUITEM_SETTING(lcd_sleep_after_backlight_off
,
101 &global_settings
.lcd_sleep_after_backlight_off
, NULL
);
103 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
104 MENUITEM_SETTING(brightness_item
, &global_settings
.brightness
, NULL
);
106 #endif /* HAVE_BACKLIGHT */
107 #ifdef HAVE_LCD_CONTRAST
108 MENUITEM_SETTING(contrast
, &global_settings
.contrast
, NULL
);
110 #ifdef HAVE_LCD_BITMAP
111 #ifdef HAVE_LCD_INVERT
112 MENUITEM_SETTING(invert
, &global_settings
.invert
, NULL
);
115 MENUITEM_SETTING(flip_display
, &global_settings
.flip_display
, flipdisplay_callback
);
117 #endif /* HAVE_LCD_BITMAP */
119 /* now the actual menu */
120 MAKE_MENU(lcd_settings
,ID2P(LANG_LCD_MENU
),
121 NULL
, Icon_Display_menu
122 #ifdef HAVE_BACKLIGHT
125 ,&backlight_timeout_plugged
127 # ifdef HAS_BUTTON_HOLD
128 ,&backlight_on_button_hold
131 #if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
132 || defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
133 ,&backlight_fade_in
, &backlight_fade_out
135 ,&bl_filter_first_keypress
136 # ifdef HAVE_LCD_SLEEP_SETTING
137 ,&lcd_sleep_after_backlight_off
139 # ifdef HAVE_BACKLIGHT_BRIGHTNESS
142 #endif /* HAVE_BACKLIGHT */
143 #ifdef HAVE_LCD_CONTRAST
146 #ifdef HAVE_LCD_BITMAP
147 # ifdef HAVE_LCD_INVERT
150 # ifdef HAVE_LCD_FLIP
153 #endif /* HAVE_LCD_BITMAP */
156 /***********************************/
159 /********************************/
160 /* Remote LCD settings menu */
161 #ifdef HAVE_REMOTE_LCD
162 MENUITEM_SETTING(remote_backlight_timeout
,
163 &global_settings
.remote_backlight_timeout
, NULL
);
166 MENUITEM_SETTING(remote_backlight_timeout_plugged
,
167 &global_settings
.remote_backlight_timeout_plugged
, NULL
);
170 #ifdef HAS_REMOTE_BUTTON_HOLD
171 MENUITEM_SETTING(remote_backlight_on_button_hold
,
172 &global_settings
.remote_backlight_on_button_hold
, NULL
);
175 MENUITEM_SETTING(remote_caption_backlight
,
176 &global_settings
.remote_caption_backlight
, NULL
);
177 MENUITEM_SETTING(remote_bl_filter_first_keypress
,
178 &global_settings
.remote_bl_filter_first_keypress
,
179 filterfirstkeypress_callback
);
180 MENUITEM_SETTING(remote_contrast
,
181 &global_settings
.remote_contrast
, NULL
);
182 MENUITEM_SETTING(remote_invert
,
183 &global_settings
.remote_invert
, NULL
);
186 MENUITEM_SETTING(remote_flip_display
,
187 &global_settings
.remote_flip_display
, flipdisplay_callback
);
190 #ifdef HAVE_REMOTE_LCD_TICKING
191 static int ticking_callback(int action
,const struct menu_item_ex
*this_item
)
196 case ACTION_EXIT_MENUITEM
:
197 lcd_remote_emireduce(global_settings
.remote_reduce_ticking
);
202 MENUITEM_SETTING(remote_reduce_ticking
,
203 &global_settings
.remote_reduce_ticking
, ticking_callback
);
206 MAKE_MENU(lcd_remote_settings
, ID2P(LANG_LCD_REMOTE_MENU
),
207 NULL
, Icon_Remote_Display_menu
,
208 &remote_backlight_timeout
,
210 &remote_backlight_timeout_plugged
,
212 #ifdef HAS_REMOTE_BUTTON_HOLD
213 &remote_backlight_on_button_hold
,
215 &remote_caption_backlight
, &remote_bl_filter_first_keypress
,
216 &remote_contrast
, &remote_invert
219 ,&remote_flip_display
221 #ifdef HAVE_REMOTE_LCD_TICKING
222 ,&remote_reduce_ticking
226 #endif /* HAVE_REMOTE_LCD */
227 /* Remote LCD settings menu */
228 /********************************/
230 /***********************************/
232 MENUITEM_SETTING_W_TEXT(scroll_speed
, &global_settings
.scroll_speed
,
233 ID2P(LANG_SCROLL
), NULL
);
234 MENUITEM_SETTING(scroll_delay
, &global_settings
.scroll_delay
, NULL
);
235 #ifdef HAVE_LCD_BITMAP
236 MENUITEM_SETTING_W_TEXT(scroll_step
, &global_settings
.scroll_step
,
237 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
239 MENUITEM_SETTING(bidir_limit
, &global_settings
.bidir_limit
, NULL
);
240 #ifdef HAVE_REMOTE_LCD
241 MENUITEM_SETTING_W_TEXT(remote_scroll_speed
, &global_settings
.remote_scroll_speed
,
242 ID2P(LANG_SCROLL
), NULL
);
243 MENUITEM_SETTING(remote_scroll_delay
, &global_settings
.remote_scroll_delay
, NULL
);
244 MENUITEM_SETTING_W_TEXT(remote_scroll_step
, &global_settings
.remote_scroll_step
,
245 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
246 MENUITEM_SETTING(remote_bidir_limit
, &global_settings
.remote_bidir_limit
, NULL
);
248 MAKE_MENU(remote_scroll_sets
, ID2P(LANG_REMOTE_SCROLL_SETS
), 0, Icon_NOICON
,
249 &remote_scroll_speed
, &remote_scroll_delay
,
250 &remote_scroll_step
, &remote_bidir_limit
);
251 #endif /* HAVE_REMOTE_LCD */
252 #ifdef HAVE_LCD_CHARCELLS
253 MENUITEM_SETTING(jump_scroll
, &global_settings
.jump_scroll
, NULL
);
254 MENUITEM_SETTING(jump_scroll_delay
, &global_settings
.jump_scroll_delay
, NULL
);
256 /* list acceleration */
257 #ifndef HAVE_WHEEL_ACCELERATION
258 MENUITEM_SETTING(list_accel_start_delay
,
259 &global_settings
.list_accel_start_delay
, NULL
);
260 MENUITEM_SETTING(list_accel_wait
, &global_settings
.list_accel_wait
, NULL
);
261 #endif /* HAVE_WHEEL_ACCELERATION */
262 #ifdef HAVE_LCD_BITMAP
263 static int screenscroll_callback(int action
,const struct menu_item_ex
*this_item
)
268 case ACTION_EXIT_MENUITEM
:
269 gui_list_screen_scroll_out_of_view(global_settings
.offset_out_of_view
);
274 MENUITEM_SETTING(offset_out_of_view
, &global_settings
.offset_out_of_view
,
275 screenscroll_callback
);
276 MENUITEM_SETTING(screen_scroll_step
, &global_settings
.screen_scroll_step
, NULL
);
278 MENUITEM_SETTING(scroll_paginated
, &global_settings
.scroll_paginated
, NULL
);
280 MAKE_MENU(scroll_settings_menu
, ID2P(LANG_SCROLL_MENU
), 0, Icon_NOICON
,
281 &scroll_speed
, &scroll_delay
,
282 #ifdef HAVE_LCD_BITMAP
286 #ifdef HAVE_REMOTE_LCD
289 #ifdef HAVE_LCD_CHARCELLS
290 &jump_scroll
, &jump_scroll_delay
,
292 #ifdef HAVE_LCD_BITMAP
293 &offset_out_of_view
, &screen_scroll_step
,
296 #ifndef HAVE_WHEEL_ACCELERATION
297 &list_accel_start_delay
, &list_accel_wait
301 /***********************************/
303 /***********************************/
305 #ifdef HAVE_LCD_BITMAP
306 static int statusbar_callback(int action
,const struct menu_item_ex
*this_item
)
311 case ACTION_EXIT_MENUITEM
:
312 send_event(GUI_EVENT_STATUSBAR_TOGGLE
, NULL
);
313 /* this should be changed so only the viewports are reloaded */
314 settings_apply(false);
319 MENUITEM_SETTING(scrollbar_item
, &global_settings
.scrollbar
, NULL
);
320 MENUITEM_SETTING(statusbar
, &global_settings
.statusbar
, statusbar_callback
);
321 #if CONFIG_KEYPAD == RECORDER_PAD
322 MENUITEM_SETTING(buttonbar
, &global_settings
.buttonbar
, NULL
);
324 MENUITEM_SETTING(volume_type
, &global_settings
.volume_type
, NULL
);
325 MENUITEM_SETTING(battery_display
, &global_settings
.battery_display
, NULL
);
326 MAKE_MENU(bars_menu
, ID2P(LANG_BARS_MENU
), 0, Icon_NOICON
,
327 &scrollbar_item
, &statusbar
,
328 #if CONFIG_KEYPAD == RECORDER_PAD
331 &volume_type
, &battery_display
);
332 #endif /* HAVE_LCD_BITMAP */
334 /***********************************/
337 /***********************************/
338 /* PEAK METER MENU */
340 #ifdef HAVE_LCD_BITMAP
341 static int peakmeter_callback(int action
,const struct menu_item_ex
*this_item
)
346 case ACTION_EXIT_MENUITEM
:
347 peak_meter_init_times(global_settings
.peak_meter_release
,
348 global_settings
.peak_meter_hold
,
349 global_settings
.peak_meter_clip_hold
);
354 MENUITEM_SETTING(peak_meter_hold
,
355 &global_settings
.peak_meter_hold
, peakmeter_callback
);
356 MENUITEM_SETTING(peak_meter_clip_hold
,
357 &global_settings
.peak_meter_clip_hold
, peakmeter_callback
);
358 #ifdef HAVE_RECORDING
359 MENUITEM_SETTING(peak_meter_clipcounter
,
360 &global_settings
.peak_meter_clipcounter
, NULL
);
362 MENUITEM_SETTING(peak_meter_release
,
363 &global_settings
.peak_meter_release
, peakmeter_callback
);
365 * Menu to select wether the scale of the meter
366 * displays dBfs of linear values.
368 static int peak_meter_scale(void) {
370 bool use_dbfs
= global_settings
.peak_meter_dbfs
;
371 retval
= set_bool_options(str(LANG_PM_SCALE
),
373 STR(LANG_PM_DBFS
), STR(LANG_PM_LINEAR
),
376 /* has the user really changed the scale? */
377 if (use_dbfs
!= global_settings
.peak_meter_dbfs
) {
379 /* store the change */
380 global_settings
.peak_meter_dbfs
= use_dbfs
;
381 peak_meter_set_use_dbfs(use_dbfs
);
383 /* If the user changed the scale mode the meaning of
384 peak_meter_min (peak_meter_max) has changed. Thus we have
385 to convert the values stored in global_settings. */
388 /* we only store -dBfs */
389 global_settings
.peak_meter_min
= -peak_meter_get_min() / 100;
390 global_settings
.peak_meter_max
= -peak_meter_get_max() / 100;
392 /* limit the returned value to the allowed range */
393 if(global_settings
.peak_meter_min
> 89)
394 global_settings
.peak_meter_min
= 89;
399 global_settings
.peak_meter_min
= peak_meter_get_min();
401 /* converting dBfs -> percent results in a precision loss.
402 I assume that the user doesn't bother that conversion
403 dBfs <-> percent isn't symmetrical for odd values but that
404 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
405 resulting from dBfs -> percent manually here */
406 max
= peak_meter_get_max();
407 global_settings
.peak_meter_max
= max
< 99 ? max
: 100;
409 settings_apply_pm_range();
415 * Adjust the min value of the value range that
416 * the peak meter shall visualize.
418 static int peak_meter_min(void) {
420 if (global_settings
.peak_meter_dbfs
) {
423 int range_max
= -global_settings
.peak_meter_max
;
424 int min
= -global_settings
.peak_meter_min
;
426 retval
= set_int(str(LANG_PM_MIN
), str(LANG_PM_DBFS
), UNIT_DB
,
427 &min
, NULL
, 1, -89, range_max
, NULL
);
429 global_settings
.peak_meter_min
= - min
;
432 /* for linear scale */
434 int min
= global_settings
.peak_meter_min
;
436 retval
= set_int(str(LANG_PM_MIN
), "%", UNIT_PERCENT
,
438 1, 0, global_settings
.peak_meter_max
- 1, NULL
);
440 global_settings
.peak_meter_min
= (unsigned char)min
;
443 settings_apply_pm_range();
449 * Adjust the max value of the value range that
450 * the peak meter shall visualize.
452 static int peak_meter_max(void) {
454 if (global_settings
.peak_meter_dbfs
) {
457 int range_min
= -global_settings
.peak_meter_min
;
458 int max
= -global_settings
.peak_meter_max
;
460 retval
= set_int(str(LANG_PM_MAX
), str(LANG_PM_DBFS
), UNIT_DB
,
461 &max
, NULL
, 1, range_min
, 0, NULL
);
463 global_settings
.peak_meter_max
= - max
;
467 /* for linear scale */
469 int max
= global_settings
.peak_meter_max
;
471 retval
= set_int(str(LANG_PM_MAX
), "%", UNIT_PERCENT
,
473 1, global_settings
.peak_meter_min
+ 1, 100, NULL
);
475 global_settings
.peak_meter_max
= (unsigned char)max
;
478 settings_apply_pm_range();
481 MENUITEM_FUNCTION(peak_meter_scale_item
, 0, ID2P(LANG_PM_SCALE
),
482 peak_meter_scale
, NULL
, NULL
, Icon_NOICON
);
483 MENUITEM_FUNCTION(peak_meter_min_item
, 0, ID2P(LANG_PM_MIN
),
484 peak_meter_min
, NULL
, NULL
, Icon_NOICON
);
485 MENUITEM_FUNCTION(peak_meter_max_item
, 0, ID2P(LANG_PM_MAX
),
486 peak_meter_max
, NULL
, NULL
, Icon_NOICON
);
487 MAKE_MENU(peak_meter_menu
, ID2P(LANG_PM_MENU
), NULL
, Icon_NOICON
,
488 &peak_meter_release
, &peak_meter_hold
,
489 &peak_meter_clip_hold
,
490 #ifdef HAVE_RECORDING
491 &peak_meter_clipcounter
,
493 &peak_meter_scale_item
, &peak_meter_min_item
, &peak_meter_max_item
);
494 #endif /* HAVE_LCD_BITMAP */
495 /* PEAK METER MENU */
496 /***********************************/
500 MENUITEM_SETTING(codepage_setting
, &global_settings
.default_codepage
, NULL
);
503 MAKE_MENU(display_menu
, ID2P(LANG_DISPLAY
),
504 NULL
, Icon_Display_menu
,
506 #ifdef HAVE_REMOTE_LCD
507 &lcd_remote_settings
,
509 &scroll_settings_menu
,
510 #ifdef HAVE_LCD_BITMAP
511 &bars_menu
, &peak_meter_menu
,