adafruit / Adafruit_Seesaw

Arduino library driver for seesaw multi-use chip
93 stars 64 forks source link

NeoPixel::clear() writes more than 32 Bytes to I2C #42

Open unvirtual opened 3 years ago

unvirtual commented 3 years ago

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

Callee:

bool Adafruit_seesaw::write(uint8_t regHigh, uint8_t regLow,
                            uint8_t *buf = NULL, uint8_t num = 0) {
  uint8_t prefix[2];
  prefix[0] = (uint8_t)regHigh;
  prefix[1] = (uint8_t)regLow;

  if (_flow != -1)
    while (!::digitalRead(_flow))
      yield();

  if (!_i2c_dev->write(buf, num, true, prefix, 2)) {
    return false;
  }

  return true;
}
ladyada commented 3 years ago

hihi wanna submit a PR to fix it?

unvirtual commented 3 years ago

See #43

caternuson commented 3 years ago

@unvirtual Can you test this again with the latest release of BusIO: https://github.com/adafruit/Adafruit_BusIO/releases/tag/1.9.0 I wonder if chunkification fixes this?