added digital control to manualControl
This commit is contained in:
@@ -16,6 +16,11 @@
|
||||
#include "controlPadInput.h"
|
||||
#include "calibrateCompass.h"
|
||||
|
||||
class DirectionChangeWrapper {
|
||||
public:
|
||||
virtual void action() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Drive the Rover with a Joystick
|
||||
*
|
||||
@@ -26,6 +31,11 @@
|
||||
*/
|
||||
class ManualControl : public DriveModi {
|
||||
public:
|
||||
enum class InputMode : uint8_t {
|
||||
Analog,
|
||||
Digital
|
||||
};
|
||||
|
||||
ManualControl(MoveControl *moveControl, const ControlPadInput *input);
|
||||
|
||||
/**
|
||||
@@ -35,7 +45,7 @@ class ManualControl : public DriveModi {
|
||||
~ManualControl();
|
||||
|
||||
/**
|
||||
* @brief Calls runManualControl() to update all values.
|
||||
* @brief Calls analogControl() to update all values.
|
||||
*
|
||||
* This function should be called every mainloop. If the delay is not reached, than the
|
||||
* functions returns immediately.
|
||||
@@ -44,12 +54,6 @@ class ManualControl : public DriveModi {
|
||||
*/
|
||||
void loop() override;
|
||||
|
||||
/**
|
||||
* @brief Noramly called repeatedly by loop() to calcluate new values.
|
||||
* Set new values for speed and rotation in moveControl
|
||||
*/
|
||||
void runManualControl();
|
||||
|
||||
/**
|
||||
* @brief Set the min delay between each loop
|
||||
*
|
||||
@@ -79,6 +83,11 @@ class ManualControl : public DriveModi {
|
||||
|
||||
void setCalibrateCompass(CalibrateCompass* val = nullptr) { this->caliCompass = val; }
|
||||
|
||||
void switchInputMode();
|
||||
void setInputMode(InputMode mode) { this->inputMode = mode; }
|
||||
InputMode getInputMode() const { return this->inputMode; }
|
||||
void setDirectionChangeCallback(DirectionChangeWrapper* callback) { this->directionChangeWrapper = callback; }
|
||||
|
||||
uint16_t getDutycycleLeft() const { return this->moveControl->getDutycycleLeft(); }
|
||||
uint16_t getDutycycleRight() const { return this->moveControl->getDutycycleRight(); }
|
||||
|
||||
@@ -87,11 +96,20 @@ class ManualControl : public DriveModi {
|
||||
const ControlPadInput* input;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Noramly called repeatedly by loop() to calcluate new values.
|
||||
* Set new values for speed and rotation in moveControl
|
||||
*/
|
||||
void analogControl();
|
||||
void digitalControl();
|
||||
|
||||
uint32_t lastMillis = 0;
|
||||
uint8_t delay = 10;
|
||||
double max_speed = 1;
|
||||
double max_rotation = 7;
|
||||
CalibrateCompass* caliCompass = nullptr;
|
||||
DirectionChangeWrapper* directionChangeWrapper = nullptr;
|
||||
InputMode inputMode = InputMode::Analog;
|
||||
};
|
||||
|
||||
#endif // MANUAL_CONTROL_H
|
||||
|
||||
Reference in New Issue
Block a user