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"
38 #if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1))
44 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
);
61 #ifdef HAVE_LCD_BITMAP
62 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
);
70 #ifdef HAVE_REMOTE_LCD
71 lcd_remote_set_flip(global_settings
.remote_flip_display
);
80 /***********************************/
83 MENUITEM_SETTING(backlight_timeout
, &global_settings
.backlight_timeout
, NULL
);
85 MENUITEM_SETTING(backlight_timeout_plugged
,
86 &global_settings
.backlight_timeout_plugged
, NULL
);
88 #ifdef HAS_BUTTON_HOLD
89 MENUITEM_SETTING(backlight_on_button_hold
,
90 &global_settings
.backlight_on_button_hold
, NULL
);
92 MENUITEM_SETTING(caption_backlight
, &global_settings
.caption_backlight
, NULL
);
93 #if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
94 MENUITEM_SETTING(backlight_fade_in
, &global_settings
.backlight_fade_in
, NULL
);
95 MENUITEM_SETTING(backlight_fade_out
, &global_settings
.backlight_fade_out
, NULL
);
97 MENUITEM_SETTING(bl_filter_first_keypress
,
98 &global_settings
.bl_filter_first_keypress
,
99 filterfirstkeypress_callback
);
100 #ifdef HAVE_LCD_SLEEP
101 MENUITEM_SETTING(lcd_sleep_after_backlight_off
,
102 &global_settings
.lcd_sleep_after_backlight_off
, NULL
);
104 #ifdef HAVE_BACKLIGHT_BRIGHTNESS
105 MENUITEM_SETTING(brightness_item
, &global_settings
.brightness
, NULL
);
107 #endif /* HAVE_BACKLIGHT */
108 #ifdef HAVE_LCD_CONTRAST
109 MENUITEM_SETTING(contrast
, &global_settings
.contrast
, NULL
);
111 #ifdef HAVE_LCD_BITMAP
112 #ifdef HAVE_LCD_INVERT
113 MENUITEM_SETTING(invert
, &global_settings
.invert
, NULL
);
116 MENUITEM_SETTING(flip_display
, &global_settings
.flip_display
, flipdisplay_callback
);
118 #endif /* HAVE_LCD_BITMAP */
120 /* now the actual menu */
121 MAKE_MENU(lcd_settings
,ID2P(LANG_LCD_MENU
),
122 NULL
, Icon_Display_menu
123 #ifdef HAVE_BACKLIGHT
126 ,&backlight_timeout_plugged
128 # ifdef HAS_BUTTON_HOLD
129 ,&backlight_on_button_hold
132 # if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
133 ,&backlight_fade_in
, &backlight_fade_out
135 ,&bl_filter_first_keypress
136 # ifdef HAVE_LCD_SLEEP
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
);
185 MENUITEM_SETTING(remote_flip_display
,
186 &global_settings
.remote_flip_display
, flipdisplay_callback
);
188 #ifdef HAVE_REMOTE_LCD_TICKING
189 int ticking_callback(int action
,const struct menu_item_ex
*this_item
)
194 case ACTION_EXIT_MENUITEM
:
195 lcd_remote_emireduce(global_settings
.remote_reduce_ticking
);
200 MENUITEM_SETTING(remote_reduce_ticking
,
201 &global_settings
.remote_reduce_ticking
, ticking_callback
);
204 MAKE_MENU(lcd_remote_settings
, ID2P(LANG_LCD_REMOTE_MENU
),
205 NULL
, Icon_Remote_Display_menu
,
206 &remote_backlight_timeout
,
208 &remote_backlight_timeout_plugged
,
210 #ifdef HAS_REMOTE_BUTTON_HOLD
211 &remote_backlight_on_button_hold
,
213 &remote_caption_backlight
, &remote_bl_filter_first_keypress
,
214 &remote_contrast
, &remote_invert
, &remote_flip_display
215 #ifdef HAVE_REMOTE_LCD_TICKING
216 ,&remote_reduce_ticking
220 #endif /* HAVE_REMOTE_LCD */
221 /* Remote LCD settings menu */
222 /********************************/
224 /***********************************/
226 MENUITEM_SETTING_W_TEXT(scroll_speed
, &global_settings
.scroll_speed
,
227 ID2P(LANG_SCROLL
), NULL
);
228 MENUITEM_SETTING(scroll_delay
, &global_settings
.scroll_delay
, NULL
);
229 #ifdef HAVE_LCD_BITMAP
230 MENUITEM_SETTING_W_TEXT(scroll_step
, &global_settings
.scroll_step
,
231 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
233 MENUITEM_SETTING(bidir_limit
, &global_settings
.bidir_limit
, NULL
);
234 #ifdef HAVE_REMOTE_LCD
235 MENUITEM_SETTING_W_TEXT(remote_scroll_speed
, &global_settings
.remote_scroll_speed
,
236 ID2P(LANG_SCROLL
), NULL
);
237 MENUITEM_SETTING(remote_scroll_delay
, &global_settings
.remote_scroll_delay
, NULL
);
238 MENUITEM_SETTING_W_TEXT(remote_scroll_step
, &global_settings
.remote_scroll_step
,
239 ID2P(LANG_SCROLL_STEP_EXAMPLE
), NULL
);
240 MENUITEM_SETTING(remote_bidir_limit
, &global_settings
.remote_bidir_limit
, NULL
);
242 MAKE_MENU(remote_scroll_sets
, ID2P(LANG_REMOTE_SCROLL_SETS
), 0, Icon_NOICON
,
243 &remote_scroll_speed
, &remote_scroll_delay
,
244 &remote_scroll_step
, &remote_bidir_limit
);
245 #endif /* HAVE_REMOTE_LCD */
246 #ifdef HAVE_LCD_CHARCELLS
247 MENUITEM_SETTING(jump_scroll
, &global_settings
.jump_scroll
, NULL
);
248 MENUITEM_SETTING(jump_scroll_delay
, &global_settings
.jump_scroll_delay
, NULL
);
250 /* list acceleration */
251 #ifndef HAVE_SCROLLWHEEL
252 MENUITEM_SETTING(list_accel_start_delay
,
253 &global_settings
.list_accel_start_delay
, NULL
);
254 MENUITEM_SETTING(list_accel_wait
, &global_settings
.list_accel_wait
, NULL
);
255 #endif /* HAVE_SCROLLWHEEL */
256 #ifdef HAVE_LCD_BITMAP
257 int screenscroll_callback(int action
,const struct menu_item_ex
*this_item
)
262 case ACTION_EXIT_MENUITEM
:
263 gui_list_screen_scroll_out_of_view(global_settings
.offset_out_of_view
);
268 MENUITEM_SETTING(offset_out_of_view
, &global_settings
.offset_out_of_view
,
269 screenscroll_callback
);
270 MENUITEM_SETTING(screen_scroll_step
, &global_settings
.screen_scroll_step
, NULL
);
272 MENUITEM_SETTING(scroll_paginated
, &global_settings
.scroll_paginated
, NULL
);
274 MAKE_MENU(scroll_settings_menu
, ID2P(LANG_SCROLL_MENU
), 0, Icon_NOICON
,
275 &scroll_speed
, &scroll_delay
,
276 #ifdef HAVE_LCD_BITMAP
280 #ifdef HAVE_REMOTE_LCD
283 #ifdef HAVE_LCD_CHARCELLS
284 &jump_scroll
, &jump_scroll_delay
,
286 #ifdef HAVE_LCD_BITMAP
287 &offset_out_of_view
, &screen_scroll_step
,
290 #ifndef HAVE_SCROLLWHEEL
291 &list_accel_start_delay
, &list_accel_wait
295 /***********************************/
297 /***********************************/
299 #ifdef HAVE_LCD_BITMAP
300 MENUITEM_SETTING(scrollbar_item
, &global_settings
.scrollbar
, NULL
);
301 MENUITEM_SETTING(statusbar
, &global_settings
.statusbar
, NULL
);
302 #if CONFIG_KEYPAD == RECORDER_PAD
303 MENUITEM_SETTING(buttonbar
, &global_settings
.buttonbar
, NULL
);
305 MENUITEM_SETTING(volume_type
, &global_settings
.volume_type
, NULL
);
306 MENUITEM_SETTING(battery_display
, &global_settings
.battery_display
, NULL
);
307 MAKE_MENU(bars_menu
, ID2P(LANG_BARS_MENU
), 0, Icon_NOICON
,
308 &scrollbar_item
, &statusbar
,
309 #if CONFIG_KEYPAD == RECORDER_PAD
312 &volume_type
, &battery_display
);
313 #endif /* HAVE_LCD_BITMAP */
315 /***********************************/
318 /***********************************/
319 /* PEAK METER MENU */
321 #ifdef HAVE_LCD_BITMAP
322 int peakmeter_callback(int action
,const struct menu_item_ex
*this_item
)
327 case ACTION_EXIT_MENUITEM
:
328 peak_meter_init_times(global_settings
.peak_meter_release
,
329 global_settings
.peak_meter_hold
,
330 global_settings
.peak_meter_clip_hold
);
335 MENUITEM_SETTING(peak_meter_hold
,
336 &global_settings
.peak_meter_hold
, peakmeter_callback
);
337 MENUITEM_SETTING(peak_meter_clip_hold
,
338 &global_settings
.peak_meter_clip_hold
, peakmeter_callback
);
339 #ifdef HAVE_RECORDING
340 MENUITEM_SETTING(peak_meter_clipcounter
,
341 &global_settings
.peak_meter_clipcounter
, NULL
);
343 MENUITEM_SETTING(peak_meter_release
,
344 &global_settings
.peak_meter_release
, peakmeter_callback
);
346 * Menu to select wether the scale of the meter
347 * displays dBfs of linear values.
349 static int peak_meter_scale(void) {
351 bool use_dbfs
= global_settings
.peak_meter_dbfs
;
352 retval
= set_bool_options(str(LANG_PM_SCALE
),
354 STR(LANG_PM_DBFS
), STR(LANG_PM_LINEAR
),
357 /* has the user really changed the scale? */
358 if (use_dbfs
!= global_settings
.peak_meter_dbfs
) {
360 /* store the change */
361 global_settings
.peak_meter_dbfs
= use_dbfs
;
362 peak_meter_set_use_dbfs(use_dbfs
);
364 /* If the user changed the scale mode the meaning of
365 peak_meter_min (peak_meter_max) has changed. Thus we have
366 to convert the values stored in global_settings. */
369 /* we only store -dBfs */
370 global_settings
.peak_meter_min
= -peak_meter_get_min() / 100;
371 global_settings
.peak_meter_max
= -peak_meter_get_max() / 100;
373 /* limit the returned value to the allowed range */
374 if(global_settings
.peak_meter_min
> 89)
375 global_settings
.peak_meter_min
= 89;
380 global_settings
.peak_meter_min
= peak_meter_get_min();
382 /* converting dBfs -> percent results in a precision loss.
383 I assume that the user doesn't bother that conversion
384 dBfs <-> percent isn't symmetrical for odd values but that
385 he wants 0 dBfs == 100%. Thus I 'correct' the percent value
386 resulting from dBfs -> percent manually here */
387 max
= peak_meter_get_max();
388 global_settings
.peak_meter_max
= max
< 99 ? max
: 100;
390 settings_apply_pm_range();
396 * Adjust the min value of the value range that
397 * the peak meter shall visualize.
399 static int peak_meter_min(void) {
401 if (global_settings
.peak_meter_dbfs
) {
404 int range_max
= -global_settings
.peak_meter_max
;
405 int min
= -global_settings
.peak_meter_min
;
407 retval
= set_int(str(LANG_PM_MIN
), str(LANG_PM_DBFS
), UNIT_DB
,
408 &min
, NULL
, 1, -89, range_max
, NULL
);
410 global_settings
.peak_meter_min
= - min
;
413 /* for linear scale */
415 int min
= global_settings
.peak_meter_min
;
417 retval
= set_int(str(LANG_PM_MIN
), "%", UNIT_PERCENT
,
419 1, 0, global_settings
.peak_meter_max
- 1, NULL
);
421 global_settings
.peak_meter_min
= (unsigned char)min
;
424 settings_apply_pm_range();
430 * Adjust the max value of the value range that
431 * the peak meter shall visualize.
433 static int peak_meter_max(void) {
435 if (global_settings
.peak_meter_dbfs
) {
438 int range_min
= -global_settings
.peak_meter_min
;
439 int max
= -global_settings
.peak_meter_max
;;
441 retval
= set_int(str(LANG_PM_MAX
), str(LANG_PM_DBFS
), UNIT_DB
,
442 &max
, NULL
, 1, range_min
, 0, NULL
);
444 global_settings
.peak_meter_max
= - max
;
448 /* for linear scale */
450 int max
= global_settings
.peak_meter_max
;
452 retval
= set_int(str(LANG_PM_MAX
), "%", UNIT_PERCENT
,
454 1, global_settings
.peak_meter_min
+ 1, 100, NULL
);
456 global_settings
.peak_meter_max
= (unsigned char)max
;
459 settings_apply_pm_range();
462 MENUITEM_FUNCTION(peak_meter_scale_item
, 0, ID2P(LANG_PM_SCALE
),
463 peak_meter_scale
, NULL
, NULL
, Icon_NOICON
);
464 MENUITEM_FUNCTION(peak_meter_min_item
, 0, ID2P(LANG_PM_MIN
),
465 peak_meter_min
, NULL
, NULL
, Icon_NOICON
);
466 MENUITEM_FUNCTION(peak_meter_max_item
, 0, ID2P(LANG_PM_MAX
),
467 peak_meter_max
, NULL
, NULL
, Icon_NOICON
);
468 MAKE_MENU(peak_meter_menu
, ID2P(LANG_PM_MENU
), NULL
, Icon_NOICON
,
469 &peak_meter_release
, &peak_meter_hold
,
470 &peak_meter_clip_hold
,
471 #ifdef HAVE_RECORDING
472 &peak_meter_clipcounter
,
474 &peak_meter_scale_item
, &peak_meter_min_item
, &peak_meter_max_item
);
475 #endif /* HAVE_LCD_BITMAP */
476 /* PEAK METER MENU */
477 /***********************************/
481 MENUITEM_SETTING(codepage_setting
, &global_settings
.default_codepage
, NULL
);
484 MAKE_MENU(display_menu
, ID2P(LANG_DISPLAY
),
485 NULL
, Icon_Display_menu
,
487 #ifdef HAVE_REMOTE_LCD
488 &lcd_remote_settings
,
490 &scroll_settings_menu
,
491 #ifdef HAVE_LCD_BITMAP
492 &bars_menu
, &peak_meter_menu
,