From 199a89a700f00d09b3cea2f5175ce07940b6d175 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 25 Mar 2024 14:16:15 +0700 Subject: [PATCH] move ct conversion counter --- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp | 2 +- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.hpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp index b0ea648..f5ce161 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.cpp @@ -30,7 +30,7 @@ void CurrentTransformerCard::loop() if (this->lastConversionTime == 0) { this->lastConversionTime = millis(); } - static uint32_t lastConversionLoopTime = 0; + if (millis() - lastConversionLoopTime > this->conversionInterval) { this->beginConversion(); lastConversionLoopTime = millis(); diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.hpp index 9dfa44a..708a3f9 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/CurrentTransformerCard.hpp @@ -46,5 +46,6 @@ class CurrentTransformerCard : public ExpansionCard std::function adcToCurrent; // std::function that convert adc value to current in amps uint8_t handler_count = 0; std::map> callbacks; + uint32_t lastConversionLoopTime; };