Draft: Support PWM phase shifts on ESP8266 #4165
Open
+535
−735
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Use the phase-locked soft PWM from the Arduino core to implement the same PWM phase output as ESP32s are using. The soft PWM code is vendored in, as it was previously, to add the NMI workaround from #4035. Testing revealed a need for additional tweaks to support adjusting relative signal phase without a stop/restart cycle (which interlocks with the NMI twice) so I've added that here too.
Completes #4034.
This PR includes a logic change that also affects ESP32:
I've tested this with an ESP8266 and an ESP32-WROVER using a scope to check for regressions. Additional testing would be greatly appreciated.
Finally: while this code does its best replicate the 2-channel CW/WW output pattern intended for H-bridge usage, I still wouldn't recommend using one with ESP8266. There isn't (currently) a way to atomically update several pins phase at once, leading to the possibility of overlap while an update is being applied.