spelling
This commit is contained in:
@@ -0,0 +1,57 @@
|
|||||||
|
/**
|
||||||
|
* @file controlPad.cpp
|
||||||
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
|
* @brief
|
||||||
|
* @version 0.1
|
||||||
|
* @date 2023-03-30
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2023
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "controlPad.h"
|
||||||
|
|
||||||
|
ControlPad::ControlPad() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ControlPad::loop() {
|
||||||
|
if (millis() - this->lastLoopMillis < this->loopDelay)
|
||||||
|
return false;
|
||||||
|
this->lastLoopMillis = millis();
|
||||||
|
|
||||||
|
if(!this->connected)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (millis() - this->lastMessageReceive > this->disconnectTime) {
|
||||||
|
this->connected = false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->menuControl && this->controlInput.buttons > 0 && this->updated)
|
||||||
|
if (!this->firstButtonPress)
|
||||||
|
this->menuControl->printMenu();
|
||||||
|
|
||||||
|
if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Left))
|
||||||
|
this->menuControl->left();
|
||||||
|
else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Right))
|
||||||
|
this->menuControl->right();
|
||||||
|
else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Up))
|
||||||
|
this->menuControl->up();
|
||||||
|
else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Down))
|
||||||
|
this->menuControl->down();
|
||||||
|
else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::Yes))
|
||||||
|
this->menuControl->yes();
|
||||||
|
else if (ControlPadButton::isControlPadButtonPressed(&this->controlInput, ControlPadButton::PadButton::No))
|
||||||
|
this->menuControl->no();
|
||||||
|
|
||||||
|
this->menuControl->update();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ControlPadInput * ControlPad::getControlPadDataPtr(uint16_t maxElapsedTime) const {
|
||||||
|
if (maxElapsedTime && millis() - this->lastMessageReceive > maxElapsedTime)
|
||||||
|
return nullptr;
|
||||||
|
return &this->controlInput;
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file controllPad.h
|
* @file controlPad.h
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
* @brief
|
* @brief
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
@@ -13,23 +13,23 @@
|
|||||||
|
|
||||||
#include <menuControl.h>
|
#include <menuControl.h>
|
||||||
|
|
||||||
#include "controllPadInput.h"
|
#include "controlPadInput.h"
|
||||||
|
|
||||||
class ControllPad {
|
class ControlPad {
|
||||||
public:
|
public:
|
||||||
ControllPad();
|
ControlPad();
|
||||||
|
|
||||||
bool loop();
|
bool loop();
|
||||||
|
|
||||||
void setMenuControll(MenuControl* menuControll) { this->menuControl = menuControl; }
|
void setMenuControl(MenuControl* menuControl) { this->menuControl = menuControl; }
|
||||||
|
|
||||||
const ControllPadInput * getControllPadDataPtr(uint16_t maxElapsedTime = 0) const;
|
const ControlPadInput * getControlPadDataPtr(uint16_t maxElapsedTime = 0) const;
|
||||||
|
|
||||||
bool isControllPadConnected() const { return this->connected; }
|
bool isControlPadConnected() const { return this->connected; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MenuControl* menuControl = nullptr;
|
MenuControl* menuControl = nullptr;
|
||||||
ControllPadInput controllInput;
|
ControlPadInput controlInput;
|
||||||
|
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
bool updated = false;
|
bool updated = false;
|
||||||
@@ -38,7 +38,7 @@ class ControllPad {
|
|||||||
uint16_t disconnectTime = 50;
|
uint16_t disconnectTime = 50;
|
||||||
uint16_t loopDelay = 5;
|
uint16_t loopDelay = 5;
|
||||||
|
|
||||||
uint32_t lastMessageRecive = 0;
|
uint32_t lastMessageReceive = 0;
|
||||||
uint32_t lastLoopMillis = 0;
|
uint32_t lastLoopMillis = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* @file controllPadInput.h
|
* @file controlPadInput.h
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
* @author Alexander Klein (alex@kleiax.de)
|
||||||
* @brief
|
* @brief
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
@@ -9,12 +9,12 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef CONTROLL_PAD_INPUT_H
|
#ifndef CONTROL_PAD_INPUT_H
|
||||||
#define CONTROLL_PAD_INPUT_H
|
#define CONTROL_PAD_INPUT_H
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
struct ControllPadInput {
|
struct ControlPadInput {
|
||||||
uint8_t buttons;
|
uint8_t buttons;
|
||||||
uint8_t x;
|
uint8_t x;
|
||||||
uint8_t y;
|
uint8_t y;
|
||||||
@@ -22,7 +22,7 @@ struct ControllPadInput {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ControllPadButton {
|
class ControlPadButton {
|
||||||
public:
|
public:
|
||||||
enum PadButton {
|
enum PadButton {
|
||||||
Left,
|
Left,
|
||||||
@@ -34,9 +34,9 @@ class ControllPadButton {
|
|||||||
Action
|
Action
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool isControllPadButtonPressed(const ControllPadInput *input, PadButton button) {
|
static bool isControlPadButtonPressed(const ControlPadInput *input, PadButton button) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONTROLL_PAD_INPUT_H
|
#endif // CONTROL_PAD_INPUT_H
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
* @file controllPad.cpp
|
|
||||||
* @author Alexander Klein (alex@kleiax.de)
|
|
||||||
* @brief
|
|
||||||
* @version 0.1
|
|
||||||
* @date 2023-03-30
|
|
||||||
*
|
|
||||||
* @copyright Copyright (c) 2023
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "controllPad.h"
|
|
||||||
|
|
||||||
ControllPad::ControllPad() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ControllPad::loop() {
|
|
||||||
if (millis() - this->lastLoopMillis < this->loopDelay)
|
|
||||||
return false;
|
|
||||||
this->lastLoopMillis = millis();
|
|
||||||
|
|
||||||
if(!this->connected)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (millis() - this->lastMessageRecive > this->disconnectTime) {
|
|
||||||
this->connected = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this->menuControl && this->controllInput.buttons > 0 && this->updated)
|
|
||||||
if (!this->firstButtonPress)
|
|
||||||
this->menuControl->printMenu();
|
|
||||||
|
|
||||||
if (ControllPadButton::isControllPadButtonPressed(&this->controllInput, ControllPadButton::PadButton::Left))
|
|
||||||
this->menuControl->left();
|
|
||||||
else if (ControllPadButton::isControllPadButtonPressed(&this->controllInput, ControllPadButton::PadButton::Right))
|
|
||||||
this->menuControl->right();
|
|
||||||
else if (ControllPadButton::isControllPadButtonPressed(&this->controllInput, ControllPadButton::PadButton::Up))
|
|
||||||
this->menuControl->up();
|
|
||||||
else if (ControllPadButton::isControllPadButtonPressed(&this->controllInput, ControllPadButton::PadButton::Down))
|
|
||||||
this->menuControl->down();
|
|
||||||
else if (ControllPadButton::isControllPadButtonPressed(&this->controllInput, ControllPadButton::PadButton::Yes))
|
|
||||||
this->menuControl->yes();
|
|
||||||
else if (ControllPadButton::isControllPadButtonPressed(&this->controllInput, ControllPadButton::PadButton::No))
|
|
||||||
this->menuControl->no();
|
|
||||||
|
|
||||||
this->menuControl->update();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ControllPadInput * ControllPad::getControllPadDataPtr(uint16_t maxElapsedTime) const {
|
|
||||||
if (maxElapsedTime && millis() - this->lastMessageRecive > maxElapsedTime)
|
|
||||||
return nullptr;
|
|
||||||
return &this->controllInput;
|
|
||||||
}
|
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "controllPadInput.h"
|
#include "controlPadInput.h"
|
||||||
#include "menuInformationSites.h"
|
#include "menuInformationSites.h"
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include "driveModi/Modi/Autopilot/autopilot.h"
|
#include "driveModi/Modi/Autopilot/autopilot.h"
|
||||||
|
|
||||||
Autopilot::Autopilot(MoveControl* moveControl, const ControllPadInput *input, Navigation* navigation)
|
Autopilot::Autopilot(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation)
|
||||||
: ManualControl(moveControl, input) {
|
: ManualControl(moveControl, input) {
|
||||||
this->navigation = navigation;
|
this->navigation = navigation;
|
||||||
this->navigationStarted = this->navigation->startNavigation();
|
this->navigationStarted = this->navigation->startNavigation();
|
||||||
@@ -45,7 +45,7 @@ void Autopilot::runAutopilot() {
|
|||||||
this->selfDrivingAvailable = true;
|
this->selfDrivingAvailable = true;
|
||||||
|
|
||||||
if (!this->selfDriving && this->selfDrivingAvailable)
|
if (!this->selfDriving && this->selfDrivingAvailable)
|
||||||
this->setSelfDriving(ControllPadButton::isControllPadButtonPressed(this->input, ControllPadButton::PadButton::Action));
|
this->setSelfDriving(ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action));
|
||||||
|
|
||||||
if (this->routeInfo.currentPoint == this->routeInfo.totalPoints) {
|
if (this->routeInfo.currentPoint == this->routeInfo.totalPoints) {
|
||||||
this->navigationEnded = true;
|
this->navigationEnded = true;
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class Autopilot : public ManualControl {
|
|||||||
* @param moveControl for ManualControl
|
* @param moveControl for ManualControl
|
||||||
* @param navigation for route instructions
|
* @param navigation for route instructions
|
||||||
*/
|
*/
|
||||||
Autopilot(MoveControl* moveControl, const ControllPadInput *input, Navigation* navigation);
|
Autopilot(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calls runAutopilot or ManualControl loop
|
* @brief Calls runAutopilot or ManualControl loop
|
||||||
@@ -50,7 +50,7 @@ class Autopilot : public ManualControl {
|
|||||||
void loop();
|
void loop();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Manges the autoipilot
|
* @brief Manges the autopilot
|
||||||
*
|
*
|
||||||
* If the first Point is near to current location you can turn
|
* If the first Point is near to current location you can turn
|
||||||
* the autopilot on.
|
* the autopilot on.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
#include "driveModi/Modi/CaptureRoute/captureRoute.h"
|
#include "driveModi/Modi/CaptureRoute/captureRoute.h"
|
||||||
|
|
||||||
CaptureRoute::CaptureRoute(MoveControl* moveControl, const ControllPadInput *input, Navigation* navigation)
|
CaptureRoute::CaptureRoute(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation)
|
||||||
: ManualControl(moveControl, input) {
|
: ManualControl(moveControl, input) {
|
||||||
this->navigation = navigation;
|
this->navigation = navigation;
|
||||||
this->routeInfo = navigation->getRouteInfo();
|
this->routeInfo = navigation->getRouteInfo();
|
||||||
@@ -28,7 +28,7 @@ void CaptureRoute::loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CaptureRoute::runCaptureRoute() {
|
void CaptureRoute::runCaptureRoute() {
|
||||||
if (ControllPadButton::isControllPadButtonPressed(this->input, ControllPadButton::PadButton::Action)) {
|
if (ControlPadButton::isControlPadButtonPressed(this->input, ControlPadButton::PadButton::Action)) {
|
||||||
if (this->navigation->addCurrentPosToRoute()) {
|
if (this->navigation->addCurrentPosToRoute()) {
|
||||||
this->routeInfo = navigation->getRouteInfo();
|
this->routeInfo = navigation->getRouteInfo();
|
||||||
this->updateDisplay = true;
|
this->updateDisplay = true;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class CaptureRoute : public ManualControl {
|
|||||||
* @param moveControl for ManualControl
|
* @param moveControl for ManualControl
|
||||||
* @param navigation to add Points
|
* @param navigation to add Points
|
||||||
*/
|
*/
|
||||||
CaptureRoute(MoveControl* moveControl, const ControllPadInput *input, Navigation* navigation);
|
CaptureRoute(MoveControl* moveControl, const ControlPadInput *input, Navigation* navigation);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Calls runCaptureRoute and ManualControl::loop
|
* @brief Calls runCaptureRoute and ManualControl::loop
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "manualControl.h"
|
#include "manualControl.h"
|
||||||
|
|
||||||
ManualControl::ManualControl(MoveControl *moveControl, const ControllPadInput *input) {
|
ManualControl::ManualControl(MoveControl *moveControl, const ControlPadInput *input) {
|
||||||
this->moveControl = moveControl;
|
this->moveControl = moveControl;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
this->moveControl->setDrivingStatus(DrivingStatus::drive);
|
this->moveControl->setDrivingStatus(DrivingStatus::drive);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#include "moveControl.h"
|
#include "moveControl.h"
|
||||||
#include "driveModi/driveModi.h"
|
#include "driveModi/driveModi.h"
|
||||||
#include "controllPadInput.h"
|
#include "controlPadInput.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Drive the Rover with a Joystick
|
* @brief Drive the Rover with a Joystick
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
class ManualControl : public DriveModi {
|
class ManualControl : public DriveModi {
|
||||||
public:
|
public:
|
||||||
ManualControl(MoveControl *moveControl, const ControllPadInput *input);
|
ManualControl(MoveControl *moveControl, const ControlPadInput *input);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroy the Manual Control object
|
* @brief Destroy the Manual Control object
|
||||||
@@ -72,7 +72,7 @@ class ManualControl : public DriveModi {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
MoveControl *moveControl;
|
MoveControl *moveControl;
|
||||||
const ControllPadInput* input;
|
const ControlPadInput* input;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t lastMillis = 0;
|
uint32_t lastMillis = 0;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ Modi& operator++(Modi& m, int) {
|
|||||||
return m = (m == Modi::TestMode) ? Modi::Off : static_cast<Modi>(static_cast<int>(m)+1);
|
return m = (m == Modi::TestMode) ? Modi::Off : static_cast<Modi>(static_cast<int>(m)+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
DriveManager::DriveManager(MoveControl *moveControl, const ControllPadInput *input, bool wifi) {
|
DriveManager::DriveManager(MoveControl *moveControl, const ControlPadInput *input, bool wifi) {
|
||||||
this->moveControl = moveControl;
|
this->moveControl = moveControl;
|
||||||
this->input = input;
|
this->input = input;
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "networkConfig.h"
|
#include "networkConfig.h"
|
||||||
#include "debugTimes.h"
|
#include "debugTimes.h"
|
||||||
#include "controllPadInput.h"
|
#include "controlPadInput.h"
|
||||||
|
|
||||||
// All Drive Modi
|
// All Drive Modi
|
||||||
#include "driveModi/Modi/ManualControl/manualControl.h"
|
#include "driveModi/Modi/ManualControl/manualControl.h"
|
||||||
@@ -52,7 +52,7 @@ class DriveManager {
|
|||||||
*
|
*
|
||||||
* @param moveControl
|
* @param moveControl
|
||||||
*/
|
*/
|
||||||
DriveManager(MoveControl *moveControl, const ControllPadInput *input, bool wifi = false);
|
DriveManager(MoveControl *moveControl, const ControlPadInput *input, bool wifi = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Destroy the Drive Manager object
|
* @brief Destroy the Drive Manager object
|
||||||
@@ -118,7 +118,7 @@ class DriveManager {
|
|||||||
private:
|
private:
|
||||||
Modi currentModus = Modi::Off;
|
Modi currentModus = Modi::Off;
|
||||||
MoveControl *moveControl;
|
MoveControl *moveControl;
|
||||||
const ControllPadInput* input;
|
const ControlPadInput* input;
|
||||||
DriveModi *currentModusPtr = nullptr;
|
DriveModi *currentModusPtr = nullptr;
|
||||||
Navigation* navigation;
|
Navigation* navigation;
|
||||||
SPIClass* spiPort;
|
SPIClass* spiPort;
|
||||||
|
|||||||
+6
-6
@@ -29,7 +29,7 @@
|
|||||||
#include "debugMqtt.h"
|
#include "debugMqtt.h"
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
#include "debugTimes.h"
|
#include "debugTimes.h"
|
||||||
#include "controllPad.h"
|
#include "controlPad.h"
|
||||||
|
|
||||||
#include "menu.h"
|
#include "menu.h"
|
||||||
#include "menuAction.h"
|
#include "menuAction.h"
|
||||||
@@ -50,7 +50,7 @@ LcdWrapper* lcdWrapper;
|
|||||||
OutputBuf* outputBuf;
|
OutputBuf* outputBuf;
|
||||||
DebugMqtt* debugMqtt = nullptr;
|
DebugMqtt* debugMqtt = nullptr;
|
||||||
Battery* mainBattery;
|
Battery* mainBattery;
|
||||||
ControllPad* controllPad;
|
ControlPad* controlPad;
|
||||||
|
|
||||||
bool wifiIsActive;
|
bool wifiIsActive;
|
||||||
|
|
||||||
@@ -66,8 +66,8 @@ void setup() {
|
|||||||
char wifiIndicator = 'X';
|
char wifiIndicator = 'X';
|
||||||
|
|
||||||
mainBattery = new Battery(35, 692000, 218500);
|
mainBattery = new Battery(35, 692000, 218500);
|
||||||
controllPad = new ControllPad();
|
controlPad = new ControlPad();
|
||||||
controllPad->setMenuControll(main_m);
|
controlPad->setMenuControl(main_m);
|
||||||
|
|
||||||
Wire.begin(21, 19);
|
Wire.begin(21, 19);
|
||||||
Wire.setClock(400000);
|
Wire.setClock(400000);
|
||||||
@@ -97,7 +97,7 @@ void setup() {
|
|||||||
std::cout << "Welcome to Kleiax-Rover" << std::endl;
|
std::cout << "Welcome to Kleiax-Rover" << std::endl;
|
||||||
std::cout << "All actions from the main program run on Core -> " << xPortGetCoreID() << std::endl;
|
std::cout << "All actions from the main program run on Core -> " << xPortGetCoreID() << std::endl;
|
||||||
|
|
||||||
driveManager = new DriveManager(&moveController, controllPad->getControllPadDataPtr(), wifiIsActive);
|
driveManager = new DriveManager(&moveController, controlPad->getControlPadDataPtr(), wifiIsActive);
|
||||||
|
|
||||||
outputBuf->activateMqtt(false);
|
outputBuf->activateMqtt(false);
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ void loop() {
|
|||||||
wifiTime.stopConsol("WiFi-Time", 10);
|
wifiTime.stopConsol("WiFi-Time", 10);
|
||||||
}
|
}
|
||||||
driveManager->loop();
|
driveManager->loop();
|
||||||
controllPad->loop();
|
controlPad->loop();
|
||||||
lcdWrapper->loop();
|
lcdWrapper->loop();
|
||||||
|
|
||||||
mainBattery->loop();
|
mainBattery->loop();
|
||||||
|
|||||||
Reference in New Issue
Block a user