|
|
|
@ -115,7 +115,7 @@ bool Model100Side::isDeviceAvailable() {
|
|
|
|
|
|
|
|
|
|
// if the time to check counter is 1, check for the device
|
|
|
|
|
|
|
|
|
|
else if ( --unavailable_device_check_countdown_ == 0 ) {
|
|
|
|
|
else if (--unavailable_device_check_countdown_ == 0) {
|
|
|
|
|
uint8_t wire_result;
|
|
|
|
|
Wire.beginTransmission(addr);
|
|
|
|
|
wire_result = Wire.endTransmission();
|
|
|
|
@ -124,7 +124,7 @@ bool Model100Side::isDeviceAvailable() {
|
|
|
|
|
unavailable_device_check_countdown_ = 0; // TODO this is already true
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
Wire.beginTransmission (wire_result);
|
|
|
|
|
Wire.beginTransmission(wire_result);
|
|
|
|
|
wire_result = Wire.endTransmission();
|
|
|
|
|
|
|
|
|
|
// set the time to check counter to max
|
|
|
|
@ -143,13 +143,15 @@ void Model100Side::markDeviceUnavailable() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t Model100Side::writeData(uint8_t *data, uint8_t length) {
|
|
|
|
|
if (isDeviceAvailable() == false ) {
|
|
|
|
|
if (isDeviceAvailable() == false) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
Wire.beginTransmission(addr);
|
|
|
|
|
Wire.write(data, length);
|
|
|
|
|
uint8_t result = Wire.endTransmission();
|
|
|
|
|
if (result) { markDeviceUnavailable(); }
|
|
|
|
|
if (result) {
|
|
|
|
|
markDeviceUnavailable();
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -185,14 +187,14 @@ int Model100Side::readRegister(uint8_t cmd) {
|
|
|
|
|
|
|
|
|
|
// gives information on the key that was just pressed or released.
|
|
|
|
|
bool Model100Side::readKeys() {
|
|
|
|
|
if (isDeviceAvailable() == false ) {
|
|
|
|
|
if (isDeviceAvailable() == false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t row_counter = 0;
|
|
|
|
|
// perform blocking read into buffer
|
|
|
|
|
uint8_t read = 0;
|
|
|
|
|
uint8_t bytes_returned =0;
|
|
|
|
|
uint8_t bytes_returned = 0;
|
|
|
|
|
bytes_returned = Wire.requestFrom(addr, 5); // request 5 bytes from the keyscanner
|
|
|
|
|
if (bytes_returned < 5) {
|
|
|
|
|
return false;
|
|
|
|
|