17 lines
474 B
C++
17 lines
474 B
C++
|
#include <I2CCommunicator.h>
|
||
|
#include <Wire.h>
|
||
|
|
||
|
I2CCommunicator::I2CCommunicator(TwoWire &w_out, int slaveAddr, int timeout) : StreamCommunicator(w_out)
|
||
|
{
|
||
|
w_out.begin();
|
||
|
w_out.setTimeout(timeout);
|
||
|
this->slaveAddr = slaveAddr;
|
||
|
}
|
||
|
|
||
|
void I2CCommunicator::sendMessage(const char message[])
|
||
|
{
|
||
|
TwoWire *foo = static_cast<TwoWire *>(&stream);
|
||
|
foo->beginTransmission(slaveAddr);
|
||
|
StreamCommunicator::sendMessage(message);
|
||
|
foo->endTransmission(slaveAddr);
|
||
|
}
|