NeoPixelBus
NeoPixelBus copied to clipboard
NeoEspBitBangMethod does not work for pin numbers greater than 31
Describe the bug Using NeoEspBitBangMethods with PIN numbers greater than 31 does not work.
In NeoEspBitBangMethod.cpp the method neoEspBitBangWriteSpacingPixels has two issues:
At lines 104 and 105 should be:
uint32_t setValue = _BV(pin % 32);
uint32_t clearValue = _BV(pin % 32);
and at line 119 should be something like:
volatile uint32_t* setRegister;
volatile uint32_t* clearRegister;
if (pin < 32) {
setRegister = &GPIO.out_w1ts;
clearRegister = &GPIO.out_w1tc;
}
else {
setRegister = &GPIO.out1_w1ts.val;
clearRegister = &GPIO.out1_w1tc.val;
}
This will generate the correct bit masks and choose the correct registers for pins greater than 31.
(I ran into this on an Adafruit Esp32 QT Py where the internal NeoPixel is on pin 39).