/** * @file driveModi.h * @author Alexander Klein (alex@kleiax.de) * @brief Contains a virtual class for all Modi * @version 0.1 * @date 2021-12-14 * * @copyright Copyright (c) 2021 * */ #ifndef DRIVEMODI_H #define DRIVEMODI_H #include "component.h" #include "moveControl.h" #include "controlPadInput.h" #include "sensorData.h" /** * @brief The struct contains all objects needed by a DriveMode */ struct DriveModiParams { MoveControl *moveControl; const ControlPadInput *input; const SensorData *sensorData; }; /** * @brief Baseclass to build DriveModi * * This class must be inherited by other classes which want to be * act as a DriveModi, because the DriveModi structure uses polymorphism. */ class DriveModi : public Component { public: virtual ~DriveModi(); const SensorData *getSensorData() const { return this->sensorData; } /** * @brief This activates a DriveMode * * This function have to be called to provide the DriveMode * with this objects * * @param moveControl * @param input * @param sensorData */ void activate(MoveControl *moveControl, ControlPadInput *input, SensorData *sensorData); void activate(DriveModiParams params); void setSpeeds(DrivingSpeeds speeds) { this->maxSpeeds = speeds; } DrivingSpeeds getSpeeds() const { return this->maxSpeeds; } DrivingSpeeds &getSpeedsRef() { return this->maxSpeeds; } protected: /** * @brief Prepare other things * * This function can be overwritten to prepare things * for the specific DriveModi. This function will be * called after activate(). */ virtual void afterActivate() {} MoveControl *moveControl = nullptr; DrivingSpeeds maxSpeeds = {1, 7}; const ControlPadInput *input = nullptr; const SensorData *sensorData = nullptr; private: void init(); static constexpr uint8_t defaultDelay = 40; }; #endif // DRIVEMODI_H