Moznost callbacku pri zapnuti a vypnuti OLED displeje

This commit is contained in:
Pavel Brychta 2020-12-15 14:31:25 +01:00
parent 19782d2af5
commit a2011cacf8
2 changed files with 25 additions and 2 deletions

View File

@ -21,6 +21,8 @@ typedef struct {
static crt_anim_t _anim;
static bool _displayon = false; // priznak, ze na OLED je videt zobrazeni (neni ve stavu spanku)
static oledon _oledon = nullptr;
static oledoff _oledoff = nullptr;
void OLEDUIPlus::goToFrame(uint8_t frame)
{
@ -122,6 +124,8 @@ void onOffOverlay(OLEDDisplay *display, OLEDDisplayUiState *state)
if (_anim.lineClosing && _anim.closing) {
_anim.active = false;
display->displayOff();
if (_oledoff != nullptr)
_oledoff();
_displayon = false;
}
@ -278,6 +282,8 @@ int OLEDUIPlus::extendOn(void)
if (0 != _oledtimeout) {
_oledTiming.setOneshot(_oledtimeout); // prodlouzime delku svitu OLED
if (false == _displayon) {
if (_oledon != nullptr)
_oledon();
startAnim(1);
retval = 1; // musime rozsvitit displej
}
@ -347,7 +353,7 @@ void OLEDUIPlus::OTAProgress(unsigned int progress, unsigned int total)
if (_oled) {
_oled->drawProgressBar(4, 32, 120, 8, progress / (total / 100));
_oled->display();
_oled->display();
}
}
@ -359,9 +365,21 @@ void OLEDUIPlus::OTAEnd(void)
_oled->setFont(ArialMT_Plain_10);
_oled->setTextAlignment(TEXT_ALIGN_CENTER_BOTH);
_oled->drawString(_oled->getWidth() / 2, _oled->getHeight() / 2, "Restart");
_oled->display();
_oled->display();
}
}
#endif
void OLEDUIPlus::setOffCb(oledoff oloff)
{
_oledoff = oloff;
}
void OLEDUIPlus::setOnCb(oledon olon)
{
_oledon = olon;
}
OLEDUIPlus ui;

View File

@ -24,6 +24,8 @@ typedef void (*de)(OLEDDisplay *display, int16_t x, int16_t y, void *ptr); // dr
typedef int (*ee)(void *ptr);
typedef void (*ce)(void);
typedef bool (*ve)(void *ptr);
typedef void (*oledon)(void); // informace o tom, ze je treba zapnout OLED displej
typedef void (*oledoff)(void); // informace o tom, ze zhasiname OLED displej
typedef struct {
const char *entryText; // staticky text, vypisovany v polozce menu
@ -58,6 +60,9 @@ public:
uint8_t getFrameIndex(FrameCallback cb);
void setMainFrame(FrameCallback cb);
bool isVisible(void);
void setOffCb(oledoff oloff);
void setOnCb(oledon olon);
#if defined(USE_OTA)
void OTAStart(void);
void OTAProgress(unsigned int progress, unsigned int total);