refactore
This commit is contained in:
@@ -10,15 +10,6 @@
|
||||
*/
|
||||
#include "manualControl.h"
|
||||
|
||||
ManualControl::ManualControl(MoveControl* moveControl, const ControlPadInput *input)
|
||||
: DriveModi(moveControl) {
|
||||
this->input = input;
|
||||
}
|
||||
|
||||
ManualControl::~ManualControl() {
|
||||
|
||||
}
|
||||
|
||||
void ManualControl::run() {
|
||||
switch (this->inputMode) {
|
||||
case InputMode::Analog :
|
||||
@@ -34,16 +25,6 @@ void ManualControl::run() {
|
||||
}
|
||||
}
|
||||
|
||||
void ManualControl::setCalibrateCompass(CalibrateCompass *caliCompass) {
|
||||
if (caliCompass) {
|
||||
this->caliCompass = caliCompass;
|
||||
this->addChildComponent(this->caliCompass);
|
||||
} else if (this->caliCompass) {
|
||||
this->removeChildComponent(this->caliCompass);
|
||||
this->caliCompass = caliCompass;
|
||||
}
|
||||
}
|
||||
|
||||
void ManualControl::switchInputMode() {
|
||||
this->inputMode = (this->inputMode == InputMode::Analog) ? InputMode::Digital : InputMode::Analog;
|
||||
}
|
||||
@@ -51,7 +32,7 @@ void ManualControl::switchInputMode() {
|
||||
void ManualControl::analogControl() {
|
||||
// Have to be int16_t to avoid overflow (int8_t = 255 - 127 = -128)
|
||||
int16_t x = this->input->x - 127;
|
||||
int16_t y = this->input->y - 127;
|
||||
int16_t y = this-> input->y - 127;
|
||||
|
||||
// static int counter = 0;
|
||||
// if (counter % 60 == 0) {
|
||||
|
||||
@@ -11,10 +11,7 @@
|
||||
#ifndef MANUAL_CONTROL_H
|
||||
#define MANUAL_CONTROL_H
|
||||
|
||||
#include "moveControl.h"
|
||||
#include "driveModi/driveModi.h"
|
||||
#include "controlPadInput.h"
|
||||
#include "calibrateCompass.h"
|
||||
|
||||
class DirectionChangeWrapper {
|
||||
public:
|
||||
@@ -36,10 +33,7 @@ class ManualControl : public DriveModi {
|
||||
Digital
|
||||
};
|
||||
|
||||
ManualControl(MoveControl *moveControl, const ControlPadInput *input);
|
||||
~ManualControl();
|
||||
|
||||
void setCalibrateCompass(CalibrateCompass* caliCompass = nullptr);
|
||||
ManualControl(DriveModiParams params) : DriveModi(params){};
|
||||
|
||||
void switchInputMode();
|
||||
void setInputMode(InputMode mode) { this->inputMode = mode; }
|
||||
@@ -51,14 +45,12 @@ class ManualControl : public DriveModi {
|
||||
|
||||
protected:
|
||||
void run() override;
|
||||
const ControlPadInput* input;
|
||||
|
||||
private:
|
||||
void analogControl();
|
||||
void digitalControl();
|
||||
|
||||
bool lastLoopTurned = false;
|
||||
CalibrateCompass* caliCompass = nullptr;
|
||||
DirectionChangeWrapper* directionChangeWrapper = nullptr;
|
||||
InputMode inputMode = InputMode::Analog;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user