-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow specifying waveform generator in source code #7800
Conversation
Allows code to explicitly specify which waveform generator it wants, without needing to use one of the 100 IDE menus or adding a `-D` compile-time define. Uses weakrefs to allow for apps to call `enablePhaseLockedWaveform();` within their `setup()` (or anywhere, really) and have the phase locked versions override the default waveform generators automatically. For example: ```` void setup() { // Uncomment following line to use phase-locked waveform generator // enablePhaseLockedWaveform(); Serial.begin(115200); pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output analogWriteRange(1000); } void loop() { analogWrite(LED_BUILTIN, 100); delay(1000); // Wait for a second analogWrite(LED_BUILTIN, 900); delay(2000); // Wait for two seconds (to demonstrate the active low LED) } ```` Also adds an example showing it's use.
@Tech-TX and @dok-net , can you give this a try and make sure I didn't miss a Your existing test apps should work fine, just add or remove a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fade example is nice, both version work and the two .elf
contents apparently show correct linking.
Great job !
@earlephilhower I've created a branch for ease of consumption, that contains my requested changes to your PR: https://github.com/dok-net/arduino-esp8266/tree/pr7800 |
@earlephilhower While I like the simplicity of switching the "modes" that's afforded by your fine PR, I am really concerned that it eats ever more memory:
|
About the new example, I am afraid there's two problems with the use of PolledTimeout. First, in setup, there exists a more proper way to integrate PolledTimeout and yield, I've used it, was discussed in some other PR. Please consider using the template for that. |
Address @dok-net's comments and also remove the _weak/_bound version of startWaveform() since it's invariant of the actual waveform generator.
Thanks for the feedback, @dok-net . Good catch on the dead code. I've thrown in a new push with those changes and which removes the weak/bound bounce for As for the PolledTimeout, the example is just the existing |
I still see one forward declaration that I think is redundant :-) |
@earlephilhower This should be the PolledTimeout template to use for built-in yielding:
|
Is it good to go ? |
I have no changes and know of no problems, so good to go from me... |
Allows code to explicitly specify which waveform generator it wants,
without needing to use one of the 100 IDE menus or adding a
-D
compile-time define.
Uses weakrefs to allow for apps to call
enablePhaseLockedWaveform();
within their
setup()
(or anywhere, really) and have the phase lockedversions override the default waveform generators automatically.
For example:
Also adds an example showing it's use.