moved print function to base class

This commit is contained in:
2022-12-28 10:20:48 +01:00
parent c9ddadc15b
commit 9d5cc92a80
4 changed files with 27 additions and 14 deletions
+24
View File
@@ -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;
}
+3 -1
View File
@@ -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;
};
-12
View File
@@ -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;
}
-1
View File
@@ -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;