mnoved update delay to base class and make
it setAble
This commit is contained in:
+24
-1
@@ -45,7 +45,17 @@ class MenuControl {
|
||||
/**
|
||||
* @brief can be called to update shown data
|
||||
*/
|
||||
virtual void update() {}
|
||||
virtual void update() {
|
||||
if (this->updateDelay == 0)
|
||||
return;
|
||||
|
||||
if (millis() - this->lastUpdateMillis < this->updateDelay) {
|
||||
return;
|
||||
}
|
||||
|
||||
this->printMenu();
|
||||
this->lastMillis = millis();
|
||||
}
|
||||
|
||||
virtual void printMenu() = 0;
|
||||
|
||||
@@ -69,10 +79,23 @@ class MenuControl {
|
||||
*/
|
||||
void setLcd(DisplayWrapper* lcd) { this->lcd = lcd; }
|
||||
|
||||
/**
|
||||
* @brief Set the time between each new print to the display
|
||||
*
|
||||
* If the delay is zero, no updates will be made.
|
||||
* The delay is by default zero.
|
||||
*
|
||||
* @param delay time in milliseconds
|
||||
*/
|
||||
void setUpdateDelay(uint16_t delay = 0) { this->updateDelay = delay; }
|
||||
|
||||
protected:
|
||||
void print(String lineOne, String lineTwo) const;
|
||||
|
||||
MenuControl* parentMenu = nullptr;
|
||||
DisplayWrapper* lcd = nullptr;
|
||||
|
||||
uint16_t updateDelay = 0;
|
||||
uint32_t lastUpdateMillis = 0;
|
||||
};
|
||||
#endif // MENU_CONTROLL_H
|
||||
|
||||
Reference in New Issue
Block a user