summaryrefslogtreecommitdiff
path: root/firmware/backlight.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/backlight.c')
-rw-r--r--firmware/backlight.c57
1 files changed, 53 insertions, 4 deletions
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{