Cleanup motor
This commit is contained in:
parent
bab29a01c5
commit
1df58e9066
@ -1,18 +1,18 @@
|
||||
#include "Motor.h"
|
||||
#include <time.h>
|
||||
|
||||
#include <Arduino.h>
|
||||
// #include <Arduino.h>
|
||||
|
||||
Motor::Motor() {
|
||||
type = Type::Motor;
|
||||
}
|
||||
|
||||
float Motor::GetSpeed() {
|
||||
return this->currentSpeed;
|
||||
return this->currentTargetSpeed;
|
||||
}
|
||||
|
||||
void Motor::SetSpeed(float speed) {
|
||||
this->currentSpeed = speed;
|
||||
void Motor::SetSpeed(float targetSpeed) {
|
||||
this->currentTargetSpeed = targetSpeed;
|
||||
}
|
||||
|
||||
bool Motor::Drive(float distance) {
|
||||
|
17
Motor.h
17
Motor.h
@ -10,18 +10,25 @@ class Motor : public Thing {
|
||||
public:
|
||||
Motor();
|
||||
/// @brief Turning direction of the motor
|
||||
enum Direction { Forward = 1, Reverse = -1 };
|
||||
|
||||
/// @brief Set the turning direction of the motor
|
||||
// void SetDirection(Direction direction);
|
||||
/// @brief Motor turning direction
|
||||
enum class Direction { Clockwise = 1, CounterClockwise = -1 };
|
||||
/// @brief The forward turning direction of the motor
|
||||
Direction direction = Direction::Clockwise;
|
||||
|
||||
/// @brief Set the target motor speed
|
||||
/// @param speed The speed between -1 (full backward), 0 (stop) and 1 (full
|
||||
/// forward)
|
||||
virtual void SetSpeed(float speed);
|
||||
float GetSpeed();
|
||||
/// @brief Get the current target speed of the motor
|
||||
/// @return The speed between -1 (full backward), 0 (stop) and 1 (full
|
||||
/// forward)
|
||||
virtual float GetSpeed();
|
||||
|
||||
bool Drive(float distance);
|
||||
|
||||
protected:
|
||||
float currentSpeed = 0;
|
||||
float currentTargetSpeed = 0;
|
||||
bool driving = false;
|
||||
float targetDistance = 0;
|
||||
time_t startTime = 0;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 80c89a8232aa77cabaee9f739ef6fdd3e5508260
|
||||
Subproject commit 493a3f748907b4fb7e64177f94b7cb98a951af4c
|
Loading…
x
Reference in New Issue
Block a user