From 8378338ed8492633dc8be26083d9c0c520b736d1 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Sat, 10 Feb 2024 16:36:59 +0700 Subject: [PATCH] change energy length --- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformer.cpp | 8 ++++---- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformer.hpp | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformer.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformer.cpp index 5378f07..8b581f4 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformer.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformer.cpp @@ -60,12 +60,12 @@ float CurrentTransformer::getCurrent() return this->current; } -long double CurrentTransformer::getEnergy() +double CurrentTransformer::getEnergy() { return this->energy; } -uint8_t CurrentTransformer::registerCallback(std::function callback) { +uint8_t CurrentTransformer::registerCallback(std::function callback) { this->callbacks[this->handler_count] = callback; return this->handler_count++; } @@ -74,10 +74,10 @@ void CurrentTransformer::unregisterCallback(uint8_t handler) { } void CurrentTransformer::saveEnergy(){ - this->fram->write(this->framAddress, (uint8_t*)&this->energy, 16); + this->fram->write(this->framAddress, (uint8_t*)&this->energy, sizeof(this->energy)); } void CurrentTransformer::loadEnergy(){ - this->fram->read(this->framAddress, (uint8_t*)&this->energy, 16); + this->fram->read(this->framAddress, (uint8_t*)&this->energy, sizeof(this->energy)); } void CurrentTransformer::setEnergyAutoSave(bool autoSave){ diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformer.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformer.hpp index fdd5c8d..e449a08 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformer.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformer.hpp @@ -25,7 +25,7 @@ class CurrentTransformer void loadEnergy(); void setEnergyAutoSave(bool autoSave); float getVoltage(); - uint8_t registerCallback(std::function callback); + uint8_t registerCallback(std::function callback); void unregisterCallback(uint8_t handler); private: AnalogCard* analogCard; @@ -35,12 +35,12 @@ class CurrentTransformer uint32_t conversionInterval; bool autoSave; float calibration; - long double energy; + double energy; float current; float *voltage; uint32_t lastConversionTime; std::function adcToCurrent; // std::function that convert adc value to current in amps uint8_t handler_count = 0; - std::map> callbacks; + std::map> callbacks; };