Update all Menus to new Print function

This commit is contained in:
2023-01-04 10:35:49 +01:00
parent 04109d82e6
commit 1147cb4eb6
7 changed files with 22 additions and 69 deletions
-5
View File
@@ -3,8 +3,3 @@
-> Program battery pack tracking -> Program battery pack tracking
-> Add an beeper -> Add an beeper
-> Program the beeper -> Program the beeper
-> Update all Menus to new Print function
-> use int input menu for pid menu
-> capture Route new route if reenter
-> route export and import
+12 -20
View File
@@ -31,26 +31,18 @@ bool Menu::isInSubmenu() {
} }
void Menu::printMenu() { void Menu::printMenu() {
if (this->lcd) { std::list<MenuAction*>::iterator iter = this->selectedEntry;
lcd->clear();
lcd->setCursor(0, 0); String lineOne = "-> ";
lcd->print("-> "); String lineTwo = "";
lcd->print((**this->selectedEntry).getName());
lcd->setCursor(0, 1); lineOne.concat((**iter).getName());
std::list<MenuAction*>::iterator iter = this->selectedEntry; iter++;
iter++; if (iter != this->entrys.end()) {
if (iter != this->entrys.end()) { lineTwo.concat((**iter).getName());
lcd->print((**iter).getName()); } else
} else lineTwo.concat((*this->entrys.begin())->getName());
lcd->print((*this->entrys.begin())->getName());
}
std::cout << std::endl;
for (std::list<MenuAction*>::iterator iter = this->entrys.begin(); iter != this->entrys.end(); iter++) {
if (this->selectedEntry == iter)
std::cout << " " << (**iter).getName() << std::endl;
else
std::cout << (**iter).getName() << std::endl;
}
this->inSubmenu = false; this->inSubmenu = false;
} }
+5 -12
View File
@@ -196,16 +196,16 @@ void MenuIntInput::printMenu() {
if (this->currentPosition == 0 && this->length == 1) { if (this->currentPosition == 0 && this->length == 1) {
// No arrow // No arrow
sprintf(bufferName, " %s ", this->names + 12 * this->currentPosition); sprintf(bufferName, " %s ", this->names + MAX_NAME_LENGTH * this->currentPosition);
} else if (this->currentPosition > 0 && this->length - 1 == this->currentPosition) { } else if (this->currentPosition > 0 && this->length - 1 == this->currentPosition) {
// Left arrow only // Left arrow only
sprintf(bufferName, "< %s ", this->names + 12 * this->currentPosition); sprintf(bufferName, "< %s ", this->names + MAX_NAME_LENGTH * this->currentPosition);
} else if (this->currentPosition == 0 && this->length > 1) { } else if (this->currentPosition == 0 && this->length > 1) {
// Right arrow only // Right arrow only
sprintf(bufferName, " %s >", this->names + 12 * this->currentPosition); sprintf(bufferName, " %s >", this->names + MAX_NAME_LENGTH * this->currentPosition);
} else { } else {
// Both arrow // Both arrow
sprintf(bufferName, "< %s >", this->names + 12 * this->currentPosition); sprintf(bufferName, "< %s >", this->names + MAX_NAME_LENGTH * this->currentPosition);
} }
char bufferValue[17]; char bufferValue[17];
@@ -214,12 +214,5 @@ void MenuIntInput::printMenu() {
else else
sprintf(bufferValue, " -> 0"); sprintf(bufferValue, " -> 0");
if (this->lcd) { this->print(bufferName, bufferValue);
lcd->clear();
lcd->setCursor(0, 0);
lcd->print(bufferName);
lcd->setCursor(0, 1);
lcd->print(bufferValue);
}
std::cout << bufferName << " : " << bufferValue << std::endl;
} }
@@ -60,15 +60,7 @@ void MenuAutopilot::printMenu() {
} }
} }
if (this->lcd) { this->print(buf1, buf2);
this->lcd->clear();
this->lcd->setCursor(0, 0);
this->lcd->print(buf1);
this->lcd->setCursor(0, 1);
this->lcd->print(buf2);
}
std::cout << buf1 << " " << buf2 << std::endl;
} }
void MenuAutopilot::update() { void MenuAutopilot::update() {
@@ -16,15 +16,10 @@ void MenuCaptureRoute::printMenu() {
this->routeInfo = this->captureRoute->getRouteInfo(); this->routeInfo = this->captureRoute->getRouteInfo();
if (this->lcd) { String lineOne = "Points: ";
this->lcd->clear(); String lineTwo = "You can drive.";
this->lcd->setCursor(0, 0);
this->lcd->printf("Points: %u", this->routeInfo.totalPoints);
this->lcd->setCursor(0, 1);
this->lcd->print("du fahren. :-)");
} lineTwo.concat(this->routeInfo.totalPoints);
std::cout << "Points: " << this->routeInfo.totalPoints << " du fahren. :-)" << std::endl;
} }
void MenuCaptureRoute::update() { void MenuCaptureRoute::update() {
@@ -11,14 +11,5 @@
#include "menuManualDrive.h" #include "menuManualDrive.h"
void MenuManualControl::printMenu() { void MenuManualControl::printMenu() {
this->driveManager->changeModus(Modi::ManualControl); this->print("Now you can", "drive. :)");
if (this->lcd) {
this->lcd->clear();
this->lcd->setCursor(0, 0);
this->lcd->print("Jetzt kannst");
this->lcd->setCursor(0, 1);
this->lcd->print("du fahren. :-)");
}
std::cout << "Jetzt kannst du\n fahren. :-)" << std::endl;
} }
@@ -36,11 +36,6 @@ class MenuDriveMode : public MenuControl {
virtual void printMenu() = 0; virtual void printMenu() = 0;
/**
* @brief can be called to update shown data
*/
void update(){}
protected: protected:
DriveManager* driveManager; DriveManager* driveManager;
bool firstPrint = true; bool firstPrint = true;