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 -3
View File
@@ -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++) {
+4 -4
View File
@@ -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;