diff --git a/include/VictronMppt.h b/include/VictronMppt.h index 98aa36dcd..a4f1b1ab8 100644 --- a/include/VictronMppt.h +++ b/include/VictronMppt.h @@ -34,13 +34,13 @@ class VictronMpptClass { int32_t getPanelPowerWatts() const; // sum of total yield of all MPPT charge controllers in kWh - double getYieldTotal() const; + float getYieldTotal() const; // sum of today's yield of all MPPT charge controllers in kWh - double getYieldDay() const; + float getYieldDay() const; // minimum of all MPPT charge controllers' output voltages in V - double getOutputVoltage() const; + float getOutputVoltage() const; private: void loop(); diff --git a/lib/VeDirectFrameHandler/VeDirectData.h b/lib/VeDirectFrameHandler/VeDirectData.h index 0c43b555a..f651193b0 100644 --- a/lib/VeDirectFrameHandler/VeDirectData.h +++ b/lib/VeDirectFrameHandler/VeDirectData.h @@ -10,9 +10,9 @@ typedef struct { uint16_t PID = 0; // product id char SER[VE_MAX_VALUE_LEN]; // serial number char FW[VE_MAX_VALUE_LEN]; // firmware release number - double V = 0; // battery voltage in V - double I = 0; // battery current in A - double E = 0; // efficiency in percent (calculated, moving average) + float V = 0; // battery voltage in V + float I = 0; // battery current in A + float E = 0; // efficiency in percent (calculated, moving average) frozen::string const& getPidAsString() const; // product ID as string } veStruct; @@ -21,17 +21,17 @@ struct veMpptStruct : veStruct { uint8_t MPPT; // state of MPP tracker int32_t PPV; // panel power in W int32_t P; // battery output power in W (calculated) - double VPV; // panel voltage in V - double IPV; // panel current in A (calculated) + float VPV; // panel voltage in V + float IPV; // panel current in A (calculated) bool LOAD; // virtual load output state (on if battery voltage reaches upper limit, off if battery reaches lower limit) uint8_t CS; // current state of operation e.g. OFF or Bulk uint8_t ERR; // error code uint32_t OR; // off reason uint32_t HSDS; // day sequence number 1...365 - double H19; // yield total kWh - double H20; // yield today kWh + float H19; // yield total kWh + float H20; // yield today kWh int32_t H21; // maximum power today W - double H22; // yield yesterday kWh + float H22; // yield yesterday kWh int32_t H23; // maximum power yesterday W frozen::string const& getMpptAsString() const; // state of mppt as string diff --git a/lib/VeDirectFrameHandler/VeDirectMpptController.cpp b/lib/VeDirectFrameHandler/VeDirectMpptController.cpp index 24063cf51..63825d47a 100644 --- a/lib/VeDirectFrameHandler/VeDirectMpptController.cpp +++ b/lib/VeDirectFrameHandler/VeDirectMpptController.cpp @@ -76,7 +76,7 @@ void VeDirectMpptController::frameValidEvent() { } if (_tmpFrame.PPV > 0) { - _efficiency.addNumber(static_cast(_tmpFrame.P * 100) / _tmpFrame.PPV); + _efficiency.addNumber(static_cast(_tmpFrame.P * 100) / _tmpFrame.PPV); _tmpFrame.E = _efficiency.getAverage(); } } diff --git a/lib/VeDirectFrameHandler/VeDirectMpptController.h b/lib/VeDirectFrameHandler/VeDirectMpptController.h index c5af4521f..eddf8be70 100644 --- a/lib/VeDirectFrameHandler/VeDirectMpptController.h +++ b/lib/VeDirectFrameHandler/VeDirectMpptController.h @@ -24,9 +24,9 @@ class MovingAverage { _index = (_index + 1) % WINDOW_SIZE; } - double getAverage() const { + float getAverage() const { if (_count == 0) { return 0.0; } - return static_cast(_sum) / _count; + return static_cast(_sum) / _count; } private: @@ -47,5 +47,5 @@ class VeDirectMpptController : public VeDirectFrameHandler { private: bool processTextDataDerived(std::string const& name, std::string const& value) final; void frameValidEvent() final; - MovingAverage _efficiency; + MovingAverage _efficiency; }; diff --git a/src/VictronMppt.cpp b/src/VictronMppt.cpp index c555e9e81..d152c61ec 100644 --- a/src/VictronMppt.cpp +++ b/src/VictronMppt.cpp @@ -158,9 +158,9 @@ int32_t VictronMpptClass::getPanelPowerWatts() const return sum; } -double VictronMpptClass::getYieldTotal() const +float VictronMpptClass::getYieldTotal() const { - double sum = 0; + float sum = 0; for (const auto& upController : _controllers) { if (!upController->isDataValid()) { continue; } @@ -170,9 +170,9 @@ double VictronMpptClass::getYieldTotal() const return sum; } -double VictronMpptClass::getYieldDay() const +float VictronMpptClass::getYieldDay() const { - double sum = 0; + float sum = 0; for (const auto& upController : _controllers) { if (!upController->isDataValid()) { continue; } @@ -182,13 +182,13 @@ double VictronMpptClass::getYieldDay() const return sum; } -double VictronMpptClass::getOutputVoltage() const +float VictronMpptClass::getOutputVoltage() const { - double min = -1; + float min = -1; for (const auto& upController : _controllers) { if (!upController->isDataValid()) { continue; } - double volts = upController->getData().V; + float volts = upController->getData().V; if (min == -1) { min = volts; } min = std::min(min, volts); }