Skip to content

Commit 90a246b

Browse files
committed
hotfix for https://forums.adafruit.com/viewtopic.php?f=47&t=171641 (this library is going to get refactored anyways and all this code will move out)
1 parent 2f93b84 commit 90a246b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Adafruit_SSD1306.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@
5757
// SOME DEFINES AND STATIC VARIABLES USED INTERNALLY -----------------------
5858

5959
#if defined(I2C_BUFFER_LENGTH)
60-
#define WIRE_MAX I2C_BUFFER_LENGTH ///< Particle or similar Wire lib
60+
#define WIRE_MAX min(256, I2C_BUFFER_LENGTH) ///< Particle or similar Wire lib
6161
#elif defined(BUFFER_LENGTH)
62-
#define WIRE_MAX BUFFER_LENGTH ///< AVR or similar Wire lib
62+
#define WIRE_MAX min(256, BUFFER_LENGTH) ///< AVR or similar Wire lib
6363
#elif defined(SERIAL_BUFFER_SIZE)
64-
#define WIRE_MAX (SERIAL_BUFFER_SIZE - 1) ///< Newer Wire uses RingBuffer
64+
#define WIRE_MAX min(255, SERIAL_BUFFER_SIZE - 1) ///< Newer Wire uses RingBuffer
6565
#else
6666
#define WIRE_MAX 32 ///< Use common Arduino core default
6767
#endif
@@ -387,7 +387,7 @@ void Adafruit_SSD1306::ssd1306_commandList(const uint8_t *c, uint8_t n) {
387387
if (wire) { // I2C
388388
wire->beginTransmission(i2caddr);
389389
WIRE_WRITE((uint8_t)0x00); // Co = 0, D/C = 0
390-
uint8_t bytesOut = 1;
390+
uint16_t bytesOut = 1;
391391
while (n--) {
392392
if (bytesOut >= WIRE_MAX) {
393393
wire->endTransmission();
@@ -946,7 +946,7 @@ void Adafruit_SSD1306::display(void) {
946946
if (wire) { // I2C
947947
wire->beginTransmission(i2caddr);
948948
WIRE_WRITE((uint8_t)0x40);
949-
uint8_t bytesOut = 1;
949+
uint16_t bytesOut = 1;
950950
while (count--) {
951951
if (bytesOut >= WIRE_MAX) {
952952
wire->endTransmission();

0 commit comments

Comments
 (0)