Files
Bachelorarbeit-Rover/src/driveModi/Modi/ManualControl/manualControl.h
T

57 lines
1.5 KiB
C++

/**
* @file manualControl.h
* @author Alexander Klein (alex@kleiax.de)
* @brief A small class to drive the Rover by the controller joystick.
* @version 0.1
* @date 2021-12-13
*
* @copyright Copyright (c) 2021
*
*/
#ifndef MANUAL_CONTROL_H
#define MANUAL_CONTROL_H
#include "driveModi/driveModi.h"
class DirectionChangeWrapper {
public:
virtual void action() = 0;
};
/**
* @brief Drive the Rover with a Joystick
*
* This class gets the x and y value from the PS3 controller
* and map the values to moveControl
*
* @see MoveControl
*/
class ManualControl : public DriveModi {
public:
enum class InputMode : uint8_t {
Analog,
Digital
};
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(); }
protected:
void run() override;
private:
void analogControl();
void digitalControl();
bool lastLoopTurned = false;
DirectionChangeWrapper* directionChangeWrapper = nullptr;
InputMode inputMode = InputMode::Analog;
};
#endif // MANUAL_CONTROL_H