Compare commits

..
12 Commits
Author SHA1 Message Date
kleiax f05ab56833 call prepareReenter in SpecialMenus 2023-09-27 15:27:44 +02:00
kleiax 52c1fe25c8 add function for prepare rentering a menu 2023-09-27 15:19:32 +02:00
kleiax 230fa1ba62 remove const for runCommand 2023-09-27 13:39:28 +02:00
kleiax cbfbad26ae move the bool for skip from private to protected 2023-09-23 22:13:24 +02:00
kleiax 79b4cd4018 possibility to skip no and do left 2023-09-23 22:03:14 +02:00
kleiax 341add1deb remove multiple definition of function declarition 2023-08-18 16:30:31 +02:00
kleiax 155fd73c81 fix syntax 2023-08-18 16:28:16 +02:00
kleiax 67315f18b3 menuinformation site - add second action
inherit lcd Wrapper
2023-08-18 15:59:00 +02:00
kleiax 7de343d08a Update MenuInfornationSites printDefault() 2023-05-11 12:59:11 +02:00
kleiax 6b57b3fdb4 fix wrong variable name 2023-04-26 08:11:45 +02:00
kleiax 0ab6c829d5 removed old update functions 2023-04-26 07:57:00 +02:00
kleiax db3c25da42 mnoved update delay to base class and make
it setAble
2023-04-26 07:54:57 +02:00
7 changed files with 53 additions and 25 deletions
+27 -2
View File
@@ -45,8 +45,19 @@ class MenuControl {
/** /**
* @brief can be called to update shown data * @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->lastUpdateMillis = millis();
}
virtual void prepareReenterMenu() {}
virtual void printMenu() = 0; virtual void printMenu() = 0;
/** /**
@@ -57,7 +68,7 @@ class MenuControl {
* *
* @param menu * @param menu
*/ */
void setParentMenu(MenuControl* menu) { this->parentMenu = menu; } void setParentMenu(MenuControl* menu);
// MenuControl* getParentMenu() { return this->parentMenu; } // MenuControl* getParentMenu() { return this->parentMenu; }
/** /**
@@ -69,10 +80,24 @@ class MenuControl {
*/ */
void setLcd(DisplayWrapper* lcd) { this->lcd = lcd; } 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: protected:
void print(String lineOne, String lineTwo) const; void print(String lineOne, String lineTwo) const;
DisplayWrapper* getLcd() const { return this->lcd; }
MenuControl* parentMenu = nullptr; MenuControl* parentMenu = nullptr;
DisplayWrapper* lcd = nullptr; DisplayWrapper* lcd = nullptr;
uint16_t updateDelay = 0;
uint32_t lastUpdateMillis = 0;
}; };
#endif // MENU_CONTROLL_H #endif // MENU_CONTROLL_H
+3 -7
View File
@@ -61,30 +61,26 @@ class MenuInformationSites : public MenuControl {
*/ */
void printMenu() override; void printMenu() override;
/**
* @brief can be called to update shown data
*/
void update() override;
protected: protected:
bool setCountPages(uint8_t pages); bool setCountPages(uint8_t pages);
uint8_t getCountPages() const; uint8_t getCountPages() const;
uint8_t getCurrentPage() const; uint8_t getCurrentPage() const;
virtual void printPage() const = 0; virtual void printPage() const = 0;
virtual void runCommand() const {} virtual void runCommandNo() {}
virtual void runCommand() {}
virtual void init() {} virtual void init() {}
void printDefault() const; void printDefault() const;
uint8_t lastPageNumber = 0; uint8_t lastPageNumber = 0;
bool leaved = true; bool leaved = true;
bool noEqualLeft = false;
private: private:
uint8_t countPages; uint8_t countPages;
uint8_t currentPage; uint8_t currentPage;
const uint16_t delay = 5000; const uint16_t delay = 5000;
uint32_t lastMillis = 0; uint32_t lastMillis = 0;
}; };
-2
View File
@@ -81,8 +81,6 @@ class MenuIntInput : public MenuControl {
*/ */
void printMenu() override; void printMenu() override;
void update() override {};
private: private:
MenuIntInputWrapper* wrapper; MenuIntInputWrapper* wrapper;
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "Menu", "name": "Menu",
"version": "1.0.1", "version": "1.1.2",
"description": "Build page based menus on uCs", "description": "Build page based menus on uCs",
"keywords": "menu, page, input", "keywords": "menu, page, input",
"repository": "repository":
+7
View File
@@ -20,3 +20,10 @@ void MenuControl::print(String lineOne, String lineTwo) const {
lcd->print(lineTwo.c_str()); lcd->print(lineTwo.c_str());
} }
} }
void MenuControl::setParentMenu(MenuControl* menu) {
this->parentMenu = menu;
DisplayWrapper* lcd = this->parentMenu->getLcd();
if (lcd)
this->lcd = lcd;
}
+8 -10
View File
@@ -39,13 +39,19 @@ void MenuInformationSites::right() {
void MenuInformationSites::left() { void MenuInformationSites::left() {
if (this->parentMenu) { if (this->parentMenu) {
this->parentMenu->prepareReenterMenu();
this->parentMenu->printMenu(); this->parentMenu->printMenu();
this->leaved = true; this->leaved = true;
} }
} }
void MenuInformationSites::no() { void MenuInformationSites::no() {
if (this->noEqualLeft) {
this->left(); this->left();
return;
}
this->runCommandNo();
this->printMenu();
} }
void MenuInformationSites::yes() { void MenuInformationSites::yes() {
@@ -64,14 +70,6 @@ void MenuInformationSites::printMenu() {
this->lastPageNumber = this->currentPage; this->lastPageNumber = this->currentPage;
} }
void MenuInformationSites::update() {
if (millis() - this->lastMillis < this->delay) {
return;
}
this->printMenu();
this->lastMillis = millis();
}
bool MenuInformationSites::setCountPages(uint8_t pages) { bool MenuInformationSites::setCountPages(uint8_t pages) {
this->countPages = pages; this->countPages = pages;
this->currentPage = 0; this->currentPage = 0;
@@ -91,8 +89,8 @@ uint8_t MenuInformationSites::getCurrentPage() const {
} }
void MenuInformationSites::printDefault() const { void MenuInformationSites::printDefault() const {
String lineOne = String("Page: ") + (this->currentPage + 1); String lineOne = String("Pagenumber: ") + (this->currentPage + 1);
String lineTwo = String("of ") + this->countPages; String lineTwo = String("Pagecount : ") + this->countPages;
this->print(lineOne, lineTwo); this->print(lineOne, lineTwo);
} }
+6 -2
View File
@@ -181,14 +181,18 @@ void MenuIntInput::no() {
this->values[i] = this->originalValues[i]; this->values[i] = this->originalValues[i];
this->currentPosition = 0; this->currentPosition = 0;
if (this->parentMenu) if (this->parentMenu) {
this->parentMenu->prepareReenterMenu();
this->parentMenu->printMenu(); this->parentMenu->printMenu();
}
} }
void MenuIntInput::yes() { void MenuIntInput::yes() {
this->wrapper->action(this->values, this->length); this->wrapper->action(this->values, this->length);
if (this->parentMenu && printParentMenu) if (this->parentMenu && printParentMenu){
this->parentMenu->prepareReenterMenu();
this->parentMenu->printMenu(); this->parentMenu->printMenu();
}
} }
void MenuIntInput::printMenu() { void MenuIntInput::printMenu() {