firmata.js icon indicating copy to clipboard operation
firmata.js copied to clipboard

pwmWrite doesn't allow values > 14 bits on pin numbers < 16

Open soundanalogous opened this issue 8 years ago • 4 comments

For future proofing, we should allow pwm/analog writes of values > 14 bits on pins 0 - 15. Currently higher res writes are only available for pins > 15:

https://github.com/firmata/firmata.js/blob/master/lib/firmata.js#L776-L806

soundanalogous avatar Feb 26 '17 22:02 soundanalogous

I'm certainly all for future proofing—do you have an idea of how we might accomplish this?

rwaldron avatar Mar 22 '17 13:03 rwaldron

I wonder if we could just switch to using EXTENDED_ANALOG for all pins? (I haven't actually looked to see if that's doable)

rwaldron avatar Mar 22 '17 14:03 rwaldron

Switching to EXTENDED_ANALOG is one option. Another is changing line 781 to:

if (pin > 15 || value >= 0x00040000 - 1) {

soundanalogous avatar Mar 22 '17 15:03 soundanalogous

correction (no need for the -1)

if (pin > 15 || value >= 0x00040000) {

soundanalogous avatar Mar 22 '17 16:03 soundanalogous