Skip to content

Commit 1fea77c

Browse files
committed
fix build
1 parent 359804b commit 1fea77c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

PCF8574.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010

1111
#include "PCF8574.h"
1212

13-
const int I2C_BUFFER_LENGTH = 30; // AVR limit - 1 for address
13+
#ifndef I2C_BUFFER_LENGTH
14+
#define I2C_BUFFER_LENGTH (32)
15+
#endif
1416

1517

1618
PCF8574::PCF8574(const uint8_t deviceAddress, TwoWire *wire)
@@ -98,7 +100,7 @@ void PCF8574::write(const uint8_t pin, const uint8_t value)
98100
// experimental 0.4.4
99101
bool PCF8574::writeArray(uint8_t *array, uint8_t size)
100102
{
101-
if (size > I2C_BUFFER_LENGTH)
103+
if (size > (I2C_BUFFER_LENGTH - 1))
102104
{
103105
_error = PCF8574_BUFFER_LENGTH_ERROR;
104106
return false;
@@ -117,7 +119,7 @@ bool PCF8574::writeArray(uint8_t *array, uint8_t size)
117119

118120
bool PCF8574::readArray(uint8_t *array, uint8_t size)
119121
{
120-
if (size > I2C_BUFFER_LENGTH)
122+
if (size > (I2C_BUFFER_LENGTH - 1))
121123
{
122124
_error = PCF8574_BUFFER_LENGTH_ERROR;
123125
return false;

0 commit comments

Comments
 (0)