List the steps to reproduce the problem below (if possible attach a sketch or
copy the sketch code in too):
Call seesaw_NeoPixel.clear() with DEBUG_SERIAL enabled
Neopixel is not updated and the following error is printed:
I2CDevice could not write such a large buffer
Root cause:
The reason seems to be, that Neopixel::clear() calls Adafruit_seesaw::write(SEESAW_NEOPIXEL_BASE, SEESAW_NEOPIXEL_BUF, writeBuf, 32) with a size of 32 bytes, while seesaw::write() then prepends a prefix of size prefix_len=2 bytes for a total of 34 bytes.
Fix:
write at most 30 bytes in Adafruit_seesaw::write() from Neopixel::clear().
(Interestingly the offset is correctly calculated to make space for 4 Bytes of prefix + offsets).
Caller:
void seesaw_NeoPixel::clear() {
// Clear local pixel buffer
memset(pixels, 0, numBytes);
// Now clear the pixels on the seesaw
uint8_t writeBuf[32];
memset(writeBuf, 0, 32);
for(uint8_t offset = 0; offset < numBytes; offset += 32-4) {
writeBuf[0] = (offset >> 8);
writeBuf[1] = offset;
this->write(SEESAW_NEOPIXEL_BASE, SEESAW_NEOPIXEL_BUF, writeBuf, 32);
}
}
List the steps to reproduce the problem below (if possible attach a sketch or copy the sketch code in too):
Call
seesaw_NeoPixel.clear()
withDEBUG_SERIAL
enabledNeopixel is not updated and the following error is printed:
I2CDevice could not write such a large buffer
Root cause:
Neopixel::clear()
callsAdafruit_seesaw::write(SEESAW_NEOPIXEL_BASE, SEESAW_NEOPIXEL_BUF, writeBuf, 32)
with a size of 32 bytes, whileseesaw::write()
then prepends a prefix of sizeprefix_len=2
bytes for a total of 34 bytes.Fix:
Adafruit_seesaw::write()
fromNeopixel::clear()
. (Interestingly the offset is correctly calculated to make space for 4 Bytes of prefix + offsets).Caller:
Callee: