move ct conversion counter

This commit is contained in:
Siwat Sirichai 2024-03-25 14:16:15 +07:00
parent 3a9488d4f8
commit 199a89a700
2 changed files with 2 additions and 1 deletions

View File

@ -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();

View File

@ -46,5 +46,6 @@ class CurrentTransformerCard : public ExpansionCard
std::function<float(uint16_t)> adcToCurrent; // std::function that convert adc value to current in amps
uint8_t handler_count = 0;
std::map<uint8_t,std::function<void(float, double)>> callbacks;
uint32_t lastConversionLoopTime;
};