-
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
analogWrite changed values which are not max or min aren't updated to the output #5034
Comments
@EricMc1289 please supply a MCVE, I cannot reproduce any problem with my own testing.
You can see the 3 different periods in the captured logic analyzer output: Code inspection doesn't show anything, either. setWaveform just sets the value that will be applied on the next cycle, and that's straight-line code. |
I just upgrade to 2.4.2 from 2.3.0 and and meet with similar issue. |
@gislf That is actually a different issue than what @EricMc1289 was saying. GPIO6-11 are used for the flash interface normally. Looks like you have some board that only uses a 2x wide irom interface, not a 4x. I didn't think any existed in the wild, and therefore GPIO9 and 10 are not allowed to be PWM'd (to save memory). Could you open a new issue with this so we can track it? The fix is trivial, but I'd like to track it... |
@earlephilhower Thank you for the quick response! Yes ESP8285 has build in flash, so additional GPIO pins are available. May be it’s a good idea to enable these pin for PWM on ESP8285. The board I use is ESP -01M which has 11 GPIO. https://www.elecrow.com/download/esp_01m_datasheet_en.pdf |
To put this in an MCVE is quite hard, because it is a bigger framework and normaly the mode changes by http request. But hopefully this will show the issue. So this is the sample file:
and the colors.h:
Normally i would trigger the mode change with an http request by the httpserver. In 2.4.1 it works as seen above. With Version 2.4.2. it only works if I change the |
@EricMc1289 The code snippet is still missing bits and can't compile. Just make a new sketch that compiles and runs for you, and shows the error, and then I can look at it. Right now it looks like it ends up looking exactly like my simple test case which passes, with the exception that you set 3 pins, and not 1. I've rerun the code w/3 pins and it still runs fine, so w/o a working MCVE there's nothing I can do:
|
Another idea: Add |
Also tried the edge cases, still looks fine on my tests:
|
It's been 3 weeks without any response from the original author, and nobody else seems to have had this problem (or at least they haven't reported it here), so I'm going to close this as a can't reproduce. The other one, the 8285 extra pins, is being tracked in a separate bug. |
@earlephilhower
Hi, maybe there is a bug in the pwm function of analogWrite with the latest changes. I have testet 2.4.2 and latest git. If you try to set 3 pwm channels at once like in the function below to set the rgb color of a LED Stripe, you wont get every color updated correctly.
The configuration of the pwm is as follows for both functions:
There was a very strange behaviour: F.E. if i got to the color yellow direktly (r=255, g=150, b=0) there was only red LEDs on but when i switched from green (r=0, g=255,b=0) to yellow it seems to work but with (g=255). From my research of this behavior i think there is a problem with updating the values, when they are not min or max. If you update to min or max it works but if you update within the range of the pwm, so if the old value is not 0 or 255, in my case , it will not update the output.
While testing and trying to fix that i found the following solution by changing my function a littlebit:
These changes are a very quick and dirty patch and now it works like a charm. So I assume there is somewhere a bug in updating the pwm values for an existing waveform object.
The text was updated successfully, but these errors were encountered: