Rename Battery classes

This commit is contained in:
Maximilian Mewes 2024-05-06 17:39:40 +02:00
parent 05a8c692f2
commit 18e9f9c304
6 changed files with 21 additions and 22 deletions

View File

@ -7,7 +7,7 @@
* Battery base class * Battery base class
* all other battery classes should inherit from this * all other battery classes should inherit from this
*/ */
class Battery class UMBattery
{ {
private: private:
@ -25,7 +25,7 @@ class Battery
} }
public: public:
Battery() UMBattery()
{ {
this->setVoltageMultiplier(USERMOD_BATTERY_VOLTAGE_MULTIPLIER); this->setVoltageMultiplier(USERMOD_BATTERY_VOLTAGE_MULTIPLIER);
this->setCalibration(USERMOD_BATTERY_CALIBRATION); this->setCalibration(USERMOD_BATTERY_CALIBRATION);

View File

@ -131,5 +131,4 @@ typedef struct bconfig_t
float voltageMultiplier; float voltageMultiplier;
} batteryConfig; } batteryConfig;
#endif #endif

View File

@ -2,18 +2,18 @@
#define UMBLion_h #define UMBLion_h
#include "../battery_defaults.h" #include "../battery_defaults.h"
#include "../battery.h" #include "../UMBattery.h"
/** /**
* Lion Battery * LiOn Battery
* *
*/ */
class Lion : public Battery class LionUMBattery : public UMBattery
{ {
private: private:
public: public:
Lion() : Battery() LionUMBattery() : UMBattery()
{ {
this->setMinVoltage(USERMOD_BATTERY_LION_MIN_VOLTAGE); this->setMinVoltage(USERMOD_BATTERY_LION_MIN_VOLTAGE);
this->setMaxVoltage(USERMOD_BATTERY_LION_MAX_VOLTAGE); this->setMaxVoltage(USERMOD_BATTERY_LION_MAX_VOLTAGE);

View File

@ -2,18 +2,18 @@
#define UMBLipo_h #define UMBLipo_h
#include "../battery_defaults.h" #include "../battery_defaults.h"
#include "../battery.h" #include "../UMBattery.h"
/** /**
* Lipo Battery * LiPo Battery
* *
*/ */
class Lipo : public Battery class LipoUMBattery : public UMBattery
{ {
private: private:
public: public:
Lipo() : Battery() LipoUMBattery() : UMBattery()
{ {
this->setMinVoltage(USERMOD_BATTERY_LIPO_MIN_VOLTAGE); this->setMinVoltage(USERMOD_BATTERY_LIPO_MIN_VOLTAGE);
this->setMaxVoltage(USERMOD_BATTERY_LIPO_MAX_VOLTAGE); this->setMaxVoltage(USERMOD_BATTERY_LIPO_MAX_VOLTAGE);

View File

@ -2,18 +2,18 @@
#define UMBUnkown_h #define UMBUnkown_h
#include "../battery_defaults.h" #include "../battery_defaults.h"
#include "../battery.h" #include "../UMBattery.h"
/** /**
* Lion Battery * Unkown / Default Battery
* *
*/ */
class Unkown : public Battery class UnkownUMBattery : public UMBattery
{ {
private: private:
public: public:
Unkown() : Battery() UnkownUMBattery() : UMBattery()
{ {
this->setMinVoltage(USERMOD_BATTERY_UNKOWN_MIN_VOLTAGE); this->setMinVoltage(USERMOD_BATTERY_UNKOWN_MIN_VOLTAGE);
this->setMaxVoltage(USERMOD_BATTERY_UNKOWN_MAX_VOLTAGE); this->setMaxVoltage(USERMOD_BATTERY_UNKOWN_MAX_VOLTAGE);

View File

@ -2,10 +2,10 @@
#include "wled.h" #include "wled.h"
#include "battery_defaults.h" #include "battery_defaults.h"
#include "battery.h" #include "UMBattery.h"
#include "types/unkown.h" #include "types/UnkownUMBattery.h"
#include "types/lion.h" #include "types/LionUMBattery.h"
#include "types/lipo.h" #include "types/LiPoUMBattery.h"
/* /*
* Usermod by Maximilian Mewes * Usermod by Maximilian Mewes
@ -19,7 +19,7 @@ class UsermodBattery : public Usermod
// battery pin can be defined in my_config.h // battery pin can be defined in my_config.h
int8_t batteryPin = USERMOD_BATTERY_MEASUREMENT_PIN; int8_t batteryPin = USERMOD_BATTERY_MEASUREMENT_PIN;
Battery* bat = new Unkown(); UMBattery* bat = new UnkownUMBattery();
batteryConfig cfg; batteryConfig cfg;
// how often to read the battery voltage // how often to read the battery voltage
@ -142,9 +142,9 @@ class UsermodBattery : public Usermod
// plug in the right battery type // plug in the right battery type
if(cfg.type == (batteryType)lipo) { if(cfg.type == (batteryType)lipo) {
bat = new Lipo(); bat = new LipoUMBattery();
} else if(cfg.type == (batteryType)lion) { } else if(cfg.type == (batteryType)lion) {
bat = new Lion(); bat = new LipoUMBattery();
} }
// update the choosen battery type with configured values // update the choosen battery type with configured values