diff --git a/tasmota/core_esp8266_wiring_pwm.cpp b/tasmota/core_esp8266_wiring_pwm.cpp index f74334e43..d81928a5d 100644 --- a/tasmota/core_esp8266_wiring_pwm.cpp +++ b/tasmota/core_esp8266_wiring_pwm.cpp @@ -48,10 +48,12 @@ extern void __analogWriteFreq(uint32_t freq) { } } + extern void __analogWrite(uint8_t pin, int val) { if (pin > 16) { return; } + uint32_t analogPeriod = microsecondsToClockCycles(1000000UL) / analogFreq; if (val < 0) { val = 0; @@ -80,4 +82,4 @@ extern void analogWriteRange(uint32_t range) __attribute__((weak, alias("__analo }; -#endif // ESP8266 +#endif // ESP8266 diff --git a/tasmota/tasmota_globals.h b/tasmota/tasmota_globals.h index 791896ac3..a4df0c4f7 100644 --- a/tasmota/tasmota_globals.h +++ b/tasmota/tasmota_globals.h @@ -42,6 +42,8 @@ void DomoticzTempHumPressureSensor(float temp, float hum, float baro = -1); char* ToHex_P(const unsigned char * in, size_t insz, char * out, size_t outsz, char inbetween = '\0'); extern "C" void custom_crash_callback(struct rst_info * rst_info, uint32_t stack, uint32_t stack_end); extern "C" void resetPins(); +extern "C" int startWaveformClockCycles(uint8_t pin, uint32_t highCcys, uint32_t lowCcys, + uint32_t runTimeCcys, int8_t alignPhase, uint32_t phaseOffsetCcys, bool autoPwm); #ifdef ESP32 diff --git a/tasmota/xsns_01_counter.ino b/tasmota/xsns_01_counter.ino index 3dfbdfaaf..c3584f111 100644 --- a/tasmota/xsns_01_counter.ino +++ b/tasmota/xsns_01_counter.ino @@ -44,6 +44,9 @@ struct COUNTER { bool any_counter = false; } Counter; +uint32_t last_cycle; +uint32_t cycle_time; + #ifndef ARDUINO_ESP8266_RELEASE_2_3_0 // Fix core 2.5.x ISR not in IRAM Exception void CounterUpdate(uint8_t index) ICACHE_RAM_ATTR; void CounterUpdate1(void) ICACHE_RAM_ATTR; @@ -75,7 +78,40 @@ void CounterUpdate(uint8_t index) Counter.timer_low_high[index] = time; Counter.pin_state ^= (1<