Skip to content
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

_writeResolution, set by analogWriteResolution(), is shared by the DAC and PWM #704

Open
tedtoal opened this issue Jul 22, 2023 · 0 comments

Comments

@tedtoal
Copy link

tedtoal commented Jul 22, 2023

The resolution value _writeResolution, set by analogWriteResolution(), is shared by the DAC and PWM. There is no reason why this needs to be so.

I recommend the following changes to fix this:

28c31,32
< static int _writeResolution = 8;
---
> static int _writeResolution_DAC = 8;
> static int _writeResolution_PWM = 8;
74c78,89
<   _writeResolution = res;
---
>   _writeResolution_DAC = res;
>   _writeResolution_PWM = res;
> }
> 
> void analogWriteResolution_DAC(int res)
> {
>   _writeResolution_DAC = res;
> }
> 
> void analogWriteResolution_PWM(int res)
> {
>   _writeResolution_PWM = res;
207c240
<     value = mapResolution(value, _writeResolution, 10);
---
>     value = mapResolution(value, _writeResolution_DAC, 10);
219c252
<     value = mapResolution(value, _writeResolution, 16);
---
>     value = mapResolution(value, _writeResolution_PWM, 16);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant