Change Wire.write() return types from void to size_t to be compatible with the Arduino API
This commit is contained in:
parent
6a551bd9ab
commit
6548456957
|
@ -95,27 +95,33 @@ uint8 WireBase::requestFrom(int address, int numBytes) {
|
||||||
return WireBase::requestFrom((uint8)address, numBytes);
|
return WireBase::requestFrom((uint8)address, numBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WireBase::write(uint8 value) {
|
size_t WireBase::write(uint8 value) {
|
||||||
if (tx_buf_idx == BUFFER_LENGTH) {
|
if (tx_buf_idx == BUFFER_LENGTH) {
|
||||||
tx_buf_overflow = true;
|
tx_buf_overflow = true;
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
tx_buf[tx_buf_idx++] = value;
|
tx_buf[tx_buf_idx++] = value;
|
||||||
itc_msg.length++;
|
itc_msg.length++;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WireBase::write(uint8* buf, int len) {
|
size_t WireBase::write(uint8* buf, int len) {
|
||||||
for (uint8 i = 0; i < len; i++) {
|
for (uint8 i = 0; i < len; i++) {
|
||||||
write(buf[i]);
|
if (!write(buf[i]))
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WireBase::write(int value) {
|
|
||||||
write((uint8)value);
|
size_t WireBase::write(int value) {
|
||||||
|
return write((uint8)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WireBase::write(int* buf, int len) {
|
size_t WireBase::write(int* buf, int len) {
|
||||||
write((uint8*)buf, (uint8)len);
|
return write((uint8*)buf, (uint8)len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WireBase::write(char* buf) {
|
void WireBase::write(char* buf) {
|
||||||
|
|
|
@ -108,22 +108,22 @@ public:
|
||||||
/*
|
/*
|
||||||
* Stack up bytes to be sent when transmitting
|
* Stack up bytes to be sent when transmitting
|
||||||
*/
|
*/
|
||||||
void write(uint8);
|
size_t write(uint8);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stack up bytes from the array to be sent when transmitting
|
* Stack up bytes from the array to be sent when transmitting
|
||||||
*/
|
*/
|
||||||
void write(uint8*, int);
|
size_t write(uint8*, int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure that a sending data will only be 8-bit bytes
|
* Ensure that a sending data will only be 8-bit bytes
|
||||||
*/
|
*/
|
||||||
void write(int);
|
size_t write(int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ensure that an array sending data will only be 8-bit bytes
|
* Ensure that an array sending data will only be 8-bit bytes
|
||||||
*/
|
*/
|
||||||
void write(int*, int);
|
size_t write(int*, int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stack up bytes from a string to be sent when transmitting
|
* Stack up bytes from a string to be sent when transmitting
|
||||||
|
|
Loading…
Reference in New Issue