energy load error handling

This commit is contained in:
Siwat Sirichai 2024-06-28 22:16:44 +07:00
parent 8aeb6ab30a
commit c2e45490b0
1 changed files with 3 additions and 0 deletions

View File

@ -84,6 +84,9 @@ void CurrentTransformerCard::saveEnergy(){
} }
void CurrentTransformerCard::loadEnergy(){ void CurrentTransformerCard::loadEnergy(){
this->fram->read(this->framAddress, (uint8_t*)&this->energy, sizeof(this->energy)); 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){ void CurrentTransformerCard::setEnergyAutoSave(bool autoSave){