Merge pull request #4010 from gudnimg/improve-backlight-control
backlight: always allow backlight to dim/wake
This commit is contained in:
commit
afc866e756
|
|
@ -15,6 +15,7 @@
|
||||||
#include "fastio.h"
|
#include "fastio.h"
|
||||||
//-//
|
//-//
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "backlight.h"
|
||||||
|
|
||||||
#define LCD_DEFAULT_DELAY 100
|
#define LCD_DEFAULT_DELAY 100
|
||||||
|
|
||||||
|
|
@ -638,6 +639,7 @@ int8_t lcd_encoder_diff = 0;
|
||||||
uint8_t lcd_buttons = 0;
|
uint8_t lcd_buttons = 0;
|
||||||
uint8_t lcd_button_pressed = 0;
|
uint8_t lcd_button_pressed = 0;
|
||||||
uint8_t lcd_update_enabled = 1;
|
uint8_t lcd_update_enabled = 1;
|
||||||
|
static bool lcd_backlight_wake_trigger; // Flag set by interrupt when the knob is pressed or rotated
|
||||||
|
|
||||||
uint32_t lcd_next_update_millis = 0;
|
uint32_t lcd_next_update_millis = 0;
|
||||||
|
|
||||||
|
|
@ -695,8 +697,16 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
|
||||||
{
|
{
|
||||||
if (lcd_draw_update < lcdDrawUpdateOverride)
|
if (lcd_draw_update < lcdDrawUpdateOverride)
|
||||||
lcd_draw_update = lcdDrawUpdateOverride;
|
lcd_draw_update = lcdDrawUpdateOverride;
|
||||||
if (!lcd_update_enabled)
|
|
||||||
return;
|
if (lcd_backlight_wake_trigger) {
|
||||||
|
lcd_backlight_wake_trigger = false;
|
||||||
|
backlight_wake();
|
||||||
|
}
|
||||||
|
|
||||||
|
backlight_update();
|
||||||
|
|
||||||
|
if (!lcd_update_enabled) return;
|
||||||
|
|
||||||
if (lcd_lcdupdate_func)
|
if (lcd_lcdupdate_func)
|
||||||
lcd_lcdupdate_func();
|
lcd_lcdupdate_func();
|
||||||
}
|
}
|
||||||
|
|
@ -742,6 +752,7 @@ void lcd_buttons_update(void)
|
||||||
if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) {
|
if (!buttonBlanking.running() || buttonBlanking.expired(BUTTON_BLANKING_TIME)) {
|
||||||
buttonBlanking.start();
|
buttonBlanking.start();
|
||||||
safetyTimer.start();
|
safetyTimer.start();
|
||||||
|
lcd_backlight_wake_trigger = true; // flag event, knob pressed
|
||||||
if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
|
if ((lcd_button_pressed == 0) && (lcd_long_press_active == 0))
|
||||||
{
|
{
|
||||||
longPressTimer.start();
|
longPressTimer.start();
|
||||||
|
|
@ -803,6 +814,10 @@ void lcd_buttons_update(void)
|
||||||
lcd_encoder_diff--;
|
lcd_encoder_diff--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (abs(lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP) {
|
||||||
|
lcd_backlight_wake_trigger = true; // flag event, knob rotated
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lcd_encoder_bits = enc;
|
lcd_encoder_bits = enc;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,6 @@ Sound_SaveMode();
|
||||||
|
|
||||||
//if critical is true then silend and once mode is ignored
|
//if critical is true then silend and once mode is ignored
|
||||||
void __attribute__((noinline)) Sound_MakeCustom(uint16_t ms,uint16_t tone_,bool critical){
|
void __attribute__((noinline)) Sound_MakeCustom(uint16_t ms,uint16_t tone_,bool critical){
|
||||||
backlight_wake();
|
|
||||||
if (critical || eSoundMode != e_SOUND_MODE_SILENT) {
|
if (critical || eSoundMode != e_SOUND_MODE_SILENT) {
|
||||||
if(!tone_) {
|
if(!tone_) {
|
||||||
WRITE(BEEPER, HIGH);
|
WRITE(BEEPER, HIGH);
|
||||||
|
|
@ -127,7 +126,6 @@ static void Sound_DoSound_Blind_Alert(void)
|
||||||
|
|
||||||
static void Sound_DoSound_Encoder_Move(void)
|
static void Sound_DoSound_Encoder_Move(void)
|
||||||
{
|
{
|
||||||
backlight_wake();
|
|
||||||
uint8_t nI;
|
uint8_t nI;
|
||||||
|
|
||||||
for(nI=0;nI<5;nI++)
|
for(nI=0;nI<5;nI++)
|
||||||
|
|
@ -141,7 +139,6 @@ uint8_t nI;
|
||||||
|
|
||||||
static void Sound_DoSound_Echo(void)
|
static void Sound_DoSound_Echo(void)
|
||||||
{
|
{
|
||||||
backlight_wake();
|
|
||||||
uint8_t nI;
|
uint8_t nI;
|
||||||
|
|
||||||
for(nI=0;nI<10;nI++)
|
for(nI=0;nI<10;nI++)
|
||||||
|
|
@ -163,7 +160,6 @@ WRITE(BEEPER,LOW);
|
||||||
|
|
||||||
static void Sound_DoSound_Alert(bool bOnce)
|
static void Sound_DoSound_Alert(bool bOnce)
|
||||||
{
|
{
|
||||||
backlight_wake();
|
|
||||||
uint8_t nI,nMax;
|
uint8_t nI,nMax;
|
||||||
|
|
||||||
nMax=bOnce?1:3;
|
nMax=bOnce?1:3;
|
||||||
|
|
|
||||||
|
|
@ -7441,7 +7441,6 @@ void menu_lcd_longpress_func(void)
|
||||||
// Wake up the LCD backlight and,
|
// Wake up the LCD backlight and,
|
||||||
// start LCD inactivity timer
|
// start LCD inactivity timer
|
||||||
lcd_timeoutToStatus.start();
|
lcd_timeoutToStatus.start();
|
||||||
backlight_wake();
|
|
||||||
if (homing_flag || mesh_bed_leveling_flag || menu_menu == lcd_babystep_z || menu_menu == lcd_move_z || menu_block_mask != MENU_BLOCK_NONE || Stopped)
|
if (homing_flag || mesh_bed_leveling_flag || menu_menu == lcd_babystep_z || menu_menu == lcd_move_z || menu_block_mask != MENU_BLOCK_NONE || Stopped)
|
||||||
{
|
{
|
||||||
// disable longpress during re-entry, while homing, calibration or if a serious error
|
// disable longpress during re-entry, while homing, calibration or if a serious error
|
||||||
|
|
@ -7546,7 +7545,6 @@ void menu_lcd_lcdupdate_func(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif//CARDINSERTED
|
#endif//CARDINSERTED
|
||||||
backlight_update();
|
|
||||||
if (lcd_next_update_millis < _millis())
|
if (lcd_next_update_millis < _millis())
|
||||||
{
|
{
|
||||||
if (abs(lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP)
|
if (abs(lcd_encoder_diff) >= ENCODER_PULSES_PER_STEP)
|
||||||
|
|
@ -7557,13 +7555,11 @@ void menu_lcd_lcdupdate_func(void)
|
||||||
Sound_MakeSound(e_SOUND_TYPE_EncoderMove);
|
Sound_MakeSound(e_SOUND_TYPE_EncoderMove);
|
||||||
lcd_encoder_diff = 0;
|
lcd_encoder_diff = 0;
|
||||||
lcd_timeoutToStatus.start();
|
lcd_timeoutToStatus.start();
|
||||||
backlight_wake();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LCD_CLICKED)
|
if (LCD_CLICKED)
|
||||||
{
|
{
|
||||||
lcd_timeoutToStatus.start();
|
lcd_timeoutToStatus.start();
|
||||||
backlight_wake();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(*menu_menu)();
|
(*menu_menu)();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue