Ability to control backlight for soft lock action

See Settings -> General Settings -> Display -> LCD Settings -> Backlight on Lock

Change-Id: I201cb1c2907bb6842bf5d0b7a657e9db27aa905a
This commit is contained in:
roman.artiukhin 2023-08-21 00:55:03 +03:00 committed by William Wilgus
parent 6b0e3fe775
commit 7bbaf74c5c
7 changed files with 20 additions and 23 deletions

View file

@ -2347,15 +2347,15 @@
desc: in lcd settings
user: core
<source>
*: none
*: "Backlight on Lock"
hold_button: "Backlight on Hold"
</source>
<dest>
*: none
*: "Backlight on Lock"
hold_button: "Backlight on Hold"
</dest>
<voice>
*: none
*: "Backlight on Lock"
hold_button: "Backlight on hold"
</voice>
</phrase>

View file

@ -149,10 +149,10 @@ MENUITEM_SETTING(backlight_timeout, &global_settings.backlight_timeout, NULL);
MENUITEM_SETTING(backlight_timeout_plugged,
&global_settings.backlight_timeout_plugged, NULL);
#endif
#ifdef HAS_BUTTON_HOLD
MENUITEM_SETTING(backlight_on_button_hold,
&global_settings.backlight_on_button_hold, NULL);
#endif
MENUITEM_SETTING(caption_backlight, &global_settings.caption_backlight, NULL);
#if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
|| defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)
@ -200,9 +200,7 @@ MAKE_MENU(lcd_settings,ID2P(LANG_LCD_MENU),
# if CONFIG_CHARGING
,&backlight_timeout_plugged
# endif
# ifdef HAS_BUTTON_HOLD
,&backlight_on_button_hold
# endif
,&caption_backlight
#if defined(HAVE_BACKLIGHT_FADING_INT_SETTING) \
|| defined(HAVE_BACKLIGHT_FADING_BOOL_SETTING)

View file

@ -1051,9 +1051,7 @@ void settings_apply(bool read_disk)
#ifdef HAVE_REMOTE_LCD
set_remote_backlight_filter_keypress(global_settings.remote_bl_filter_first_keypress);
#endif
#ifdef HAS_BUTTON_HOLD
backlight_set_on_button_hold(global_settings.backlight_on_button_hold);
#endif
#ifdef HAVE_LCD_SLEEP_SETTING
lcd_set_sleep_after_backlight_off(global_settings.lcd_sleep_after_backlight_off);

View file

@ -691,10 +691,8 @@ struct user_settings
#ifdef HAVE_BACKLIGHT
bool bl_selective_actions; /* backlight disable on some actions */
int bl_selective_actions_mask;/* mask of actions that will not enable backlight */
#ifdef HAS_BUTTON_HOLD
int backlight_on_button_hold; /* what to do with backlight when hold
switch is on */
#endif
#ifdef HAVE_LCD_SLEEP_SETTING
int lcd_sleep_after_backlight_off; /* when to put lcd to sleep after backlight
has turned off: -1=never, 0=always,

View file

@ -1846,12 +1846,16 @@ const struct settings_list settings[] = {
ID2P(LANG_IN_SUBMENU)),
#ifdef HAVE_BACKLIGHT
#ifdef HAS_BUTTON_HOLD
CHOICE_SETTING(0, backlight_on_button_hold, LANG_BACKLIGHT_ON_BUTTON_HOLD,
1, "backlight on button hold", "normal,off,on",
CHOICE_SETTING(0, backlight_on_button_hold,
LANG_BACKLIGHT_ON_BUTTON_HOLD,
#ifdef HAS_HOLD_BUTTON
1,
#else
0,
#endif
"backlight on button hold", "normal,off,on",
backlight_set_on_button_hold, 3,
ID2P(LANG_NORMAL), ID2P(LANG_OFF), ID2P(LANG_ON)),
#endif
#ifdef HAVE_LCD_SLEEP_SETTING
TABLE_SETTING_LIST(F_TIME_SETTING | F_ALLOW_ARBITRARY_VALS,

View file

@ -39,6 +39,7 @@
#include "backlight.h"
#include "lcd.h"
#include "screendump.h"
#include "action.h"
#ifdef HAVE_REMOTE_LCD
#include "lcd-remote.h"
@ -120,9 +121,7 @@ static int backlight_timeout_normal = 5*HZ;
#if CONFIG_CHARGING
static int backlight_timeout_plugged = 5*HZ;
#endif
#ifdef HAS_BUTTON_HOLD
static int backlight_on_button_hold = 0;
#endif
static void backlight_handle_timeout(void);
#ifdef HAVE_BUTTON_LIGHT
@ -846,18 +845,18 @@ bool is_backlight_on(bool ignore_always_off)
/* return value in ticks; 0 means always on, <0 means always off */
int backlight_get_current_timeout(void)
{
#ifdef HAS_BUTTON_HOLD
if ((backlight_on_button_hold != 0)
#ifdef HAVE_REMOTE_LCD_AS_MAIN
#if defined(HAVE_REMOTE_LCD_AS_MAIN) && defined(HAS_REMOTE_BUTTON_HOLD)
&& remote_button_hold()
#else
#elifdef HAS_BUTTON_HOLD
&& button_hold()
#else
&& is_keys_locked()
#endif
)
return (backlight_on_button_hold == 2) ? 0 : -1;
/* always on or always off */
else
#endif
#if CONFIG_CHARGING
if (power_input_present())
return backlight_timeout_plugged;
@ -893,6 +892,7 @@ void backlight_hold_changed(bool hold_button)
queue_post(&backlight_queue, BACKLIGHT_ON, 0);
}
}
#endif /* HAS_BUTTON_HOLD */
void backlight_set_on_button_hold(int index)
{
@ -903,7 +903,6 @@ void backlight_set_on_button_hold(int index)
backlight_on_button_hold = index;
queue_post(&backlight_queue, BACKLIGHT_TMO_CHANGED, 0);
}
#endif /* HAS_BUTTON_HOLD */
#ifdef HAVE_LCD_SLEEP_SETTING
void lcd_set_sleep_after_backlight_off(int timeout_seconds)

View file

@ -53,8 +53,8 @@ void backlight_set_timeout_plugged(int value);
#ifdef HAS_BUTTON_HOLD
void backlight_hold_changed(bool hold_button);
void backlight_set_on_button_hold(int index);
#endif
void backlight_set_on_button_hold(int index);
#if defined(HAVE_LCD_SLEEP) && defined(HAVE_LCD_SLEEP_SETTING)
void lcd_set_sleep_after_backlight_off(int timeout_seconds);