make all possible functions const

This commit is contained in:
2023-08-18 11:44:10 +02:00
parent 11d21e2e89
commit 4cd2b9368d
18 changed files with 33 additions and 52 deletions
+3 -11
View File
@@ -114,27 +114,19 @@ void MotorControl::emergencyStop() {
setRealPower(0);
}
int8_t MotorControl::getPower() {
return this->power;
}
int8_t MotorControl::getTargetPower() {
return this->targetPower;
}
bool MotorControl::isTargetPowerReached() {
bool MotorControl::isTargetPowerReached() const {
if (this->targetPower == this->power)
return true;
return false;
}
bool MotorControl::isAccelerationPositive() {
bool MotorControl::isAccelerationPositive() const {
if (power < targetPower)
return true;
return false;
}
bool MotorControl::isAccelerationNegative() {
bool MotorControl::isAccelerationNegative() const {
if (power > targetPower)
return true;
return false;
+5 -5
View File
@@ -103,19 +103,19 @@ class MotorControl : public Component {
*
* @return int8_t percent of power (-100 to 100)
*/
int8_t getPower();
int8_t getPower() const { return this->power; };
/**
* @brief Get the target power
*
* @return int8_t percent of power (-100 to 100)
*/
int8_t getTargetPower();
int8_t getTargetPower() const { return this->targetPower; };
uint16_t getDutycycle() const { return this->dutycycle; }
bool isTargetPowerReached();
bool isAccelerationPositive();
bool isAccelerationNegative();
bool isTargetPowerReached() const;
bool isAccelerationPositive() const;
bool isAccelerationNegative() const;
private:
void run() override;