added leaved feature
This commit is contained in:
@@ -38,8 +38,10 @@ void MenuInformationSites::right() {
|
||||
}
|
||||
|
||||
void MenuInformationSites::left() {
|
||||
if (this->parentMenu)
|
||||
if (this->parentMenu) {
|
||||
this->parentMenu->printMenu();
|
||||
this->leaved = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuInformationSites::no() {
|
||||
@@ -52,7 +54,14 @@ void MenuInformationSites::yes() {
|
||||
}
|
||||
|
||||
void MenuInformationSites::printMenu() {
|
||||
if (this->leaved) {
|
||||
this->leaved = false;
|
||||
this->lastPageNumber++;
|
||||
this->init();
|
||||
}
|
||||
|
||||
this->printPage();
|
||||
this->lastPageNumber = this->currentPage;
|
||||
}
|
||||
|
||||
void MenuInformationSites::update() {
|
||||
@@ -64,10 +73,12 @@ void MenuInformationSites::update() {
|
||||
}
|
||||
|
||||
bool MenuInformationSites::setCountPages(uint8_t pages) {
|
||||
if (this->countPages < pages)
|
||||
this->countPages = pages;
|
||||
else
|
||||
this->countPages = pages;
|
||||
this->currentPage = 0;
|
||||
if (this->countPages == 0) {
|
||||
this->countPages = 1;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -73,13 +73,18 @@ class MenuInformationSites : public MenuControl {
|
||||
|
||||
virtual void printPage() const = 0;
|
||||
virtual void runCommand() const {}
|
||||
virtual void init() {}
|
||||
|
||||
void printDefault() const;
|
||||
|
||||
uint8_t lastPageNumber = 0;
|
||||
bool leaved = true;
|
||||
|
||||
private:
|
||||
uint8_t countPages;
|
||||
uint8_t currentPage;
|
||||
|
||||
|
||||
const uint16_t delay = 5000;
|
||||
uint32_t lastMillis = 0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user