From c2e45490b020f6b357510d2b1a8afb2b3eedfb1d Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Fri, 28 Jun 2024 22:16:44 +0700 Subject: [PATCH] energy load error handling --- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp index f5ce161..d9f230c 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp @@ -84,6 +84,9 @@ void CurrentTransformerCard::saveEnergy(){ } void CurrentTransformerCard::loadEnergy(){ this->fram->read(this->framAddress, (uint8_t*)&this->energy, sizeof(this->energy)); + if (this->energy < 0 || isnan(this->energy)) { + this->energy = 0; + } } void CurrentTransformerCard::setEnergyAutoSave(bool autoSave){