remove all PS3 things and begin with ControllPad

This commit is contained in:
2023-03-30 22:20:28 +02:00
parent e4cdc5f98d
commit 33fe6916ed
16 changed files with 182 additions and 150 deletions
+3 -3
View File
@@ -11,8 +11,8 @@
#include "driveModi/Modi/Autopilot/autopilot.h"
Autopilot::Autopilot(MoveControl* moveControl, Ps3Controller *gamepad, Navigation* navigation)
: ManualControl(moveControl, gamepad) {
Autopilot::Autopilot(MoveControl* moveControl, const ControllPadInput *input, Navigation* navigation)
: ManualControl(moveControl, input) {
this->navigation = navigation;
this->navigationStarted = this->navigation->startNavigation();
this->routeInfo = this->navigation->getRouteInfo();
@@ -45,7 +45,7 @@ void Autopilot::runAutopilot() {
this->selfDrivingAvailable = true;
if (!this->selfDriving && this->selfDrivingAvailable)
this->setSelfDriving(this->gamepad->data.button.triangle);
this->setSelfDriving(ControllPadButton::isControllPadButtonPressed(this->input, ControllPadButton::PadButton::Action));
if (this->routeInfo.currentPoint == this->routeInfo.totalPoints) {
this->navigationEnded = true;
+1 -1
View File
@@ -35,7 +35,7 @@ class Autopilot : public ManualControl {
* @param moveControl for ManualControl
* @param navigation for route instructions
*/
Autopilot(MoveControl* moveControl, Ps3Controller *gamepad, Navigation* navigation);
Autopilot(MoveControl* moveControl, const ControllPadInput *input, Navigation* navigation);
/**
* @brief Calls runAutopilot or ManualControl loop
@@ -11,8 +11,8 @@
#include "driveModi/Modi/CaptureRoute/captureRoute.h"
CaptureRoute::CaptureRoute(MoveControl* moveControl, Ps3Controller *gamepad, Navigation* navigation)
: ManualControl(moveControl, gamepad) {
CaptureRoute::CaptureRoute(MoveControl* moveControl, const ControllPadInput *input, Navigation* navigation)
: ManualControl(moveControl, input) {
this->navigation = navigation;
this->routeInfo = navigation->getRouteInfo();
}
@@ -28,7 +28,7 @@ void CaptureRoute::loop() {
}
void CaptureRoute::runCaptureRoute() {
if (this->gamepad->data.button.triangle) {
if (ControllPadButton::isControllPadButtonPressed(this->input, ControllPadButton::PadButton::Action)) {
if (this->navigation->addCurrentPosToRoute()) {
this->routeInfo = navigation->getRouteInfo();
this->updateDisplay = true;
@@ -33,7 +33,7 @@ class CaptureRoute : public ManualControl {
* @param moveControl for ManualControl
* @param navigation to add Points
*/
CaptureRoute(MoveControl* moveControl, Ps3Controller *gamepad, Navigation* navigation);
CaptureRoute(MoveControl* moveControl, const ControllPadInput *input, Navigation* navigation);
/**
* @brief Calls runCaptureRoute and ManualControl::loop
@@ -10,9 +10,9 @@
*/
#include "manualControl.h"
ManualControl::ManualControl(MoveControl *moveControl, Ps3Controller *gamepad) {
ManualControl::ManualControl(MoveControl *moveControl, const ControllPadInput *input) {
this->moveControl = moveControl;
this->gamepad = gamepad;
this->input = input;
this->moveControl->setDrivingStatus(DrivingStatus::drive);
}
@@ -31,8 +31,8 @@ void ManualControl::loop() {
}
void ManualControl::runManualControl() {
int8_t x = this->gamepad->data.analog.stick.lx;
int8_t y = this->gamepad->data.analog.stick.ly;
int8_t x = this->input->x;
int8_t y = this->input->y;
double value_per_step = this->max_speed * 2 / 256;
this->moveControl->setSpeed((y * -1) * value_per_step);
@@ -13,6 +13,7 @@
#include "moveControl.h"
#include "driveModi/driveModi.h"
#include "controllPadInput.h"
/**
* @brief Drive the Rover with a Joystick
@@ -24,7 +25,7 @@
*/
class ManualControl : public DriveModi {
public:
ManualControl(MoveControl *moveControl, Ps3Controller *gamepad);
ManualControl(MoveControl *moveControl, const ControllPadInput *input);
/**
* @brief Destroy the Manual Control object
@@ -71,7 +72,7 @@ class ManualControl : public DriveModi {
protected:
MoveControl *moveControl;
Ps3Controller *gamepad;
const ControllPadInput* input;
private:
uint32_t lastMillis = 0;
+5 -5
View File
@@ -15,9 +15,9 @@ Modi& operator++(Modi& m, int) {
return m = (m == Modi::TestMode) ? Modi::Off : static_cast<Modi>(static_cast<int>(m)+1);
}
DriveManager::DriveManager(MoveControl *moveControl, Ps3Controller *gamepad, bool wifi) {
DriveManager::DriveManager(MoveControl *moveControl, const ControllPadInput *input, bool wifi) {
this->moveControl = moveControl;
this->gamepad = gamepad;
this->input = input;
this->spiPort = new SPIClass(HSPI);
spiPort->begin(UBLOX_GNSS_SPI_SCK, UBLOX_GNSS_SPI_CIPO, UBLOX_GNSS_SPI_COPI, UBLOX_GNSS_SPI_CS);
@@ -66,17 +66,17 @@ void DriveManager::changeModus(Modi modus) {
break;
case Modi::ManualControl: {
this->currentModusPtr = new ManualControl(this->moveControl, this->gamepad);
this->currentModusPtr = new ManualControl(this->moveControl, this->input);
}
break;
case Modi::CaptureRoute: {
this->currentModusPtr = new CaptureRoute(this->moveControl, this->gamepad, this->navigation);
this->currentModusPtr = new CaptureRoute(this->moveControl, this->input, this->navigation);
}
break;
case Modi::Autopilot: {
this->currentModusPtr = new Autopilot(this->moveControl, this->gamepad, this->navigation);
this->currentModusPtr = new Autopilot(this->moveControl, this->input, this->navigation);
}
break;
+3 -2
View File
@@ -21,6 +21,7 @@
#include "config.h"
#include "networkConfig.h"
#include "debugTimes.h"
#include "controllPadInput.h"
// All Drive Modi
#include "driveModi/Modi/ManualControl/manualControl.h"
@@ -51,7 +52,7 @@ class DriveManager {
*
* @param moveControl
*/
DriveManager(MoveControl *moveControl, Ps3Controller *gamepad, bool wifi = false);
DriveManager(MoveControl *moveControl, const ControllPadInput *input, bool wifi = false);
/**
* @brief Destroy the Drive Manager object
@@ -117,7 +118,7 @@ class DriveManager {
private:
Modi currentModus = Modi::Off;
MoveControl *moveControl;
Ps3Controller *gamepad;
const ControllPadInput* input;
DriveModi *currentModusPtr = nullptr;
Navigation* navigation;
SPIClass* spiPort;
-2
View File
@@ -12,8 +12,6 @@
#ifndef DRIVEMODI_H
#define DRIVEMODI_H
#include <Ps3Controller.h>
/**
* @brief Baseclass to build DriveModi
*