Removed 2 unneeded values from HA reporting, fixed mV reporting value
This commit is contained in:
@@ -277,6 +277,19 @@ class Meter {
|
||||
|
||||
float calc_display_value_() const {
|
||||
if (this->overload) return NAN;
|
||||
|
||||
if (this->is_plus) {
|
||||
uint16_t pair1 = static_cast<uint16_t>(this->raw_[0]) | (static_cast<uint16_t>(this->raw_[1]) << 8);
|
||||
uint8_t decimal = pair1 & 0x07;
|
||||
if (decimal >= 7) return NAN;
|
||||
|
||||
uint16_t pair3 = static_cast<uint16_t>(this->raw_[4]) | (static_cast<uint16_t>(this->raw_[5]) << 8);
|
||||
bool negative = pair3 >= 0x7FFF;
|
||||
uint16_t digits = negative ? (pair3 & 0x7FFF) : pair3;
|
||||
float v = static_cast<float>(digits) / std::pow(10.0f, decimal);
|
||||
return negative ? -v : v;
|
||||
}
|
||||
|
||||
uint8_t decimal = 0;
|
||||
switch (this->value_[REGPOINT] & 0x07) {
|
||||
case 0b001: decimal = 1; break;
|
||||
|
||||
Reference in New Issue
Block a user