new ntrip client
This commit is contained in:
@@ -13,13 +13,11 @@
|
||||
MenuTestMode::MenuTestMode(DriveManager* driveManager)
|
||||
: MenuDriveMode(driveManager) {
|
||||
// this->testMode = testMode;
|
||||
this->values[0] = 1;
|
||||
this->values[1] = 2;
|
||||
this->values[2] = 3;
|
||||
// this->values[0] = 0;
|
||||
// this->values[1] = 0;
|
||||
|
||||
strcpy(this->names[0], "Alpha");
|
||||
strcpy(this->names[1], "Beta");
|
||||
strcpy(this->names[2], "Gamma");
|
||||
// strcpy(this->names[0], "Centimeter");
|
||||
// strcpy(this->names[1], "Degree");
|
||||
}
|
||||
|
||||
MenuTestMode::~MenuTestMode() {
|
||||
@@ -68,6 +66,7 @@ void MenuTestMode::no() {
|
||||
}
|
||||
|
||||
void MenuTestMode::init() {
|
||||
this->driveManager->changeModus(Modi::TestMode);
|
||||
this->testMode = (TestMode*) this->driveManager->getDriveModiPtr();
|
||||
|
||||
auto dummy = []() {
|
||||
@@ -77,40 +76,49 @@ void MenuTestMode::init() {
|
||||
// Create menu
|
||||
this->mainMenu = new Menu;
|
||||
Menu* engineMenu = new Menu;
|
||||
Menu* engineLeftMenu = new Menu;
|
||||
Menu* engineRightMenu = new Menu;
|
||||
Menu* drivingMenu = new Menu;
|
||||
Menu* drivingForwardMenu = new Menu;
|
||||
Menu* drivingBackwardMenu = new Menu;
|
||||
Menu* lightMenu = new Menu;
|
||||
|
||||
MenuIntInput* testInputMenu = new MenuIntInput(values, (char *)names, length, new MenuTestModeWrapper(this->testMode));
|
||||
MenuIntInput* drivingMenu = new MenuIntInput(2, new MenuTestModeWrapper(this->testMode, &TestMode::drive));
|
||||
MenuIntInput* engineLeftMenu = new MenuIntInput(2, new MenuTestModeWrapper(this->testMode, &TestMode::leftEngine));
|
||||
MenuIntInput* engineRightMenu = new MenuIntInput(2, new MenuTestModeWrapper(this->testMode, &TestMode::rightEngine));
|
||||
MenuIntInput* engineBothMenu = new MenuIntInput(2, new MenuTestModeWrapper(this->testMode, &TestMode::bothEngine));
|
||||
|
||||
|
||||
// Set menus on LCD
|
||||
this->mainMenu->setLcd(this->lcd);
|
||||
engineMenu->setLcd(this->lcd);
|
||||
engineLeftMenu->setLcd(this->lcd);
|
||||
engineRightMenu->setLcd(this->lcd);
|
||||
engineBothMenu->setLcd(this->lcd);
|
||||
drivingMenu->setLcd(this->lcd);
|
||||
drivingForwardMenu->setLcd(this->lcd);
|
||||
drivingBackwardMenu->setLcd(this->lcd);
|
||||
lightMenu->setLcd(this->lcd);
|
||||
testInputMenu->setLcd(this->lcd);
|
||||
|
||||
// Other menu config
|
||||
drivingMenu->setEntry(0, "Centimeter", 100);
|
||||
drivingMenu->setMinMaxSteps(0, -1000, 1000, 25);
|
||||
drivingMenu->setEntry(1, "Degree");
|
||||
drivingMenu->setMinMaxSteps(1, -360, 360, 15);
|
||||
engineLeftMenu->setEntry(0, "Percentage");
|
||||
engineLeftMenu->setMinMaxSteps(0, -100, 100, 5);
|
||||
engineLeftMenu->setEntry(1, "Seconds", 10);
|
||||
engineLeftMenu->setMinMaxSteps(1, 0, 120, 1);
|
||||
engineRightMenu->setEntry(0, "Percentage");
|
||||
engineRightMenu->setMinMaxSteps(0, -100, 100, 5);
|
||||
engineRightMenu->setEntry(1, "Seconds", 10);
|
||||
engineRightMenu->setMinMaxSteps(1, 0, 120, 1);
|
||||
engineBothMenu->setEntry(0, "Percentage");
|
||||
engineBothMenu->setMinMaxSteps(0, -100, 100, 5);
|
||||
engineBothMenu->setEntry(1, "Seconds", 10);
|
||||
engineBothMenu->setMinMaxSteps(1, 0, 120, 1);
|
||||
|
||||
|
||||
// Entrys for the menus
|
||||
MenuAction* engineAction = new MenuAction("Engine", engineMenu);
|
||||
MenuAction* engineLeftAction = new MenuAction("Left", engineLeftMenu);
|
||||
MenuAction* engineRightAction = new MenuAction("Right", engineRightMenu);
|
||||
MenuAction* engineBothAction = new MenuAction("Both", engineBothMenu);
|
||||
|
||||
MenuAction* drivingAction = new MenuAction("Driving", drivingMenu);
|
||||
MenuAction* drivingForwardAction = new MenuAction("Forward", drivingForwardMenu);
|
||||
MenuAction* drivingForwardLeftAction = new MenuAction("Left", testInputMenu);
|
||||
MenuAction* drivingForwardStraightAction = new MenuAction("Straight", dummy);
|
||||
MenuAction* drivingForwardRightAction = new MenuAction("Right", dummy);
|
||||
MenuAction* drivingBackwardAction = new MenuAction("Backward", drivingBackwardMenu);
|
||||
MenuAction* drivingBackwardLeftAction = new MenuAction("Left", dummy);
|
||||
MenuAction* drivingBackwardStraightAction = new MenuAction("Straight", dummy);
|
||||
MenuAction* drivingBackwardRightAction = new MenuAction("Right", dummy);
|
||||
|
||||
MenuAction* lightAction = new MenuAction("Light", lightMenu);
|
||||
MenuAction* lightFlashAction = new MenuAction("Flash", dummy);
|
||||
@@ -127,15 +135,7 @@ void MenuTestMode::init() {
|
||||
|
||||
engineMenu->addEntry(engineLeftAction);
|
||||
engineMenu->addEntry(engineRightAction);
|
||||
|
||||
drivingMenu->addEntry(drivingForwardAction);
|
||||
drivingMenu->addEntry(drivingBackwardAction);
|
||||
drivingForwardMenu->addEntry(drivingForwardLeftAction);
|
||||
drivingForwardMenu->addEntry(drivingForwardStraightAction);
|
||||
drivingForwardMenu->addEntry(drivingForwardRightAction);
|
||||
drivingBackwardMenu->addEntry(drivingBackwardLeftAction);
|
||||
drivingBackwardMenu->addEntry(drivingBackwardStraightAction);
|
||||
drivingBackwardMenu->addEntry(drivingBackwardRightAction);
|
||||
engineMenu->addEntry(engineBothAction);
|
||||
|
||||
lightMenu->addEntry(lightFlashAction);
|
||||
lightMenu->addEntry(lightFadeAction);
|
||||
@@ -145,13 +145,22 @@ void MenuTestMode::init() {
|
||||
lightMenu->addEntry(lightOffAction);
|
||||
}
|
||||
|
||||
MenuTestModeWrapper::MenuTestModeWrapper(TestMode* testMode) {
|
||||
MenuTestModeWrapper::MenuTestModeWrapper(TestMode* testMode, TestModeFunctionSingle testModeFunction) {
|
||||
this->testMode = testMode;
|
||||
this->testModeFunctionSingle = testModeFunction;
|
||||
}
|
||||
|
||||
MenuTestModeWrapper::MenuTestModeWrapper(TestMode* testMode, TestModeFunctionDouble testModeFunction) {
|
||||
this->testMode = testMode;
|
||||
this->testModeFunctionDouble = testModeFunction;
|
||||
}
|
||||
|
||||
void MenuTestModeWrapper::action(int16_t* values, uint8_t length) {
|
||||
if (length > 2)
|
||||
std::cout << "Dummy in Action" << values[0] << values[1] << values[2] << std::endl;
|
||||
else
|
||||
std::cout << "Dummy in Action kene dre values" << std::endl;
|
||||
// This function calls a member function with a pointer
|
||||
// Very helpful site:
|
||||
// https://isocpp.org/wiki/faq/pointers-to-members#fnptr-vs-memfnptr-types
|
||||
if (length == 2 && this->testModeFunctionDouble)
|
||||
(this->testMode->*this->testModeFunctionDouble)(values[0], values[1]);
|
||||
else if (length == 1 && this->testModeFunctionSingle)
|
||||
(this->testMode->*this->testModeFunctionSingle)(values[0]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user