summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/settings.c11
-rw-r--r--apps/settings.h12
-rw-r--r--apps/settings_menu.c19
-rw-r--r--firmware/backlight.c57
-rw-r--r--firmware/drivers/adc.c2
-rw-r--r--firmware/drivers/button.c10
-rw-r--r--firmware/export/backlight.h23
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/adc-x5.c2
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/button-x5.c16
-rw-r--r--firmware/target/coldfire/iaudio/x5/pcf50606-x5.c2
10 files changed, 131 insertions, 23 deletions
diff --git a/apps/settings.c b/apps/settings.c
index 8dcad6bae4..d2b220f893 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -647,6 +647,14 @@ static const struct bit_entry hd_bits[] =
647 {8|SIGNED, S_O(rec_agc_maxgain_line), 96, "agc maximum line gain", NULL}, 647 {8|SIGNED, S_O(rec_agc_maxgain_line), 96, "agc maximum line gain", NULL},
648 {3, S_O(rec_agc_cliptime), 1, "agc cliptime", "0.2s,0.4s,0.6s,0.8,1s"}, 648 {3, S_O(rec_agc_cliptime), 1, "agc cliptime", "0.2s,0.4s,0.6s,0.8,1s"},
649#endif 649#endif
650
651#ifdef HAVE_REMOTE_LCD
652#ifdef HAS_REMOTE_BUTTON_HOLD
653 {2, S_O(remote_backlight_on_button_hold), 0, "remote backlight on button hold",
654 "normal,off,on" },
655#endif
656#endif
657
650 /* If values are just added to the end, no need to bump the version. */ 658 /* If values are just added to the end, no need to bump the version. */
651 /* new stuff to be added at the end */ 659 /* new stuff to be added at the end */
652 660
@@ -1108,7 +1116,10 @@ void settings_apply(void)
1108#ifdef CONFIG_CHARGING 1116#ifdef CONFIG_CHARGING
1109 remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged); 1117 remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged);
1110#endif 1118#endif
1119#ifdef HAS_REMOTE_BUTTON_HOLD
1120 remote_backlight_set_on_button_hold(global_settings.remote_backlight_on_button_hold);
1111#endif 1121#endif
1122#endif /* HAVE_REMOTE_LCD */
1112#ifdef CONFIG_BACKLIGHT 1123#ifdef CONFIG_BACKLIGHT
1113 backlight_set_timeout(global_settings.backlight_timeout); 1124 backlight_set_timeout(global_settings.backlight_timeout);
1114#ifdef CONFIG_CHARGING 1125#ifdef CONFIG_CHARGING
diff --git a/apps/settings.h b/apps/settings.h
index b66e96b765..561dc59375 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -354,11 +354,15 @@ struct user_settings
354 then according to timeout_values[] */ 354 then according to timeout_values[] */
355 int remote_backlight_timeout_plugged; 355 int remote_backlight_timeout_plugged;
356 bool remote_caption_backlight; /* turn on backlight at end and start of track */ 356 bool remote_caption_backlight; /* turn on backlight at end and start of track */
357#ifdef HAS_REMOTE_BUTTON_HOLD
358 int remote_backlight_on_button_hold; /* what to do with remote backlight when hold
359 switch is on */
360#endif
357#ifdef HAVE_REMOTE_LCD_TICKING 361#ifdef HAVE_REMOTE_LCD_TICKING
358 bool remote_reduce_ticking; /* 0=normal operation, 362 bool remote_reduce_ticking; /* 0=normal operation,
359 1=EMI reduce on with cost more CPU. */ 363 1=EMI reduce on with cost more CPU. */
360#endif 364#endif
361#endif 365#endif /* HAVE_REMOTE_LCD */
362 366
363 bool next_folder; /* move to next folder */ 367 bool next_folder; /* move to next folder */
364 bool runtimedb; /* runtime database active? */ 368 bool runtimedb; /* runtime database active? */
@@ -446,10 +450,12 @@ struct user_settings
446 bool remote_bl_filter_first_keypress; /* filter first remote keypress when remote dark? */ 450 bool remote_bl_filter_first_keypress; /* filter first remote keypress when remote dark? */
447#endif 451#endif
448#ifdef HAS_BUTTON_HOLD 452#ifdef HAS_BUTTON_HOLD
449 int backlight_on_button_hold; 453 int backlight_on_button_hold; /* what to do with backlight when hold
454 switch is on */
450#endif 455#endif
451#ifdef HAVE_LCD_SLEEP 456#ifdef HAVE_LCD_SLEEP
452 int lcd_sleep_after_backlight_off; 457 int lcd_sleep_after_backlight_off; /* when to put lcd to sleep after backlight
458 has turned off */
453#endif 459#endif
454#endif /* CONFIG_BACKLIGHT */ 460#endif /* CONFIG_BACKLIGHT */
455 461
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 5f84dc1d34..ab19c820be 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -315,6 +315,22 @@ static bool remote_caption_backlight(void)
315 return set_bool((char *)str(LANG_CAPTION_BACKLIGHT), 315 return set_bool((char *)str(LANG_CAPTION_BACKLIGHT),
316 &global_settings.remote_caption_backlight); 316 &global_settings.remote_caption_backlight);
317} 317}
318
319#ifdef HAS_REMOTE_BUTTON_HOLD
320static bool remote_backlight_on_button_hold(void)
321{
322 static const struct opt_items names[3] = {
323 { STR(LANG_BACKLIGHT_ON_BUTTON_HOLD_NORMAL) },
324 { STR(LANG_OFF) },
325 { STR(LANG_ON) },
326 };
327 return set_option(str(LANG_BACKLIGHT_ON_BUTTON_HOLD),
328 &global_settings.remote_backlight_on_button_hold,
329 INT, names, 3,
330 remote_backlight_set_on_button_hold);
331}
332#endif /* HAS_BUTTON_HOLD */
333
318#endif /* HAVE_REMOTE_LCD */ 334#endif /* HAVE_REMOTE_LCD */
319 335
320#ifdef HAVE_LCD_CONTRAST 336#ifdef HAVE_LCD_CONTRAST
@@ -1887,6 +1903,9 @@ static bool lcd_remote_settings_menu(void)
1887 { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING), 1903 { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING),
1888 remote_backlight_timer_plugged }, 1904 remote_backlight_timer_plugged },
1889#endif 1905#endif
1906#ifdef HAS_REMOTE_BUTTON_HOLD
1907 { ID2P(LANG_BACKLIGHT_ON_BUTTON_HOLD), remote_backlight_on_button_hold },
1908#endif
1890 { ID2P(LANG_CAPTION_BACKLIGHT), remote_caption_backlight }, 1909 { ID2P(LANG_CAPTION_BACKLIGHT), remote_caption_backlight },
1891 { ID2P(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS), set_remote_bl_filter_first_keypress }, 1910 { ID2P(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS), set_remote_bl_filter_first_keypress },
1892 { ID2P(LANG_CONTRAST), remote_contrast }, 1911 { ID2P(LANG_CONTRAST), remote_contrast },
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 6f7432c9e2..bf88cbe9bc 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -178,6 +178,9 @@ static int remote_backlight_timeout = 5*HZ;
178#ifdef CONFIG_CHARGING 178#ifdef CONFIG_CHARGING
179static int remote_backlight_timeout_plugged = 5*HZ; 179static int remote_backlight_timeout_plugged = 5*HZ;
180#endif 180#endif
181#ifdef HAS_REMOTE_BUTTON_HOLD
182static int remote_backlight_on_button_hold = 0;
183#endif
181#endif 184#endif
182 185
183#ifdef HAVE_LCD_SLEEP 186#ifdef HAVE_LCD_SLEEP
@@ -461,6 +464,10 @@ static void remote_backlight_update_state(void)
461 if (remote_backlight_timer < 0) 464 if (remote_backlight_timer < 0)
462 { 465 {
463 remote_backlight_timer = 0; /* Disable the timeout */ 466 remote_backlight_timer = 0; /* Disable the timeout */
467#ifdef HAS_REMOTE_BUTTON_HOLD
468 if (remote_backlight_on_button_hold == 2 && remote_button_hold())
469 return; /* Keep on if "On" */
470#endif
464 __remote_backlight_off(); 471 __remote_backlight_off();
465 } 472 }
466 else 473 else
@@ -471,8 +478,18 @@ static void remote_backlight_update_state(void)
471 backlight_update_state(); 478 backlight_update_state();
472 } 479 }
473 else 480 else
474#endif 481#endif
482 {
483#ifdef HAS_REMOTE_BUTTON_HOLD
484 if (remote_backlight_on_button_hold == 1 && remote_button_hold())
485 {
486 /* Keep off if "Off". */
487 remote_backlight_timer = 0; /* Disable the timeout */
488 return;
489 }
490#endif
475 __remote_backlight_on(); 491 __remote_backlight_on();
492 }
476 } 493 }
477} 494}
478#endif /* HAVE_REMOTE_LCD */ 495#endif /* HAVE_REMOTE_LCD */
@@ -493,9 +510,15 @@ void backlight_thread(void)
493 510
494 case REMOTE_BACKLIGHT_OFF: 511 case REMOTE_BACKLIGHT_OFF:
495 remote_backlight_timer = 0; /* Disable the timeout */ 512 remote_backlight_timer = 0; /* Disable the timeout */
513#ifdef HAS_REMOTE_BUTTON_HOLD
514 if (remote_backlight_on_button_hold == 2 &&
515 remote_button_hold())
516 break; /* Keep on if "On" */
517#endif
496 __remote_backlight_off(); 518 __remote_backlight_off();
497 break; 519 break;
498#endif 520#endif /* HAVE_REMOTE_LCD */
521
499 case BACKLIGHT_ON: 522 case BACKLIGHT_ON:
500 backlight_update_state(); 523 backlight_update_state();
501 break; 524 break;
@@ -701,9 +724,7 @@ void backlight_hold_changed(bool hold_button)
701 set to "Normal" */ 724 set to "Normal" */
702 /* Queue or freeze */ 725 /* Queue or freeze */
703 if (hold_button && backlight_on_button_hold == 1) 726 if (hold_button && backlight_on_button_hold == 1)
704 {
705 backlight_off(); /* setting == Off */ 727 backlight_off(); /* setting == Off */
706 }
707 else /* setting == On, Normal, no hold button, or anything else */ 728 else /* setting == On, Normal, no hold button, or anything else */
708 backlight_on(); 729 backlight_on();
709} 730}
@@ -774,6 +795,34 @@ void remote_backlight_set_timeout_plugged(int index)
774} 795}
775#endif /* CONFIG_CHARGING */ 796#endif /* CONFIG_CHARGING */
776 797
798#ifdef HAS_REMOTE_BUTTON_HOLD
799/* Remote hold button change event handler. */
800void remote_backlight_hold_changed(bool rc_hold_button)
801{
802 /* Hold switch overrides all backlight behavior except when
803 set to "Normal" */
804 /* Queue or freeze */
805 if (rc_hold_button && remote_backlight_on_button_hold == 1)
806 remote_backlight_off(); /* setting == Off */
807 else /* setting == On, Normal, no hold button, or anything else */
808 remote_backlight_on();
809
810}
811
812void remote_backlight_set_on_button_hold(int index)
813{
814 if ((unsigned)index >= 3)
815 /* if given a weird value, use default */
816 index = 0;
817
818 if (index == remote_backlight_on_button_hold)
819 return;
820
821 remote_backlight_on_button_hold = index;
822 remote_backlight_hold_changed(remote_button_hold());
823}
824#endif /* HAS_REMOTE_BUTTON_HOLD */
825
777/* return value in ticks; 0 means always on, <0 means always off */ 826/* return value in ticks; 0 means always on, <0 means always off */
778int remote_backlight_get_current_timeout(void) 827int remote_backlight_get_current_timeout(void)
779{ 828{
diff --git a/firmware/drivers/adc.c b/firmware/drivers/adc.c
index 1ebac066e7..d00f89958a 100644
--- a/firmware/drivers/adc.c
+++ b/firmware/drivers/adc.c
@@ -123,6 +123,7 @@ static int channelnum[] =
123 123
124unsigned short adc_scan(int channel) 124unsigned short adc_scan(int channel)
125{ 125{
126 int level = set_irq_level(HIGHEST_IRQ_LEVEL);
126 unsigned char data; 127 unsigned char data;
127 128
128 pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1); 129 pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1);
@@ -130,6 +131,7 @@ unsigned short adc_scan(int channel)
130 131
131 adcdata[channel] = data; 132 adcdata[channel] = data;
132 133
134 set_irq_level(level);
133 return data; 135 return data;
134} 136}
135#else 137#else
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index f31ab33c87..5e6f6b4827 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -845,6 +845,7 @@ static int button_read(void)
845 static int prev_data = 0xff; 845 static int prev_data = 0xff;
846 static int last_valid = 0xff; 846 static int last_valid = 0xff;
847 bool hold_button_old; 847 bool hold_button_old;
848 bool remote_hold_button_old;
848 849
849 /* normal buttons */ 850 /* normal buttons */
850 hold_button_old = hold_button; 851 hold_button_old = hold_button;
@@ -916,12 +917,13 @@ static int button_read(void)
916 } 917 }
917 918
918 /* remote buttons */ 919 /* remote buttons */
920 remote_hold_button_old = remote_hold_button;
919 remote_hold_button = remote_button_hold_only(); 921 remote_hold_button = remote_button_hold_only();
920 922
921 if (remote_hold_button && !remote_button_hold_only()) 923#ifndef BOOTLOADER
922 { 924 if (remote_hold_button != remote_hold_button_old)
923 remote_backlight_on(); 925 remote_backlight_hold_changed(remote_hold_button);
924 } 926#endif
925 927
926 if (!remote_hold_button) 928 if (!remote_hold_button)
927 { 929 {
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h
index 62f024816f..6875768f0c 100644
--- a/firmware/export/backlight.h
+++ b/firmware/export/backlight.h
@@ -25,27 +25,35 @@ bool is_backlight_on(void);
25void backlight_on(void); 25void backlight_on(void);
26void backlight_off(void); 26void backlight_off(void);
27void backlight_set_timeout(int index); 27void backlight_set_timeout(int index);
28
28#ifdef CONFIG_BACKLIGHT 29#ifdef CONFIG_BACKLIGHT
29void backlight_init(void); 30void backlight_init(void);
31
30#if defined(IAUDIO_X5) && !defined(SIMULATOR) 32#if defined(IAUDIO_X5) && !defined(SIMULATOR)
31#define X5_BACKLIGHT_SHUTDOWN 33#define X5_BACKLIGHT_SHUTDOWN
32void x5_backlight_shutdown(void); 34void x5_backlight_shutdown(void);
33#endif 35#endif
36
34int backlight_get_current_timeout(void); 37int backlight_get_current_timeout(void);
38
35#ifdef HAVE_BACKLIGHT_PWM_FADING 39#ifdef HAVE_BACKLIGHT_PWM_FADING
36void backlight_set_fade_in(int index); 40void backlight_set_fade_in(int index);
37void backlight_set_fade_out(int index); 41void backlight_set_fade_out(int index);
38#endif 42#endif
43
39void backlight_set_timeout_plugged(int index); 44void backlight_set_timeout_plugged(int index);
40extern const signed char backlight_timeout_value[]; 45extern const signed char backlight_timeout_value[];
46
41#ifdef HAS_BUTTON_HOLD 47#ifdef HAS_BUTTON_HOLD
42void backlight_set_on_button_hold(int index);
43void backlight_hold_changed(bool hold_button); 48void backlight_hold_changed(bool hold_button);
49void backlight_set_on_button_hold(int index);
44#endif 50#endif
51
45#ifdef HAVE_LCD_SLEEP 52#ifdef HAVE_LCD_SLEEP
46void lcd_set_sleep_after_backlight_off(int index); 53void lcd_set_sleep_after_backlight_off(int index);
47extern const signed char lcd_sleep_timeout_value[]; 54extern const signed char lcd_sleep_timeout_value[];
48#endif 55#endif
56
49#else /* ndef CONFIG_BACKLIGHT */ 57#else /* ndef CONFIG_BACKLIGHT */
50#define backlight_init() 58#define backlight_init()
51#endif /* CONFIG_BACKLIGHT */ 59#endif /* CONFIG_BACKLIGHT */
@@ -56,15 +64,20 @@ void remote_backlight_off(void);
56void remote_backlight_set_timeout(int index); 64void remote_backlight_set_timeout(int index);
57void remote_backlight_set_timeout_plugged(int index); 65void remote_backlight_set_timeout_plugged(int index);
58bool is_remote_backlight_on(void); 66bool is_remote_backlight_on(void);
67
68#ifdef HAS_REMOTE_BUTTON_HOLD
69void remote_backlight_hold_changed(bool rc_hold_button);
70void remote_backlight_set_on_button_hold(int index);
59#endif 71#endif
72#endif /* HAVE_REMOTE_LCD */
60 73
61#ifdef SIMULATOR 74#ifdef SIMULATOR
62void sim_backlight(int value); 75void sim_backlight(int value);
63void sim_remote_backlight(int value); 76void sim_remote_backlight(int value);
64#endif 77#endif
65#endif
66 78
67#ifdef HAVE_BACKLIGHT_BRIGHTNESS 79#ifdef HAVE_BACKLIGHT_BRIGHTNESS
80
68#ifdef IAUDIO_X5 81#ifdef IAUDIO_X5
69/* PFC50506 can output 0%-100% duty cycle but D305A expects %15-100%. */ 82/* PFC50506 can output 0%-100% duty cycle but D305A expects %15-100%. */
70#define MIN_BRIGHTNESS_SETTING 1 /* 15/16 (93.75%) */ 83#define MIN_BRIGHTNESS_SETTING 1 /* 15/16 (93.75%) */
@@ -74,7 +87,9 @@ void sim_remote_backlight(int value);
74#define MIN_BRIGHTNESS_SETTING 2 /* 2/16 (12.50%) */ 87#define MIN_BRIGHTNESS_SETTING 2 /* 2/16 (12.50%) */
75#define MAX_BRIGHTNESS_SETTING 15 /* 15/16 (93.75%) */ 88#define MAX_BRIGHTNESS_SETTING 15 /* 15/16 (93.75%) */
76#define DEFAULT_BRIGHTNESS_SETTING 9 /* 9/16 (56.25%) */ 89#define DEFAULT_BRIGHTNESS_SETTING 9 /* 9/16 (56.25%) */
77#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ 90#endif
78 91
79void backlight_set_brightness(int val); 92void backlight_set_brightness(int val);
80#endif 93#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
94
95#endif /* BACKLIGHT_H */
diff --git a/firmware/target/coldfire/iaudio/x5/adc-x5.c b/firmware/target/coldfire/iaudio/x5/adc-x5.c
index e465f38494..fc45da8624 100755
--- a/firmware/target/coldfire/iaudio/x5/adc-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/adc-x5.c
@@ -35,6 +35,7 @@ static int channelnum[] =
35 35
36unsigned short adc_scan(int channel) 36unsigned short adc_scan(int channel)
37{ 37{
38 int level = set_irq_level(HIGHEST_IRQ_LEVEL);
38 unsigned char data; 39 unsigned char data;
39 40
40 pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1); 41 pcf50606_write(0x2f, 0x80 | (channelnum[channel] << 1) | 1);
@@ -42,6 +43,7 @@ unsigned short adc_scan(int channel)
42 43
43 adcdata[channel] = data; 44 adcdata[channel] = data;
44 45
46 set_irq_level(level);
45 return data; 47 return data;
46} 48}
47 49
diff --git a/firmware/target/coldfire/iaudio/x5/button-x5.c b/firmware/target/coldfire/iaudio/x5/button-x5.c
index 287ee0e92b..84d1dbc7d8 100755
--- a/firmware/target/coldfire/iaudio/x5/button-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/button-x5.c
@@ -41,7 +41,7 @@ bool button_hold(void)
41 41
42bool remote_button_hold(void) 42bool remote_button_hold(void)
43{ 43{
44 return false; /* TODO X5 */ 44 return adc_scan(ADC_REMOTE) < 0x17;
45} 45}
46 46
47int button_read_device(void) 47int button_read_device(void)
@@ -51,6 +51,7 @@ int button_read_device(void)
51 static bool hold_button = false; 51 static bool hold_button = false;
52 static bool remote_hold_button = false; 52 static bool remote_hold_button = false;
53 bool hold_button_old; 53 bool hold_button_old;
54 bool remote_hold_button_old;
54 55
55 /* normal buttons */ 56 /* normal buttons */
56 hold_button_old = hold_button; 57 hold_button_old = hold_button;
@@ -90,14 +91,15 @@ int button_read_device(void)
90 } 91 }
91 92
92 /* remote buttons */ 93 /* remote buttons */
93 94 remote_hold_button_old = remote_hold_button;
94 /* TODO: add light handling for the remote */
95
96 remote_hold_button = remote_button_hold();
97 95
98 data = adc_scan(ADC_REMOTE); 96 data = adc_scan(ADC_REMOTE);
99 if(data < 0x17) 97 remote_hold_button = data < 0x17;
100 remote_hold_button = true; 98
99#ifndef BOOTLOADER
100 if (remote_hold_button != remote_hold_button_old)
101 remote_backlight_hold_changed(remote_hold_button);
102#endif
101 103
102 if(!remote_hold_button) 104 if(!remote_hold_button)
103 { 105 {
diff --git a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
index dde20d8b7c..032c30814a 100644
--- a/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/pcf50606-x5.c
@@ -177,7 +177,7 @@ void pcf50606_init(void)
177 and_l(~0x00000001, &GPIO_ENABLE); 177 and_l(~0x00000001, &GPIO_ENABLE);
178 or_l(0x00000001, &GPIO_FUNCTION); 178 or_l(0x00000001, &GPIO_FUNCTION);
179 or_l(0x00000100, &GPIO_INT_EN); /* GPI0 H-L */ 179 or_l(0x00000100, &GPIO_INT_EN); /* GPI0 H-L */
180 INTPRI5 |= 0x00000006; /* INT32 - Priority 6 */ 180 INTPRI5 |= (6 << 0); /* INT32 - Priority 6 */
181 181
182 pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */ 182 pcf50606_write(0x39, 0x00); /* GPOOD0 = green led OFF */
183 pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */ 183 pcf50606_write(0x3a, 0x00); /* GPOOD1 = red led OFF */