build new class for information with pages
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* @file menuInformationSites.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief Contains an implementation of the class MenuInformationSites
|
||||
* @version 0.1
|
||||
* @date 2022-12-27
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "menuInformationSites.h"
|
||||
|
||||
MenuInformationSites::MenuInformationSites(uint8_t pages) {
|
||||
this->countPages = pages;
|
||||
this->currentPage = 0;
|
||||
this->lastMillis = millis();
|
||||
}
|
||||
|
||||
void MenuInformationSites::up() {
|
||||
if (this->currentPage == 0)
|
||||
this->currentPage = this->countPages - 1;
|
||||
else
|
||||
this->currentPage--;
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuInformationSites::down() {
|
||||
if (this->currentPage == this->countPages - 1)
|
||||
this->currentPage = 0;
|
||||
else
|
||||
this->currentPage++;
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuInformationSites::right() {
|
||||
this->yes();
|
||||
}
|
||||
|
||||
void MenuInformationSites::left() {
|
||||
if (this->parentMenu)
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuInformationSites::no() {
|
||||
this->left();
|
||||
}
|
||||
|
||||
void MenuInformationSites::yes() {
|
||||
this->runCommand();
|
||||
this->printMenu();
|
||||
}
|
||||
|
||||
void MenuInformationSites::printMenu() {
|
||||
this->printPage();
|
||||
}
|
||||
|
||||
void MenuInformationSites::update() {
|
||||
if (millis() - this->lastMillis < this->delay) {
|
||||
return;
|
||||
}
|
||||
this->printMenu();
|
||||
this->lastMillis = millis();
|
||||
}
|
||||
|
||||
uint8_t MenuInformationSites::getCountPages() const {
|
||||
return this->countPages;
|
||||
}
|
||||
|
||||
uint8_t MenuInformationSites::getCurrentPage() const {
|
||||
return this->currentPage;
|
||||
}
|
||||
Reference in New Issue
Block a user