Compare commits
12
Commits
v1.0
...
f05ab56833
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f05ab56833 | ||
|
|
52c1fe25c8 | ||
|
|
230fa1ba62 | ||
|
|
cbfbad26ae | ||
|
|
79b4cd4018 | ||
|
|
341add1deb | ||
|
|
155fd73c81 | ||
|
|
67315f18b3 | ||
|
|
7de343d08a | ||
|
|
6b57b3fdb4 | ||
|
|
0ab6c829d5 | ||
|
|
db3c25da42 |
+27
-2
@@ -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
|
||||||
|
|||||||
@@ -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;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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
@@ -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":
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user