80 lines
1.7 KiB
C++
80 lines
1.7 KiB
C++
/**
|
|
* @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;
|
|
}
|
|
|
|
void MenuInformationSites::printDefault() const {
|
|
String lineOne = String("Page: ") + (this->currentPage + 1);
|
|
String lineTwo = String("of ") + this->countPages;
|
|
|
|
this->print(lineOne, lineTwo);
|
|
}
|