f/keyboardio-model-100
Jesse Vincent 3 years ago
parent b44edf476b
commit 9d9b16dc93
No known key found for this signature in database
GPG Key ID: 122F5DF7108E4046

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

Loading…
Cancel
Save