summaryrefslogtreecommitdiff
path: root/firmware/backlight.c
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2016-11-22 06:21:31 +0100
committerWilliam Wilgus <me.theuser@yahoo.com>2017-01-17 23:06:17 +0100
commitdc87e9e9f3c383b63c3cb3713886a6c93b6a79d1 (patch)
tree47a6c0d49e7741f91fa74d7230b1267f60617902 /firmware/backlight.c
parent16a9f84571276a13f4cfd5c66db8cd63ce4e2e7f (diff)
downloadrockbox-dc87e9e9f3c383b63c3cb3713886a6c93b6a79d1.tar.gz
rockbox-dc87e9e9f3c383b63c3cb3713886a6c93b6a79d1.zip
Selective Backlight/Advanced Softlock - Selective actions based on context
Selective backlight allows the user to choose actions that will not enable the backlight when pressed. Advanced softlock allows user to choose actions that will not be blocked by screenlock on devices without a hold button. Both only occur in FM and WPS Contexts. Update: Back from the dead -Cleaned up code, removed unnecessary calls, re-arranged last filter action timeout conditional to work in case last_filtered_action_tick was never set -Added entries to the manual -Fixed back button on some menus not activating backlight -Made menus more intuitive, no actions selected now changes menu item to off. -Added talk fuctionality. -Added option to disable selective backlight while on external power. -Rewrote backlight and softlock handling code to fix issue with scrollwheels -Menu changed to have toggle(yes/no) and settings -Optimized selective actions lookup -Added option to disable notification of 'buttons locked' while softlocked -Removed uneeded code, consolidated action lookup to single function -Fixed incorrect name on selective softlock menu -Added option to disable touch on touchscreen devices -Fixed backlight on original screenlock without selective screenlock active -Added text selection in mask_select for when show_icons is off -Fixed voice in mask_select to speak if voice is defined instead of spelling -Added more lang defines (play skip seek) -Added option to disable unknown keys turning on backlight -Fixed Conditional argument In wrong place causing players without backlight to fail to build -Fixed Disable Unknown blocking detection of context change -Fixed canceling menu didn't update new settings -Added Autolock on backlight off -Removed backlight_on_force from backlight.c, Now sets ignore next to false and uses backlight_on -Cleaned up autolock code added strings to lang file -Fixed issue where rapid presses would bypass softlock -Removed old softlock code, Cleaned selective actions code -Changed menu to match existing RB menus -Fixed Backlight_on_Hold blocked by backlight_ignore_next -Fixed ignore_next for ipod -Fixed bug allowing context with softlock to bypass selective backlight -Changed mask_select to no longer prompt for changes to be saved -Changed menu names -Added ignore timeout to allow ipod scroll wheel to work properly and other players to still work properly, removed some previous code including ignore_event -Increased ignore timeout to prevent sd card accesses from interrupting action code and turning on backlight -Changed Unknown action to unmapped action in menu, changed handling code -Removed unneeded logic and variables for handling unfiltered actions -Reverted unmapped action code to previous functionality -Added manual entries (thanks JohnB) -Removed elusive unhandled unicode character from manual, changed formatting slightly Actions: Volume,Play,Seek,Skip Extras: Disable unmapped actions Disable selective backlight on external power Disable touch during softlock on touchscreen devices Disable softlock notifications (power button still notifies) Autolock on backlight off Method: Adds a function to ignore backlight on next call If selected action occurs backlight is forced on, Filter_first_keypress stays intact. Selective softlock allows selected actions through, bypasses the normal softlock routine. ToDo: DONE previous commit (#1) has attribution for folder_select.c which mask_select is based from. Change-Id: I08132ddcfd64c81751ef23b720f3ec6d68695fe4
Diffstat (limited to 'firmware/backlight.c')
-rw-r--r--firmware/backlight.c54
1 files changed, 47 insertions, 7 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 19a1d21eb5..25c295197f 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -103,6 +103,8 @@ static void backlight_thread(void);
103static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)]; 103static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)];
104static const char backlight_thread_name[] = "backlight"; 104static const char backlight_thread_name[] = "backlight";
105static struct event_queue backlight_queue SHAREDBSS_ATTR; 105static struct event_queue backlight_queue SHAREDBSS_ATTR;
106static bool ignore_backlight_on = false;
107static int backlight_ignored_timer = 0;
106#ifdef BACKLIGHT_DRIVER_CLOSE 108#ifdef BACKLIGHT_DRIVER_CLOSE
107static unsigned int backlight_thread_id = 0; 109static unsigned int backlight_thread_id = 0;
108#endif 110#endif
@@ -123,6 +125,8 @@ static void backlight_timeout_handler(void);
123#ifdef HAVE_BUTTON_LIGHT 125#ifdef HAVE_BUTTON_LIGHT
124static int buttonlight_timer; 126static int buttonlight_timer;
125static int buttonlight_timeout = 5*HZ; 127static int buttonlight_timeout = 5*HZ;
128static bool ignore_buttonlight_on = false;
129static int buttonlight_ignored_timer = 0;
126 130
127/* Update state of buttonlight according to timeout setting */ 131/* Update state of buttonlight according to timeout setting */
128static void buttonlight_update_state(void) 132static void buttonlight_update_state(void)
@@ -140,10 +144,20 @@ static void buttonlight_update_state(void)
140} 144}
141 145
142/* external interface */ 146/* external interface */
147
143void buttonlight_on(void) 148void buttonlight_on(void)
144{ 149{
145 queue_remove_from_head(&backlight_queue, BUTTON_LIGHT_ON); 150 if(!ignore_buttonlight_on)
146 queue_post(&backlight_queue, BUTTON_LIGHT_ON, 0); 151 {
152 queue_remove_from_head(&backlight_queue, BUTTON_LIGHT_ON);
153 queue_post(&backlight_queue, BUTTON_LIGHT_ON, 0);
154 }
155}
156
157void buttonlight_on_ignore(bool value, int timeout)
158{
159 ignore_buttonlight_on = value;
160 buttonlight_ignored_timer = timeout;
147} 161}
148 162
149void buttonlight_off(void) 163void buttonlight_off(void)
@@ -232,7 +246,7 @@ static int backlight_fading_state = NOT_FADING;
232/* s15.16 fixed point variables */ 246/* s15.16 fixed point variables */
233static int32_t bl_fade_in_step = ((BL_PWM_INTERVAL*BL_PWM_COUNT)<<16)/300; 247static int32_t bl_fade_in_step = ((BL_PWM_INTERVAL*BL_PWM_COUNT)<<16)/300;
234static int32_t bl_fade_out_step = ((BL_PWM_INTERVAL*BL_PWM_COUNT)<<16)/2000; 248static int32_t bl_fade_out_step = ((BL_PWM_INTERVAL*BL_PWM_COUNT)<<16)/2000;
235static int32_t bl_dim_fraction = 0; 249static int32_t bl_dim_fraction = 0;
236 250
237static int bl_dim_target = 0; 251static int bl_dim_target = 0;
238static int bl_dim_current = 0; 252static int bl_dim_current = 0;
@@ -642,7 +656,7 @@ void backlight_thread(void)
642 buttonlight_hw_off(); 656 buttonlight_hw_off();
643 break; 657 break;
644#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS 658#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
645 case BUTTON_LIGHT_BRIGHTNESS_CHANGED: 659 case BUTTON_LIGHT_BRIGHTNESS_CHANGED:
646 buttonlight_hw_brightness((int)ev.data); 660 buttonlight_hw_brightness((int)ev.data);
647 break; 661 break;
648#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */ 662#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
@@ -723,7 +737,19 @@ static void backlight_timeout_handler(void)
723 buttonlight_hw_off(); 737 buttonlight_hw_off();
724 } 738 }
725 } 739 }
740 if (buttonlight_ignored_timer > 0)
741 {
742 buttonlight_ignored_timer -= BACKLIGHT_THREAD_TIMEOUT;
743 if (buttonlight_ignored_timer <= 0)
744 ignore_buttonlight_on = false;
745 }
726#endif /* HAVE_BUTTON_LIGHT */ 746#endif /* HAVE_BUTTON_LIGHT */
747 if (backlight_ignored_timer > 0)
748 {
749 backlight_ignored_timer -= BACKLIGHT_THREAD_TIMEOUT;
750 if (backlight_ignored_timer <= 0)
751 ignore_backlight_on = false;
752 }
727} 753}
728 754
729void backlight_init(void) 755void backlight_init(void)
@@ -768,8 +794,17 @@ void backlight_close(void)
768 794
769void backlight_on(void) 795void backlight_on(void)
770{ 796{
771 queue_remove_from_head(&backlight_queue, BACKLIGHT_ON); 797 if(!ignore_backlight_on)
772 queue_post(&backlight_queue, BACKLIGHT_ON, 0); 798 {
799 queue_remove_from_head(&backlight_queue, BACKLIGHT_ON);
800 queue_post(&backlight_queue, BACKLIGHT_ON, 0);
801 }
802}
803
804void backlight_on_ignore(bool value, int timeout)
805{
806 ignore_backlight_on = value;
807 backlight_ignored_timer = timeout;
773} 808}
774 809
775void backlight_off(void) 810void backlight_off(void)
@@ -829,8 +864,13 @@ void backlight_set_timeout_plugged(int value)
829void backlight_hold_changed(bool hold_button) 864void backlight_hold_changed(bool hold_button)
830{ 865{
831 if (!hold_button || (backlight_on_button_hold > 0)) 866 if (!hold_button || (backlight_on_button_hold > 0))
867 {
832 /* if unlocked or override in effect */ 868 /* if unlocked or override in effect */
833 backlight_on(); 869
870 /*backlight_on(); REMOVED*/
871 queue_remove_from_head(&backlight_queue, BACKLIGHT_ON);
872 queue_post(&backlight_queue, BACKLIGHT_ON, 0);
873 }
834} 874}
835 875
836void backlight_set_on_button_hold(int index) 876void backlight_set_on_button_hold(int index)