Skip to content

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

Open
@tedtoal

Description

@tedtoal

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions