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"
37 #include "color_picker.h"
39 #include "lcd-remote.h"
41 #include "statusbar.h"
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
);
188 MENUITEM_SETTING(remote_flip_display
,
189 &global_settings
.remote_flip_display
, flipdisplay_callback
);
191 #ifdef HAVE_REMOTE_LCD_TICKING
192 static int ticking_callback(int action
,const struct menu_item_ex
*this_item
)
197 case ACTION_EXIT_MENUITEM
:
198 lcd_remote_emireduce(global_settings
.remote_reduce_ticking
);
203 MENUITEM_SETTING(remote_reduce_ticking
,
204 &global_settings
.remote_reduce_ticking
, ticking_callback
);
207 MAKE_MENU(lcd_remote_settings
, ID2P(LANG_LCD_REMOTE_MENU
),
208 NULL
, Icon_Remote_Display_menu
,
209 &remote_backlight_timeout
,
211 &remote_backlight_timeout_plugged
,
213 #ifdef HAS_REMOTE_BUTTON_HOLD
214 &remote_backlight_on_button_hold
,
216 &remote_caption_backlight
, &remote_bl_filter_first_keypress
,
217 &remote_contrast
, &remote_invert
, &remote_flip_display
218 #ifdef HAVE_REMOTE_LCD_TICKING
219 ,&remote_reduce_ticking
223 #endif /* HAVE_REMOTE_LCD */
224 /* Remote LCD settings menu */
225 /********************************/
227 /***********************************/
229 MENUITEM_SETTING_W_TEXT(scroll_speed
, &global_settings
.scroll_speed
,
230 ID2P(LANG_SCROLL
), NULL
);
231 MENUITEM_SETTING(scroll_delay
, &global_settings
.scroll_delay
, NULL
);
232 #ifdef HAVE_LCD_BITMAP
233 MENUITEM_SETTING_W_TEXT(scroll_step
, &global_settings
.scroll_step
,
234 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
236 MENUITEM_SETTING(bidir_limit
, &global_settings
.bidir_limit
, NULL
);
237 #ifdef HAVE_REMOTE_LCD
238 MENUITEM_SETTING_W_TEXT(remote_scroll_speed
, &global_settings
.remote_scroll_speed
,
239 ID2P(LANG_SCROLL
), NULL
);
240 MENUITEM_SETTING(remote_scroll_delay
, &global_settings
.remote_scroll_delay
, NULL
);
241 MENUITEM_SETTING_W_TEXT(remote_scroll_step
, &global_settings
.remote_scroll_step
,
242 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
243 MENUITEM_SETTING(remote_bidir_limit
, &global_settings
.remote_bidir_limit
, NULL
);
245 MAKE_MENU(remote_scroll_sets
, ID2P(LANG_REMOTE_SCROLL_SETS
), 0, Icon_NOICON
,
246 &remote_scroll_speed
, &remote_scroll_delay
,
247 &remote_scroll_step
, &remote_bidir_limit
);
248 #endif /* HAVE_REMOTE_LCD */
249 #ifdef HAVE_LCD_CHARCELLS
250 MENUITEM_SETTING(jump_scroll
, &global_settings
.jump_scroll
, NULL
);
251 MENUITEM_SETTING(jump_scroll_delay
, &global_settings
.jump_scroll_delay
, NULL
);
253 /* list acceleration */
254 #ifndef HAVE_SCROLLWHEEL
255 MENUITEM_SETTING(list_accel_start_delay
,
256 &global_settings
.list_accel_start_delay
, NULL
);
257 MENUITEM_SETTING(list_accel_wait
, &global_settings
.list_accel_wait
, NULL
);
258 #endif /* HAVE_SCROLLWHEEL */
259 #ifdef HAVE_LCD_BITMAP
260 static int screenscroll_callback(int action
,const struct menu_item_ex
*this_item
)
265 case ACTION_EXIT_MENUITEM
:
266 gui_list_screen_scroll_out_of_view(global_settings
.offset_out_of_view
);
271 MENUITEM_SETTING(offset_out_of_view
, &global_settings
.offset_out_of_view
,
272 screenscroll_callback
);
273 MENUITEM_SETTING(screen_scroll_step
, &global_settings
.screen_scroll_step
, NULL
);
275 MENUITEM_SETTING(scroll_paginated
, &global_settings
.scroll_paginated
, NULL
);
277 MAKE_MENU(scroll_settings_menu
, ID2P(LANG_SCROLL_MENU
), 0, Icon_NOICON
,
278 &scroll_speed
, &scroll_delay
,
279 #ifdef HAVE_LCD_BITMAP
283 #ifdef HAVE_REMOTE_LCD
286 #ifdef HAVE_LCD_CHARCELLS
287 &jump_scroll
, &jump_scroll_delay
,
289 #ifdef HAVE_LCD_BITMAP
290 &offset_out_of_view
, &screen_scroll_step
,
293 #ifndef HAVE_SCROLLWHEEL
294 &list_accel_start_delay
, &list_accel_wait
298 /***********************************/
300 /***********************************/
302 #ifdef HAVE_LCD_BITMAP
303 static int statusbar_callback(int action
,const struct menu_item_ex
*this_item
)
308 case ACTION_EXIT_MENUITEM
:
309 send_event(GUI_EVENT_STATUSBAR_TOGGLE
, NULL
);
310 /* this should be changed so only the viewports are reloaded */
311 settings_apply(false);
316 MENUITEM_SETTING(scrollbar_item
, &global_settings
.scrollbar
, NULL
);
317 MENUITEM_SETTING(statusbar
, &global_settings
.statusbar
, statusbar_callback
);
318 #if CONFIG_KEYPAD == RECORDER_PAD
319 MENUITEM_SETTING(buttonbar
, &global_settings
.buttonbar
, NULL
);
321 MENUITEM_SETTING(volume_type
, &global_settings
.volume_type
, NULL
);
322 MENUITEM_SETTING(battery_display
, &global_settings
.battery_display
, NULL
);
323 MAKE_MENU(bars_menu
, ID2P(LANG_BARS_MENU
), 0, Icon_NOICON
,
324 &scrollbar_item
, &statusbar
,
325 #if CONFIG_KEYPAD == RECORDER_PAD
328 &volume_type
, &battery_display
);
329 #endif /* HAVE_LCD_BITMAP */
331 /***********************************/
334 /***********************************/
335 /* PEAK METER MENU */
337 #ifdef HAVE_LCD_BITMAP
338 static int peakmeter_callback(int action
,const struct menu_item_ex
*this_item
)
343 case ACTION_EXIT_MENUITEM
:
344 peak_meter_init_times(global_settings
.peak_meter_release
,
345 global_settings
.peak_meter_hold
,
346 global_settings
.peak_meter_clip_hold
);
351 MENUITEM_SETTING(peak_meter_hold
,
352 &global_settings
.peak_meter_hold
, peakmeter_callback
);
353 MENUITEM_SETTING(peak_meter_clip_hold
,
354 &global_settings
.peak_meter_clip_hold
, peakmeter_callback
);
355 #ifdef HAVE_RECORDING
356 MENUITEM_SETTING(peak_meter_clipcounter
,
357 &global_settings
.peak_meter_clipcounter
, NULL
);
359 MENUITEM_SETTING(peak_meter_release
,
360 &global_settings
.peak_meter_release
, peakmeter_callback
);
362 * Menu to select wether the scale of the meter
363 * displays dBfs of linear values.
365 static int peak_meter_scale(void) {
367 bool use_dbfs
= global_settings
.peak_meter_dbfs
;
368 retval
= set_bool_options(str(LANG_PM_SCALE
),
370 STR(LANG_PM_DBFS
), STR(LANG_PM_LINEAR
),
373 /* has the user really changed the scale? */
374 if (use_dbfs
!= global_settings
.peak_meter_dbfs
) {
376 /* store the change */
377 global_settings
.peak_meter_dbfs
= use_dbfs
;
378 peak_meter_set_use_dbfs(use_dbfs
);
380 /* If the user changed the scale mode the meaning of
381 peak_meter_min (peak_meter_max) has changed. Thus we have
382 to convert the values stored in global_settings. */
385 /* we only store -dBfs */
386 global_settings
.peak_meter_min
= -peak_meter_get_min() / 100;
387 global_settings
.peak_meter_max
= -peak_meter_get_max() / 100;
389 /* limit the returned value to the allowed range */
390 if(global_settings
.peak_meter_min
> 89)
391 global_settings
.peak_meter_min
= 89;
396 global_settings
.peak_meter_min
= peak_meter_get_min();
398 /* converting dBfs -> percent results in a precision loss.
399 I assume that the user doesn't bother that conversion
400 dBfs <-> percent isn't symmetrical for odd values but that
401 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
402 resulting from dBfs -> percent manually here */
403 max
= peak_meter_get_max();
404 global_settings
.peak_meter_max
= max
< 99 ? max
: 100;
406 settings_apply_pm_range();
412 * Adjust the min value of the value range that
413 * the peak meter shall visualize.
415 static int peak_meter_min(void) {
417 if (global_settings
.peak_meter_dbfs
) {
420 int range_max
= -global_settings
.peak_meter_max
;
421 int min
= -global_settings
.peak_meter_min
;
423 retval
= set_int(str(LANG_PM_MIN
), str(LANG_PM_DBFS
), UNIT_DB
,
424 &min
, NULL
, 1, -89, range_max
, NULL
);
426 global_settings
.peak_meter_min
= - min
;
429 /* for linear scale */
431 int min
= global_settings
.peak_meter_min
;
433 retval
= set_int(str(LANG_PM_MIN
), "%", UNIT_PERCENT
,
435 1, 0, global_settings
.peak_meter_max
- 1, NULL
);
437 global_settings
.peak_meter_min
= (unsigned char)min
;
440 settings_apply_pm_range();
446 * Adjust the max value of the value range that
447 * the peak meter shall visualize.
449 static int peak_meter_max(void) {
451 if (global_settings
.peak_meter_dbfs
) {
454 int range_min
= -global_settings
.peak_meter_min
;
455 int max
= -global_settings
.peak_meter_max
;;
457 retval
= set_int(str(LANG_PM_MAX
), str(LANG_PM_DBFS
), UNIT_DB
,
458 &max
, NULL
, 1, range_min
, 0, NULL
);
460 global_settings
.peak_meter_max
= - max
;
464 /* for linear scale */
466 int max
= global_settings
.peak_meter_max
;
468 retval
= set_int(str(LANG_PM_MAX
), "%", UNIT_PERCENT
,
470 1, global_settings
.peak_meter_min
+ 1, 100, NULL
);
472 global_settings
.peak_meter_max
= (unsigned char)max
;
475 settings_apply_pm_range();
478 MENUITEM_FUNCTION(peak_meter_scale_item
, 0, ID2P(LANG_PM_SCALE
),
479 peak_meter_scale
, NULL
, NULL
, Icon_NOICON
);
480 MENUITEM_FUNCTION(peak_meter_min_item
, 0, ID2P(LANG_PM_MIN
),
481 peak_meter_min
, NULL
, NULL
, Icon_NOICON
);
482 MENUITEM_FUNCTION(peak_meter_max_item
, 0, ID2P(LANG_PM_MAX
),
483 peak_meter_max
, NULL
, NULL
, Icon_NOICON
);
484 MAKE_MENU(peak_meter_menu
, ID2P(LANG_PM_MENU
), NULL
, Icon_NOICON
,
485 &peak_meter_release
, &peak_meter_hold
,
486 &peak_meter_clip_hold
,
487 #ifdef HAVE_RECORDING
488 &peak_meter_clipcounter
,
490 &peak_meter_scale_item
, &peak_meter_min_item
, &peak_meter_max_item
);
491 #endif /* HAVE_LCD_BITMAP */
492 /* PEAK METER MENU */
493 /***********************************/
497 MENUITEM_SETTING(codepage_setting
, &global_settings
.default_codepage
, NULL
);
500 MAKE_MENU(display_menu
, ID2P(LANG_DISPLAY
),
501 NULL
, Icon_Display_menu
,
503 #ifdef HAVE_REMOTE_LCD
504 &lcd_remote_settings
,
506 &scroll_settings_menu
,
507 #ifdef HAVE_LCD_BITMAP
508 &bars_menu
, &peak_meter_menu
,