diff --git a/src/OLEDUIPlus.cpp b/src/OLEDUIPlus.cpp index 62942d2..60e1e11 100644 --- a/src/OLEDUIPlus.cpp +++ b/src/OLEDUIPlus.cpp @@ -318,4 +318,41 @@ void OLEDUIPlus::setTimeout(uint32_t ms) 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; diff --git a/src/OLEDUIPlus.h b/src/OLEDUIPlus.h index c790b3d..d7c6a63 100644 --- a/src/OLEDUIPlus.h +++ b/src/OLEDUIPlus.h @@ -57,12 +57,17 @@ public: bool menuExpired(void); uint8_t getFrameIndex(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: Interval _timing; // casovac rychlosti periodicke obsluhy (rizeny dle casu, ktery vrati OLEDDisplayUi objekt) uint8_t _frameseq[8]; // historie prechodu jednotlivych obrazovek 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 uint32_t _oledtimeout = 0; // zhasinani OLED Interval _oledTiming; // casovac pro zhasinani OLED