moved print function to base class
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* @file menuControl.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-12-28
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
|
||||
#include "menuControl.h"
|
||||
|
||||
void MenuControl::print(String lineOne, String lineTwo) const {
|
||||
if (this->lcd) {
|
||||
lcd->clear();
|
||||
lcd->setCursor(0, 0);
|
||||
lcd->printf(lineOne.c_str());
|
||||
lcd->setCursor(0, 1);
|
||||
lcd->printf(lineTwo.c_str());
|
||||
}
|
||||
|
||||
std::cout << lineOne.c_str() << " " << lineTwo.c_str() << std::endl;
|
||||
}
|
||||
@@ -18,7 +18,7 @@
|
||||
/**
|
||||
* @brief Baseclass to build Menus
|
||||
*
|
||||
* This class must be inherited by other classes which want to be
|
||||
* This class have to be inherited by other classes which want to be
|
||||
* act as a menu, because the menu structure uses polymorphism.
|
||||
*
|
||||
*/
|
||||
@@ -69,6 +69,8 @@ class MenuControl {
|
||||
void setLcd(LiquidCrystal_I2C* lcd) { this->lcd = lcd; }
|
||||
|
||||
protected:
|
||||
void print(String lineOne, String lineTwo) const;
|
||||
|
||||
MenuControl* parentMenu = nullptr;
|
||||
LiquidCrystal_I2C* lcd = nullptr;
|
||||
};
|
||||
|
||||
@@ -77,15 +77,3 @@ void MenuInformationSites::printDefault() const {
|
||||
|
||||
this->print(lineOne, lineTwo);
|
||||
}
|
||||
|
||||
void MenuInformationSites::print(String lineOne, String lineTwo) const {
|
||||
if (this->lcd) {
|
||||
lcd->clear();
|
||||
lcd->setCursor(0, 0);
|
||||
lcd->printf(lineOne.c_str());
|
||||
lcd->setCursor(0, 1);
|
||||
lcd->printf(lineTwo.c_str());
|
||||
}
|
||||
|
||||
std::cout << lineOne.c_str() << " " << lineTwo.c_str() << std::endl;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,6 @@ class MenuInformationSites : public MenuControl {
|
||||
virtual void runCommand() const {}
|
||||
|
||||
void printDefault() const;
|
||||
void print(String lineOne, String lineTwo) const;
|
||||
|
||||
private:
|
||||
uint8_t countPages;
|
||||
|
||||
Reference in New Issue
Block a user