Feature: Turn off Display before reboot
Thanks for the idea to @StefanOberhumer This prevents always on Display if the device profile does not contain Display pins anymore after the reboot
This commit is contained in:
parent
c91bd42a77
commit
701c490654
@ -19,6 +19,7 @@ public:
|
|||||||
void init(DisplayType_t type, uint8_t data, uint8_t clk, uint8_t cs, uint8_t reset);
|
void init(DisplayType_t type, uint8_t data, uint8_t clk, uint8_t cs, uint8_t reset);
|
||||||
void loop();
|
void loop();
|
||||||
void setContrast(uint8_t contrast);
|
void setContrast(uint8_t contrast);
|
||||||
|
void setStatus(bool turnOn);
|
||||||
void setOrientation(uint8_t rotation = DISPLAY_ROTATION);
|
void setOrientation(uint8_t rotation = DISPLAY_ROTATION);
|
||||||
void setLanguage(uint8_t language);
|
void setLanguage(uint8_t language);
|
||||||
void setStartupDisplay();
|
void setStartupDisplay();
|
||||||
@ -33,6 +34,8 @@ private:
|
|||||||
|
|
||||||
U8G2* _display;
|
U8G2* _display;
|
||||||
|
|
||||||
|
bool _displayTurnedOn;
|
||||||
|
|
||||||
DisplayType_t _display_type = DisplayType_t::None;
|
DisplayType_t _display_type = DisplayType_t::None;
|
||||||
uint8_t _display_language = DISPLAY_LANGUAGE;
|
uint8_t _display_language = DISPLAY_LANGUAGE;
|
||||||
uint8_t _mExtra;
|
uint8_t _mExtra;
|
||||||
|
|||||||
@ -47,6 +47,7 @@ void DisplayGraphicClass::init(DisplayType_t type, uint8_t data, uint8_t clk, ui
|
|||||||
_display = constructor(reset, clk, data, cs);
|
_display = constructor(reset, clk, data, cs);
|
||||||
_display->begin();
|
_display->begin();
|
||||||
setContrast(DISPLAY_CONTRAST);
|
setContrast(DISPLAY_CONTRAST);
|
||||||
|
setStatus(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,10 +140,11 @@ void DisplayGraphicClass::loop()
|
|||||||
if ((millis() - _lastDisplayUpdate) > _period) {
|
if ((millis() - _lastDisplayUpdate) > _period) {
|
||||||
|
|
||||||
_display->clearBuffer();
|
_display->clearBuffer();
|
||||||
|
bool displayPowerSave = false;
|
||||||
|
|
||||||
//=====> Actual Production ==========
|
//=====> Actual Production ==========
|
||||||
if (Datastore.getIsAtLeastOneReachable()) {
|
if (Datastore.getIsAtLeastOneReachable()) {
|
||||||
_display->setPowerSave(false);
|
displayPowerSave = false;
|
||||||
if (Datastore.getTotalAcPowerEnabled() > 999) {
|
if (Datastore.getTotalAcPowerEnabled() > 999) {
|
||||||
snprintf(_fmtText, sizeof(_fmtText), i18n_current_power_kw[_display_language], (Datastore.getTotalAcPowerEnabled() / 1000));
|
snprintf(_fmtText, sizeof(_fmtText), i18n_current_power_kw[_display_language], (Datastore.getTotalAcPowerEnabled() / 1000));
|
||||||
} else {
|
} else {
|
||||||
@ -158,7 +160,7 @@ void DisplayGraphicClass::loop()
|
|||||||
printText(i18n_offline[_display_language], 0);
|
printText(i18n_offline[_display_language], 0);
|
||||||
// check if it's time to enter power saving mode
|
// check if it's time to enter power saving mode
|
||||||
if (millis() - _previousMillis >= (_interval * 2)) {
|
if (millis() - _previousMillis >= (_interval * 2)) {
|
||||||
_display->setPowerSave(enablePowerSafe);
|
displayPowerSave = enablePowerSafe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//<=======================
|
//<=======================
|
||||||
@ -184,6 +186,12 @@ void DisplayGraphicClass::loop()
|
|||||||
|
|
||||||
_mExtra++;
|
_mExtra++;
|
||||||
_lastDisplayUpdate = millis();
|
_lastDisplayUpdate = millis();
|
||||||
|
|
||||||
|
if (!_displayTurnedOn) {
|
||||||
|
displayPowerSave = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_display->setPowerSave(displayPowerSave);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,4 +203,9 @@ void DisplayGraphicClass::setContrast(uint8_t contrast)
|
|||||||
_display->setContrast(contrast * 2.55f);
|
_display->setContrast(contrast * 2.55f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DisplayGraphicClass::setStatus(bool turnOn)
|
||||||
|
{
|
||||||
|
_displayTurnedOn = turnOn;
|
||||||
|
}
|
||||||
|
|
||||||
DisplayGraphicClass Display;
|
DisplayGraphicClass Display;
|
||||||
@ -3,6 +3,7 @@
|
|||||||
* Copyright (C) 2022 - 2023 Thomas Basler and others
|
* Copyright (C) 2022 - 2023 Thomas Basler and others
|
||||||
*/
|
*/
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "Display_Graphic.h"
|
||||||
#include "Led_Single.h"
|
#include "Led_Single.h"
|
||||||
#include <Esp.h>
|
#include <Esp.h>
|
||||||
|
|
||||||
@ -58,6 +59,7 @@ int Utils::getTimezoneOffset()
|
|||||||
void Utils::restartDtu()
|
void Utils::restartDtu()
|
||||||
{
|
{
|
||||||
LedSingle.turnAllOff();
|
LedSingle.turnAllOff();
|
||||||
|
Display.setStatus(false);
|
||||||
yield();
|
yield();
|
||||||
delay(1000);
|
delay(1000);
|
||||||
yield();
|
yield();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user