Add some display safeguards fixing power issues at restart

This commit is contained in:
Theo Arends 2023-02-05 12:52:21 +01:00
parent 36b9e4ab78
commit 9bf1bd93c0
2 changed files with 15 additions and 9 deletions

View File

@ -237,7 +237,7 @@ uint16_t dsp_rad;
uint16_t dsp_color; uint16_t dsp_color;
int16_t dsp_len; int16_t dsp_len;
uint8_t disp_power = 0; int8_t disp_power = -1;
uint8_t disp_device = 0; uint8_t disp_device = 0;
uint8_t disp_refresh = 1; uint8_t disp_refresh = 1;
uint8_t disp_autodraw = 1; uint8_t disp_autodraw = 1;
@ -293,9 +293,10 @@ void DisplayDrawStringAt(uint16_t x, uint16_t y, char *str, uint16_t color, uint
XdspCall(FUNC_DISPLAY_DRAW_STRING); XdspCall(FUNC_DISPLAY_DRAW_STRING);
} }
void DisplayOnOff(uint8_t on) void DisplayOnOff(uint8_t on) {
{ if (disp_device) {
ExecuteCommandPower(disp_device, on, SRC_DISPLAY); ExecuteCommandPower(disp_device, on, SRC_DISPLAY);
}
} }
/*-------------------------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------------------------*/
@ -1838,8 +1839,10 @@ void DisplayLocalSensor(void)
* Public * Public
\*********************************************************************************************/ \*********************************************************************************************/
void DisplayInitDriver(void) void DisplayInitDriver(void) {
{
XdspCall(FUNC_DISPLAY_INIT_DRIVER); XdspCall(FUNC_DISPLAY_INIT_DRIVER);
// AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings->display_model); // AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "Display model %d"), Settings->display_model);
@ -1890,8 +1893,9 @@ void DisplayInitDriver(void)
} }
} }
void DisplaySetPower(void) void DisplaySetPower(void) {
{ if (!disp_device) { return; } // Not initialized yet
disp_power = bitRead(XdrvMailbox.index, disp_device -1); disp_power = bitRead(XdrvMailbox.index, disp_device -1);
//AddLog(LOG_LEVEL_DEBUG, PSTR("DSP: Power %d"), disp_power); //AddLog(LOG_LEVEL_DEBUG, PSTR("DSP: Power %d"), disp_power);
@ -1995,6 +1999,8 @@ void CmndDisplayMode(void) {
// Apply the current display dimmer // Apply the current display dimmer
void ApplyDisplayDimmer(void) { void ApplyDisplayDimmer(void) {
if ((disp_power < 0) || !disp_device) { return; } // Not initialized yet
uint8_t dimmer8 = changeUIntScale(GetDisplayDimmer(), 0, 100, 0, 255); uint8_t dimmer8 = changeUIntScale(GetDisplayDimmer(), 0, 100, 0, 255);
uint16_t dimmer10_gamma = ledGamma10(dimmer8); uint16_t dimmer10_gamma = ledGamma10(dimmer8);
if (dimmer8 && !(disp_power)) { if (dimmer8 && !(disp_power)) {

View File

@ -436,7 +436,7 @@ int8_t cs;
Settings->display_width = renderer->width(); Settings->display_width = renderer->width();
Settings->display_height = renderer->height(); Settings->display_height = renderer->height();
// ApplyDisplayDimmer(); // Not allowed here. Way too early in initi sequence. IE power state has not even been set at this point in time ApplyDisplayDimmer();
#ifdef SHOW_SPLASH #ifdef SHOW_SPLASH
if (!Settings->flag5.display_no_splash) { if (!Settings->flag5.display_no_splash) {