Files
Bachelorarbeit-Rover/src/driveModi/Modi/ManualControl/manualControl.h
T
2023-10-12 19:50:10 +02:00

74 lines
1.7 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 ControlPad
* and map the values to moveControl
*
* @see MoveControl
*/
class ManualControl : public DriveModi
{
public:
/**
* @brief The enum is used to change the interpretation of the joystick data
*/
enum class InputMode : uint8_t
{
Analog,
Digital
};
/**
* @brief Change the InputMode to the opposite
*/
void switchInputMode();
void setInputMode(InputMode mode) { this->inputMode = mode; }
InputMode getInputMode() const { return this->inputMode; }
/**
* @brief Set the DirectionChangeWrapper object
*
* This callback is used to inform the CalcAzimuth Component about a direction change
*
* @param callback
*/
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