OTA indikace (pokud je aktivovane OTA)

This commit is contained in:
Pavel Brychta 2020-11-25 16:39:50 +01:00
parent 8bf0f6d3c5
commit 9e67bd4591
2 changed files with 43 additions and 1 deletions

View File

@ -318,4 +318,41 @@ void OLEDUIPlus::setTimeout(uint32_t ms)
extendOn(); extendOn();
} }
#if defined(USE_OTA)
void OLEDUIPlus::OTAStart(void)
{
if (_oled) {
if (false == _displayon)
_oled->displayOn();
_oled->clear();
_oled->setFont(ArialMT_Plain_10);
_oled->setTextAlignment(TEXT_ALIGN_CENTER_BOTH);
_oled->drawString(_oled->getWidth() / 2, _oled->getHeight() / 2 - 10, "OTA Update");
_oled->display();
}
}
void OLEDUIPlus::OTAProgress(unsigned int progress, unsigned int total)
{
if (_oled) {
_oled->drawProgressBar(4, 32, 120, 8, progress / (total / 100));
_oled->display();
}
}
void OLEDUIPlus::OTAEnd(void)
{
if (_oled) {
_oled->clear();
_oled->setFont(ArialMT_Plain_10);
_oled->setTextAlignment(TEXT_ALIGN_CENTER_BOTH);
_oled->drawString(_oled->getWidth() / 2, _oled->getHeight() / 2, "Restart");
_oled->display();
}
}
#endif
OLEDUIPlus ui; OLEDUIPlus ui;

View File

@ -57,12 +57,17 @@ public:
bool menuExpired(void); bool menuExpired(void);
uint8_t getFrameIndex(FrameCallback cb); uint8_t getFrameIndex(FrameCallback cb);
void setMainFrame(FrameCallback cb); void setMainFrame(FrameCallback cb);
#if defined(USE_OTA)
void OTAStart(void);
void OTAProgress(unsigned int progress, unsigned int total);
void OTAEnd(void);
#endif
private: private:
Interval _timing; // casovac rychlosti periodicke obsluhy (rizeny dle casu, ktery vrati OLEDDisplayUi objekt) Interval _timing; // casovac rychlosti periodicke obsluhy (rizeny dle casu, ktery vrati OLEDDisplayUi objekt)
uint8_t _frameseq[8]; // historie prechodu jednotlivych obrazovek uint8_t _frameseq[8]; // historie prechodu jednotlivych obrazovek
uint32_t _frameptr = 0; // index ve _frameseq uint32_t _frameptr = 0; // index ve _frameseq
OLEDDisplay* _oled; // ukazatel na displej OLEDDisplay* _oled = nullptr; // ukazatel na displej
uint8_t _oledBrightness = 100; // jas OLED displeje uint8_t _oledBrightness = 100; // jas OLED displeje
uint32_t _oledtimeout = 0; // zhasinani OLED uint32_t _oledtimeout = 0; // zhasinani OLED
Interval _oledTiming; // casovac pro zhasinani OLED Interval _oledTiming; // casovac pro zhasinani OLED