make all possible functions const
This commit is contained in:
@@ -39,12 +39,12 @@ void Battery::run() {
|
||||
return;
|
||||
}
|
||||
|
||||
double Battery::getBatteryVoltage() {
|
||||
double Battery::getBatteryVoltage() const {
|
||||
double res = this->batteryVoltage;
|
||||
return (int)(res*100+0.5)/100.0;
|
||||
}
|
||||
|
||||
bool Battery::isBatteryLow(double voltage) {
|
||||
bool Battery::isBatteryLow(double voltage) const {
|
||||
if (this->getBatteryVoltage() <= voltage && this->batteryVoltage > this->absurdLowVoltage)
|
||||
return true;
|
||||
return false;
|
||||
@@ -136,7 +136,7 @@ void Battery::initBuffer() {
|
||||
this->adcBuffer[i] = 0;
|
||||
}
|
||||
|
||||
uint16_t Battery::getBufAvg() {
|
||||
uint16_t Battery::getBufAvg() const {
|
||||
uint32_t res = 0;
|
||||
uint8_t emptyPos = 0;
|
||||
for (uint8_t i = 0; i < Battery::bufferSize; i++) {
|
||||
|
||||
@@ -48,14 +48,14 @@ class Battery : public Component {
|
||||
*
|
||||
* @return double in Volt
|
||||
*/
|
||||
double getBatteryVoltage();
|
||||
double getBatteryVoltage() const;
|
||||
|
||||
/**
|
||||
* @brief Get the charge level of the battery
|
||||
*
|
||||
* @return uint8_t charge level in percent
|
||||
*/
|
||||
uint8_t getBatteryPercent() { return this->batteryPercent; }
|
||||
uint8_t getBatteryPercent() const { return this->batteryPercent; }
|
||||
|
||||
/**
|
||||
* @brief Checks if the battery is low.
|
||||
@@ -68,7 +68,7 @@ class Battery : public Component {
|
||||
* @return true if the battery is low
|
||||
* @return false if the battery is high
|
||||
*/
|
||||
bool isBatteryLow(double voltage);
|
||||
bool isBatteryLow(double voltage) const;
|
||||
|
||||
bool isNewValue();
|
||||
|
||||
@@ -79,7 +79,7 @@ class Battery : public Component {
|
||||
void calculateBatteryPercent();
|
||||
void readAdcToBuf();
|
||||
void initBuffer();
|
||||
uint16_t getBufAvg();
|
||||
uint16_t getBufAvg() const;
|
||||
|
||||
static const uint8_t bufferSize = 30;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ void Counter::clear() {
|
||||
pcnt_counter_clear(this->unit);
|
||||
}
|
||||
|
||||
int16_t Counter::getValue() {
|
||||
int16_t Counter::getValue() const {
|
||||
int16_t res;
|
||||
pcnt_get_counter_value(this->unit, &res);
|
||||
return res;
|
||||
|
||||
@@ -14,7 +14,7 @@ class Counter {
|
||||
void resume();
|
||||
void clear();
|
||||
|
||||
int16_t getValue();
|
||||
int16_t getValue() const;
|
||||
|
||||
void setFilterValue(uint16_t value);
|
||||
void filterEnable();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -128,7 +128,7 @@ class Point{
|
||||
*
|
||||
* @return Accuracy
|
||||
*/
|
||||
Accuracy getAccuracy() { return this->accuracy; }
|
||||
Accuracy getAccuracy() const { return this->accuracy; }
|
||||
|
||||
private:
|
||||
void init(uint32_t horizontalAccuracy, uint32_t creationTime);
|
||||
|
||||
@@ -95,7 +95,7 @@ class Speedometer : public Component {
|
||||
*
|
||||
* @return Direction
|
||||
*/
|
||||
Direction getDirection() { return this->currentDirection; }
|
||||
Direction getDirection() const { return this->currentDirection; }
|
||||
|
||||
/**
|
||||
* @brief Get the calculated speed of the Wheel
|
||||
|
||||
Reference in New Issue
Block a user