|
|
@ -41,9 +41,6 @@ uint8_t twi_uninitialized = 1;
|
|
|
|
Model100Side::Model100Side(byte setAd01) {
|
|
|
|
Model100Side::Model100Side(byte setAd01) {
|
|
|
|
ad01 = setAd01;
|
|
|
|
ad01 = setAd01;
|
|
|
|
addr = SCANNER_I2C_ADDR_BASE | ad01;
|
|
|
|
addr = SCANNER_I2C_ADDR_BASE | ad01;
|
|
|
|
if (twi_uninitialized--) {
|
|
|
|
|
|
|
|
// TODO twi_init();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns the relative controller addresss. The expected range is 0-3
|
|
|
|
// Returns the relative controller addresss. The expected range is 0-3
|
|
|
@ -130,9 +127,10 @@ int Model100Side::readRegister(uint8_t cmd) {
|
|
|
|
uint8_t rxBuffer[1] = {0};
|
|
|
|
uint8_t rxBuffer[1] = {0};
|
|
|
|
|
|
|
|
|
|
|
|
// perform blocking read into buffer
|
|
|
|
// perform blocking read into buffer
|
|
|
|
uint8_t read ; // TODO = twi_readFrom(addr, rxBuffer, ELEMENTS(rxBuffer), true);
|
|
|
|
|
|
|
|
if (read > 0) {
|
|
|
|
Wire.requestFrom(addr, 1); // request 1 byte from the keyscanner
|
|
|
|
return rxBuffer[0];
|
|
|
|
if (Wire.available()) {
|
|
|
|
|
|
|
|
return Wire.read();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -143,19 +141,21 @@ 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() {
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t rxBuffer[5] = {0};
|
|
|
|
uint8_t row_counter = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// perform blocking read into buffer
|
|
|
|
// perform blocking read into buffer
|
|
|
|
uint8_t read ; // TODO = twi_readFrom(addr, rxBuffer, ELEMENTS(rxBuffer), true);
|
|
|
|
uint8_t read = 0;
|
|
|
|
if (rxBuffer[0] == TWI_REPLY_KEYDATA) {
|
|
|
|
Wire.requestFrom(addr, 5); // request 1 byte from the keyscanner
|
|
|
|
keyData.rows[0] = rxBuffer[1];
|
|
|
|
if (Wire.available()) {
|
|
|
|
keyData.rows[1] = rxBuffer[2];
|
|
|
|
read = Wire.read();
|
|
|
|
keyData.rows[2] = rxBuffer[3];
|
|
|
|
if (TWI_REPLY_KEYDATA == read) {
|
|
|
|
keyData.rows[3] = rxBuffer[4];
|
|
|
|
|
|
|
|
|
|
|
|
while (Wire.available()) {
|
|
|
|
|
|
|
|
keyData.rows[row_counter++] = Wire.read();
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
keydata_t Model100Side::getKeyData() {
|
|
|
|
keydata_t Model100Side::getKeyData() {
|
|
|
|