From 6bd4edcdae34b57aa349b87b7085b9c7942c6339 Mon Sep 17 00:00:00 2001 From: stefanbode Date: Fri, 3 Jul 2020 09:01:02 +0200 Subject: [PATCH] Update xsns_01_counter.ino --- tasmota/xsns_01_counter.ino | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index 18f1ed461..c3584f111 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -99,7 +99,11 @@ void CounterUpdate(uint8_t index) uint32_t steps = (current_cycle-last_cycle+100000)/(clockCyclesPerMicrosecond() * 10000); cycle_time = (current_cycle-last_cycle)/steps; #ifdef ESP8266 - analogWriteCCyPeriod(Pin(GPIO_PWM1, index), 5, cycle_time ); + pinMode(Pin(GPIO_PWM1, index), OUTPUT); + uint32_t high = (cycle_time * 5) / 1023; + uint32_t low = cycle_time - high; + // Find the first GPIO being generated by checking GCC's find-first-set (returns 1 + the bit of the first 1 in an int32_t + startWaveformClockCycles(Pin(GPIO_PWM1, index), high, low, 0, -1, 0, true); #else analogWrite(Pin(GPIO_PWM1, index), 5); #endif