ntrip, testMode, zed9 gnss modul
This commit is contained in:
@@ -74,9 +74,9 @@ void MenuAutopilot::printMenu() {
|
||||
}
|
||||
|
||||
void MenuAutopilot::update() {
|
||||
if (millis() - this->last_millis < this->minDelay)
|
||||
if (millis() - this->lastMillis < this->minDelay)
|
||||
return;
|
||||
this->last_millis = millis();
|
||||
this->lastMillis = millis();
|
||||
|
||||
if (!this->autopilot->shouldUpdate())
|
||||
return;
|
||||
|
||||
@@ -49,7 +49,7 @@ class MenuAutopilot : public MenuDriveMode {
|
||||
Autopilot* autopilot;
|
||||
RouteInfo routeInfo;
|
||||
|
||||
uint32_t last_millis = 0;
|
||||
uint32_t lastMillis = 0;
|
||||
uint16_t minDelay = 1500;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* @file menuTestMode.cpp
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-09-08
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#include "menuTestMode.h"
|
||||
|
||||
MenuTestMode::MenuTestMode(DriveManager* driveManager)
|
||||
: MenuDriveMode(driveManager) {
|
||||
// this->testMode = testMode;
|
||||
this->values[0] = 1;
|
||||
this->values[1] = 2;
|
||||
this->values[2] = 3;
|
||||
|
||||
strcpy(this->names[0], "Alpha");
|
||||
strcpy(this->names[1], "Beta");
|
||||
strcpy(this->names[2], "Gamma");
|
||||
}
|
||||
|
||||
MenuTestMode::~MenuTestMode() {
|
||||
if (isInit) {
|
||||
delete this->mainMenu;
|
||||
}
|
||||
}
|
||||
|
||||
void MenuTestMode::printMenu() {
|
||||
if (!this->isInit) {
|
||||
this->isInit = true;
|
||||
this->init();
|
||||
}
|
||||
|
||||
this->mainMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuTestMode::down() {
|
||||
this->mainMenu->down();
|
||||
}
|
||||
|
||||
void MenuTestMode::up() {
|
||||
this->mainMenu->up();
|
||||
}
|
||||
|
||||
void MenuTestMode::right() {
|
||||
this->mainMenu->right();
|
||||
}
|
||||
|
||||
void MenuTestMode::left() {
|
||||
if (this->mainMenu->isInSubmenu())
|
||||
this->mainMenu->left();
|
||||
else
|
||||
this->parentMenu->printMenu();
|
||||
}
|
||||
|
||||
void MenuTestMode::yes() {
|
||||
this->mainMenu->yes();
|
||||
}
|
||||
|
||||
void MenuTestMode::no() {
|
||||
if (this->mainMenu->isInSubmenu())
|
||||
this->mainMenu->no();
|
||||
else
|
||||
this->left();
|
||||
}
|
||||
|
||||
void MenuTestMode::init() {
|
||||
this->testMode = (TestMode*) this->driveManager->getDriveModiPtr();
|
||||
|
||||
auto dummy = []() {
|
||||
std::cout << "Dummy in Action" <<std::endl;
|
||||
};
|
||||
|
||||
// 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));
|
||||
|
||||
// Set menus on LCD
|
||||
this->mainMenu->setLcd(this->lcd);
|
||||
engineMenu->setLcd(this->lcd);
|
||||
engineLeftMenu->setLcd(this->lcd);
|
||||
engineRightMenu->setLcd(this->lcd);
|
||||
drivingMenu->setLcd(this->lcd);
|
||||
drivingForwardMenu->setLcd(this->lcd);
|
||||
drivingBackwardMenu->setLcd(this->lcd);
|
||||
lightMenu->setLcd(this->lcd);
|
||||
testInputMenu->setLcd(this->lcd);
|
||||
|
||||
// Entrys for the menus
|
||||
MenuAction* engineAction = new MenuAction("Engine", engineMenu);
|
||||
MenuAction* engineLeftAction = new MenuAction("Left", engineLeftMenu);
|
||||
MenuAction* engineRightAction = new MenuAction("Right", engineRightMenu);
|
||||
|
||||
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);
|
||||
MenuAction* lightFadeAction = new MenuAction("Fade", dummy);
|
||||
MenuAction* lightRedAction = new MenuAction("Red", dummy);
|
||||
MenuAction* lightGreenAction = new MenuAction("Green", dummy);
|
||||
MenuAction* lightBlueAction = new MenuAction("Blue", dummy);
|
||||
MenuAction* lightOffAction = new MenuAction("Off", dummy);
|
||||
|
||||
// Add entrys to the menus
|
||||
this->mainMenu->addEntry(engineAction);
|
||||
this->mainMenu->addEntry(drivingAction);
|
||||
this->mainMenu->addEntry(lightAction);
|
||||
|
||||
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);
|
||||
|
||||
lightMenu->addEntry(lightFlashAction);
|
||||
lightMenu->addEntry(lightFadeAction);
|
||||
lightMenu->addEntry(lightRedAction);
|
||||
lightMenu->addEntry(lightGreenAction);
|
||||
lightMenu->addEntry(lightBlueAction);
|
||||
lightMenu->addEntry(lightOffAction);
|
||||
}
|
||||
|
||||
MenuTestModeWrapper::MenuTestModeWrapper(TestMode* testMode) {
|
||||
this->testMode = testMode;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* @file menuTestMode.h
|
||||
* @author Alexander Klein (alex@kleiax.de)
|
||||
* @brief
|
||||
* @version 0.1
|
||||
* @date 2022-09-08
|
||||
*
|
||||
* @copyright Copyright (c) 2022
|
||||
*
|
||||
*/
|
||||
#ifndef MENU_TEST_MODE
|
||||
#define MENU_TEST_MODE
|
||||
|
||||
#include "SpecialMenus/driveModi/menuDriveMode.h"
|
||||
#include "driveModi/Modi/TestMode/testMode.h"
|
||||
#include "menu.h"
|
||||
#include "menuAction.h"
|
||||
#include "menuIntInput.h"
|
||||
|
||||
class MenuTestMode : public MenuDriveMode {
|
||||
public:
|
||||
MenuTestMode(DriveManager *driveManager);
|
||||
~MenuTestMode();
|
||||
void printMenu();
|
||||
|
||||
void down() override;
|
||||
void up() override;
|
||||
void right() override;
|
||||
void left() override;
|
||||
void yes() override;
|
||||
void no() override;
|
||||
|
||||
private:
|
||||
void init();
|
||||
|
||||
TestMode* testMode;
|
||||
Menu* mainMenu;
|
||||
|
||||
bool isInit = false;
|
||||
|
||||
uint8_t length = 3;
|
||||
int16_t values[3];
|
||||
char names[3][MAX_NAME_LENGTH];
|
||||
};
|
||||
|
||||
class MenuTestModeWrapper : public MenuIntInputWrapper {
|
||||
public:
|
||||
MenuTestModeWrapper(TestMode* testMode);
|
||||
|
||||
void action(int16_t* values, uint8_t length) override;
|
||||
|
||||
private:
|
||||
TestMode* testMode;
|
||||
};
|
||||
|
||||
#endif // MENU_TEST_MODE
|
||||
Reference in New Issue
Block a user