fix: Make sure limit values sre consistent and not above 100%

Ref: https://github.com/tbnobody/OpenDTU/issues/25
This commit is contained in:
Mathieu Carbou 2025-01-24 11:57:39 +01:00
parent 653efb41a2
commit f01dd7c4bf
No known key found for this signature in database
GPG Key ID: BAAD965CEDEA921A

View File

@ -47,7 +47,11 @@ float SystemConfigParaParser::getLimitPercent() const
HOY_SEMAPHORE_TAKE(); HOY_SEMAPHORE_TAKE();
const float ret = ((static_cast<uint16_t>(_payload[2]) << 8) | _payload[3]) / 10.0; const float ret = ((static_cast<uint16_t>(_payload[2]) << 8) | _payload[3]) / 10.0;
HOY_SEMAPHORE_GIVE(); HOY_SEMAPHORE_GIVE();
return ret;
// don't pretend the inverter could produce more than its rated power,
// even though it does process, accept, and even save limit values beyond
// its rated power.
return min<float>(100, ret);
} }
void SystemConfigParaParser::setLimitPercent(const float value) void SystemConfigParaParser::setLimitPercent(const float value)