1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2007 Jonathan Gordon
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
30 #ifdef HAVE_LCD_BITMAP
31 #include "peakmeter.h"
34 #include "color_picker.h"
36 #include "lcd-remote.h"
40 static int filterfirstkeypress_callback(int action
,const struct menu_item_ex
*this_item
)
45 case ACTION_EXIT_MENUITEM
:
46 set_backlight_filter_keypress(global_settings
.bl_filter_first_keypress
);
47 #ifdef HAVE_REMOTE_LCD
48 set_remote_backlight_filter_keypress(
49 global_settings
.remote_bl_filter_first_keypress
);
58 static int flipdisplay_callback(int action
,const struct menu_item_ex
*this_item
)
63 case ACTION_EXIT_MENUITEM
:
64 button_set_flip(global_settings
.flip_display
);
65 lcd_set_flip(global_settings
.flip_display
);
67 #ifdef HAVE_REMOTE_LCD
68 lcd_remote_set_flip(global_settings
.remote_flip_display
);
77 /***********************************/
80 MENUITEM_SETTING(backlight_timeout
, &global_settings
.backlight_timeout
, NULL
);
82 MENUITEM_SETTING(backlight_timeout_plugged
,
83 &global_settings
.backlight_timeout_plugged
, NULL
);
85 #ifdef HAS_BUTTON_HOLD
86 MENUITEM_SETTING(backlight_on_button_hold
,
87 &global_settings
.backlight_on_button_hold
, NULL
);
89 MENUITEM_SETTING(caption_backlight
, &global_settings
.caption_backlight
, NULL
);
90 #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
91 MENUITEM_SETTING(backlight_fade_in
, &global_settings
.backlight_fade_in
, NULL
);
92 MENUITEM_SETTING(backlight_fade_out
, &global_settings
.backlight_fade_out
, NULL
);
94 MENUITEM_SETTING(bl_filter_first_keypress
,
95 &global_settings
.bl_filter_first_keypress
,
96 filterfirstkeypress_callback
);
97 #ifdef HAVE_LCD_SLEEP_SETTING
98 MENUITEM_SETTING(lcd_sleep_after_backlight_off
,
99 &global_settings
.lcd_sleep_after_backlight_off
, NULL
);
101 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
102 MENUITEM_SETTING(brightness_item
, &global_settings
.brightness
, NULL
);
104 #endif /* HAVE_BACKLIGHT */
105 #ifdef HAVE_LCD_CONTRAST
106 MENUITEM_SETTING(contrast
, &global_settings
.contrast
, NULL
);
108 #ifdef HAVE_LCD_BITMAP
109 #ifdef HAVE_LCD_INVERT
110 MENUITEM_SETTING(invert
, &global_settings
.invert
, NULL
);
113 MENUITEM_SETTING(flip_display
, &global_settings
.flip_display
, flipdisplay_callback
);
115 #endif /* HAVE_LCD_BITMAP */
117 /* now the actual menu */
118 MAKE_MENU(lcd_settings
,ID2P(LANG_LCD_MENU
),
119 NULL
, Icon_Display_menu
120 #ifdef HAVE_BACKLIGHT
123 ,&backlight_timeout_plugged
125 # ifdef HAS_BUTTON_HOLD
126 ,&backlight_on_button_hold
129 # if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
130 ,&backlight_fade_in
, &backlight_fade_out
132 ,&bl_filter_first_keypress
133 # ifdef HAVE_LCD_SLEEP_SETTING
134 ,&lcd_sleep_after_backlight_off
136 # ifdef HAVE_BACKLIGHT_BRIGHTNESS
139 #endif /* HAVE_BACKLIGHT */
140 #ifdef HAVE_LCD_CONTRAST
143 #ifdef HAVE_LCD_BITMAP
144 # ifdef HAVE_LCD_INVERT
147 # ifdef HAVE_LCD_FLIP
150 #endif /* HAVE_LCD_BITMAP */
153 /***********************************/
156 /********************************/
157 /* Remote LCD settings menu */
158 #ifdef HAVE_REMOTE_LCD
159 MENUITEM_SETTING(remote_backlight_timeout
,
160 &global_settings
.remote_backlight_timeout
, NULL
);
163 MENUITEM_SETTING(remote_backlight_timeout_plugged
,
164 &global_settings
.remote_backlight_timeout_plugged
, NULL
);
167 #ifdef HAS_REMOTE_BUTTON_HOLD
168 MENUITEM_SETTING(remote_backlight_on_button_hold
,
169 &global_settings
.remote_backlight_on_button_hold
, NULL
);
172 MENUITEM_SETTING(remote_caption_backlight
,
173 &global_settings
.remote_caption_backlight
, NULL
);
174 MENUITEM_SETTING(remote_bl_filter_first_keypress
,
175 &global_settings
.remote_bl_filter_first_keypress
,
176 filterfirstkeypress_callback
);
177 MENUITEM_SETTING(remote_contrast
,
178 &global_settings
.remote_contrast
, NULL
);
179 MENUITEM_SETTING(remote_invert
,
180 &global_settings
.remote_invert
, NULL
);
182 MENUITEM_SETTING(remote_flip_display
,
183 &global_settings
.remote_flip_display
, flipdisplay_callback
);
185 #ifdef HAVE_REMOTE_LCD_TICKING
186 int ticking_callback(int action
,const struct menu_item_ex
*this_item
)
191 case ACTION_EXIT_MENUITEM
:
192 lcd_remote_emireduce(global_settings
.remote_reduce_ticking
);
197 MENUITEM_SETTING(remote_reduce_ticking
,
198 &global_settings
.remote_reduce_ticking
, ticking_callback
);
201 MAKE_MENU(lcd_remote_settings
, ID2P(LANG_LCD_REMOTE_MENU
),
202 NULL
, Icon_Remote_Display_menu
,
203 &remote_backlight_timeout
,
205 &remote_backlight_timeout_plugged
,
207 #ifdef HAS_REMOTE_BUTTON_HOLD
208 &remote_backlight_on_button_hold
,
210 &remote_caption_backlight
, &remote_bl_filter_first_keypress
,
211 &remote_contrast
, &remote_invert
, &remote_flip_display
212 #ifdef HAVE_REMOTE_LCD_TICKING
213 ,&remote_reduce_ticking
217 #endif /* HAVE_REMOTE_LCD */
218 /* Remote LCD settings menu */
219 /********************************/
221 /***********************************/
223 MENUITEM_SETTING_W_TEXT(scroll_speed
, &global_settings
.scroll_speed
,
224 ID2P(LANG_SCROLL
), NULL
);
225 MENUITEM_SETTING(scroll_delay
, &global_settings
.scroll_delay
, NULL
);
226 #ifdef HAVE_LCD_BITMAP
227 MENUITEM_SETTING_W_TEXT(scroll_step
, &global_settings
.scroll_step
,
228 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
230 MENUITEM_SETTING(bidir_limit
, &global_settings
.bidir_limit
, NULL
);
231 #ifdef HAVE_REMOTE_LCD
232 MENUITEM_SETTING_W_TEXT(remote_scroll_speed
, &global_settings
.remote_scroll_speed
,
233 ID2P(LANG_SCROLL
), NULL
);
234 MENUITEM_SETTING(remote_scroll_delay
, &global_settings
.remote_scroll_delay
, NULL
);
235 MENUITEM_SETTING_W_TEXT(remote_scroll_step
, &global_settings
.remote_scroll_step
,
236 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
237 MENUITEM_SETTING(remote_bidir_limit
, &global_settings
.remote_bidir_limit
, NULL
);
239 MAKE_MENU(remote_scroll_sets
, ID2P(LANG_REMOTE_SCROLL_SETS
), 0, Icon_NOICON
,
240 &remote_scroll_speed
, &remote_scroll_delay
,
241 &remote_scroll_step
, &remote_bidir_limit
);
242 #endif /* HAVE_REMOTE_LCD */
243 #ifdef HAVE_LCD_CHARCELLS
244 MENUITEM_SETTING(jump_scroll
, &global_settings
.jump_scroll
, NULL
);
245 MENUITEM_SETTING(jump_scroll_delay
, &global_settings
.jump_scroll_delay
, NULL
);
247 /* list acceleration */
248 #ifndef HAVE_SCROLLWHEEL
249 MENUITEM_SETTING(list_accel_start_delay
,
250 &global_settings
.list_accel_start_delay
, NULL
);
251 MENUITEM_SETTING(list_accel_wait
, &global_settings
.list_accel_wait
, NULL
);
252 #endif /* HAVE_SCROLLWHEEL */
253 #ifdef HAVE_LCD_BITMAP
254 static int screenscroll_callback(int action
,const struct menu_item_ex
*this_item
)
259 case ACTION_EXIT_MENUITEM
:
260 gui_list_screen_scroll_out_of_view(global_settings
.offset_out_of_view
);
265 MENUITEM_SETTING(offset_out_of_view
, &global_settings
.offset_out_of_view
,
266 screenscroll_callback
);
267 MENUITEM_SETTING(screen_scroll_step
, &global_settings
.screen_scroll_step
, NULL
);
269 MENUITEM_SETTING(scroll_paginated
, &global_settings
.scroll_paginated
, NULL
);
271 MAKE_MENU(scroll_settings_menu
, ID2P(LANG_SCROLL_MENU
), 0, Icon_NOICON
,
272 &scroll_speed
, &scroll_delay
,
273 #ifdef HAVE_LCD_BITMAP
277 #ifdef HAVE_REMOTE_LCD
280 #ifdef HAVE_LCD_CHARCELLS
281 &jump_scroll
, &jump_scroll_delay
,
283 #ifdef HAVE_LCD_BITMAP
284 &offset_out_of_view
, &screen_scroll_step
,
287 #ifndef HAVE_SCROLLWHEEL
288 &list_accel_start_delay
, &list_accel_wait
292 /***********************************/
294 /***********************************/
296 #ifdef HAVE_LCD_BITMAP
297 static int statusbar_callback(int action
,const struct menu_item_ex
*this_item
)
302 case ACTION_EXIT_MENUITEM
:
303 /* this should be changed so only the viewports are reloaded */
304 settings_apply(false);
309 MENUITEM_SETTING(scrollbar_item
, &global_settings
.scrollbar
, NULL
);
310 MENUITEM_SETTING(statusbar
, &global_settings
.statusbar
, statusbar_callback
);
311 #if CONFIG_KEYPAD == RECORDER_PAD
312 MENUITEM_SETTING(buttonbar
, &global_settings
.buttonbar
, NULL
);
314 MENUITEM_SETTING(volume_type
, &global_settings
.volume_type
, NULL
);
315 MENUITEM_SETTING(battery_display
, &global_settings
.battery_display
, NULL
);
316 MAKE_MENU(bars_menu
, ID2P(LANG_BARS_MENU
), 0, Icon_NOICON
,
317 &scrollbar_item
, &statusbar
,
318 #if CONFIG_KEYPAD == RECORDER_PAD
321 &volume_type
, &battery_display
);
322 #endif /* HAVE_LCD_BITMAP */
324 /***********************************/
327 /***********************************/
328 /* PEAK METER MENU */
330 #ifdef HAVE_LCD_BITMAP
331 static int peakmeter_callback(int action
,const struct menu_item_ex
*this_item
)
336 case ACTION_EXIT_MENUITEM
:
337 peak_meter_init_times(global_settings
.peak_meter_release
,
338 global_settings
.peak_meter_hold
,
339 global_settings
.peak_meter_clip_hold
);
344 MENUITEM_SETTING(peak_meter_hold
,
345 &global_settings
.peak_meter_hold
, peakmeter_callback
);
346 MENUITEM_SETTING(peak_meter_clip_hold
,
347 &global_settings
.peak_meter_clip_hold
, peakmeter_callback
);
348 #ifdef HAVE_RECORDING
349 MENUITEM_SETTING(peak_meter_clipcounter
,
350 &global_settings
.peak_meter_clipcounter
, NULL
);
352 MENUITEM_SETTING(peak_meter_release
,
353 &global_settings
.peak_meter_release
, peakmeter_callback
);
355 * Menu to select wether the scale of the meter
356 * displays dBfs of linear values.
358 static int peak_meter_scale(void) {
360 bool use_dbfs
= global_settings
.peak_meter_dbfs
;
361 retval
= set_bool_options(str(LANG_PM_SCALE
),
363 STR(LANG_PM_DBFS
), STR(LANG_PM_LINEAR
),
366 /* has the user really changed the scale? */
367 if (use_dbfs
!= global_settings
.peak_meter_dbfs
) {
369 /* store the change */
370 global_settings
.peak_meter_dbfs
= use_dbfs
;
371 peak_meter_set_use_dbfs(use_dbfs
);
373 /* If the user changed the scale mode the meaning of
374 peak_meter_min (peak_meter_max) has changed. Thus we have
375 to convert the values stored in global_settings. */
378 /* we only store -dBfs */
379 global_settings
.peak_meter_min
= -peak_meter_get_min() / 100;
380 global_settings
.peak_meter_max
= -peak_meter_get_max() / 100;
382 /* limit the returned value to the allowed range */
383 if(global_settings
.peak_meter_min
> 89)
384 global_settings
.peak_meter_min
= 89;
389 global_settings
.peak_meter_min
= peak_meter_get_min();
391 /* converting dBfs -> percent results in a precision loss.
392 I assume that the user doesn't bother that conversion
393 dBfs <-> percent isn't symmetrical for odd values but that
394 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
395 resulting from dBfs -> percent manually here */
396 max
= peak_meter_get_max();
397 global_settings
.peak_meter_max
= max
< 99 ? max
: 100;
399 settings_apply_pm_range();
405 * Adjust the min value of the value range that
406 * the peak meter shall visualize.
408 static int peak_meter_min(void) {
410 if (global_settings
.peak_meter_dbfs
) {
413 int range_max
= -global_settings
.peak_meter_max
;
414 int min
= -global_settings
.peak_meter_min
;
416 retval
= set_int(str(LANG_PM_MIN
), str(LANG_PM_DBFS
), UNIT_DB
,
417 &min
, NULL
, 1, -89, range_max
, NULL
);
419 global_settings
.peak_meter_min
= - min
;
422 /* for linear scale */
424 int min
= global_settings
.peak_meter_min
;
426 retval
= set_int(str(LANG_PM_MIN
), "%", UNIT_PERCENT
,
428 1, 0, global_settings
.peak_meter_max
- 1, NULL
);
430 global_settings
.peak_meter_min
= (unsigned char)min
;
433 settings_apply_pm_range();
439 * Adjust the max value of the value range that
440 * the peak meter shall visualize.
442 static int peak_meter_max(void) {
444 if (global_settings
.peak_meter_dbfs
) {
447 int range_min
= -global_settings
.peak_meter_min
;
448 int max
= -global_settings
.peak_meter_max
;;
450 retval
= set_int(str(LANG_PM_MAX
), str(LANG_PM_DBFS
), UNIT_DB
,
451 &max
, NULL
, 1, range_min
, 0, NULL
);
453 global_settings
.peak_meter_max
= - max
;
457 /* for linear scale */
459 int max
= global_settings
.peak_meter_max
;
461 retval
= set_int(str(LANG_PM_MAX
), "%", UNIT_PERCENT
,
463 1, global_settings
.peak_meter_min
+ 1, 100, NULL
);
465 global_settings
.peak_meter_max
= (unsigned char)max
;
468 settings_apply_pm_range();
471 MENUITEM_FUNCTION(peak_meter_scale_item
, 0, ID2P(LANG_PM_SCALE
),
472 peak_meter_scale
, NULL
, NULL
, Icon_NOICON
);
473 MENUITEM_FUNCTION(peak_meter_min_item
, 0, ID2P(LANG_PM_MIN
),
474 peak_meter_min
, NULL
, NULL
, Icon_NOICON
);
475 MENUITEM_FUNCTION(peak_meter_max_item
, 0, ID2P(LANG_PM_MAX
),
476 peak_meter_max
, NULL
, NULL
, Icon_NOICON
);
477 MAKE_MENU(peak_meter_menu
, ID2P(LANG_PM_MENU
), NULL
, Icon_NOICON
,
478 &peak_meter_release
, &peak_meter_hold
,
479 &peak_meter_clip_hold
,
480 #ifdef HAVE_RECORDING
481 &peak_meter_clipcounter
,
483 &peak_meter_scale_item
, &peak_meter_min_item
, &peak_meter_max_item
);
484 #endif /* HAVE_LCD_BITMAP */
485 /* PEAK METER MENU */
486 /***********************************/
490 MENUITEM_SETTING(codepage_setting
, &global_settings
.default_codepage
, NULL
);
493 MAKE_MENU(display_menu
, ID2P(LANG_DISPLAY
),
494 NULL
, Icon_Display_menu
,
496 #ifdef HAVE_REMOTE_LCD
497 &lcd_remote_settings
,
499 &scroll_settings_menu
,
500 #ifdef HAVE_LCD_BITMAP
501 &bars_menu
, &peak_meter_menu
,