diff --git a/doc/Notes and TODOs/TODO allgemein.txt b/doc/Notes and TODOs/TODO allgemein.txt index 1f60c09..5c8fa8a 100644 --- a/doc/Notes and TODOs/TODO allgemein.txt +++ b/doc/Notes and TODOs/TODO allgemein.txt @@ -3,8 +3,3 @@ -> Program battery pack tracking -> Add an 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 - diff --git a/lib/Menu/menu.cpp b/lib/Menu/menu.cpp index 2f173e5..afd2c7e 100644 --- a/lib/Menu/menu.cpp +++ b/lib/Menu/menu.cpp @@ -31,26 +31,18 @@ bool Menu::isInSubmenu() { } void Menu::printMenu() { - if (this->lcd) { - lcd->clear(); - lcd->setCursor(0, 0); - lcd->print("-> "); - lcd->print((**this->selectedEntry).getName()); - lcd->setCursor(0, 1); - std::list::iterator iter = this->selectedEntry; - iter++; - if (iter != this->entrys.end()) { - lcd->print((**iter).getName()); - } else - lcd->print((*this->entrys.begin())->getName()); - } - std::cout << std::endl; - for (std::list::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; - } + std::list::iterator iter = this->selectedEntry; + + String lineOne = "-> "; + String lineTwo = ""; + + lineOne.concat((**iter).getName()); + iter++; + if (iter != this->entrys.end()) { + lineTwo.concat((**iter).getName()); + } else + lineTwo.concat((*this->entrys.begin())->getName()); + this->inSubmenu = false; } diff --git a/lib/Menu/menuIntInput.cpp b/lib/Menu/menuIntInput.cpp index 2769f93..3f8675b 100644 --- a/lib/Menu/menuIntInput.cpp +++ b/lib/Menu/menuIntInput.cpp @@ -196,16 +196,16 @@ void MenuIntInput::printMenu() { if (this->currentPosition == 0 && this->length == 1) { // 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) { // 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) { // Right arrow only - sprintf(bufferName, " %s >", this->names + 12 * this->currentPosition); + sprintf(bufferName, " %s >", this->names + MAX_NAME_LENGTH * this->currentPosition); } else { // Both arrow - sprintf(bufferName, "< %s >", this->names + 12 * this->currentPosition); + sprintf(bufferName, "< %s >", this->names + MAX_NAME_LENGTH * this->currentPosition); } char bufferValue[17]; @@ -214,12 +214,5 @@ void MenuIntInput::printMenu() { else sprintf(bufferValue, " -> 0"); - if (this->lcd) { - lcd->clear(); - lcd->setCursor(0, 0); - lcd->print(bufferName); - lcd->setCursor(0, 1); - lcd->print(bufferValue); - } - std::cout << bufferName << " : " << bufferValue << std::endl; + this->print(bufferName, bufferValue); } diff --git a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp index 963078a..30dc119 100644 --- a/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp +++ b/src/SpecialMenus/driveModi/Autopilot/menuAutopilot.cpp @@ -60,15 +60,7 @@ void MenuAutopilot::printMenu() { } } - if (this->lcd) { - 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; + this->print(buf1, buf2); } void MenuAutopilot::update() { diff --git a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp index a5c0b4d..35c39b8 100644 --- a/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp +++ b/src/SpecialMenus/driveModi/CaptureRoute/menuCaptureRoute.cpp @@ -16,15 +16,10 @@ void MenuCaptureRoute::printMenu() { this->routeInfo = this->captureRoute->getRouteInfo(); - if (this->lcd) { - this->lcd->clear(); - this->lcd->setCursor(0, 0); - this->lcd->printf("Points: %u", this->routeInfo.totalPoints); - this->lcd->setCursor(0, 1); - this->lcd->print("du fahren. :-)"); + String lineOne = "Points: "; + String lineTwo = "You can drive."; - } - std::cout << "Points: " << this->routeInfo.totalPoints << " du fahren. :-)" << std::endl; + lineTwo.concat(this->routeInfo.totalPoints); } void MenuCaptureRoute::update() { diff --git a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp index b393946..860c1d7 100644 --- a/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp +++ b/src/SpecialMenus/driveModi/ManualDrive/menuManualDrive.cpp @@ -11,14 +11,5 @@ #include "menuManualDrive.h" void MenuManualControl::printMenu() { - this->driveManager->changeModus(Modi::ManualControl); - 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; + this->print("Now you can", "drive. :)"); } diff --git a/src/SpecialMenus/driveModi/menuDriveMode.h b/src/SpecialMenus/driveModi/menuDriveMode.h index 6bc4a64..911e738 100644 --- a/src/SpecialMenus/driveModi/menuDriveMode.h +++ b/src/SpecialMenus/driveModi/menuDriveMode.h @@ -36,11 +36,6 @@ class MenuDriveMode : public MenuControl { virtual void printMenu() = 0; - /** - * @brief can be called to update shown data - */ - void update(){} - protected: DriveManager* driveManager; bool firstPrint = true;