Merge pull request #21 from keyboardio/f/actOnMatrixScan/idle-optimization

actOnMatrixScan: Optimize the idle case
pull/365/head
Jesse Vincent 7 years ago committed by GitHub
commit 899ac39032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -157,23 +157,31 @@ void Model01::readMatrix() {
}
}
void Model01::actOnHalfRow(byte row, byte colState, byte colPrevState, byte startPos) {
if ((colState == colPrevState) && (colState == 0)) {
for (byte col = 0; col < 8; col++) {
handleKeyswitchEvent(Key_NoKey, row, startPos - col, 0);
}
} else {
for (byte col = 0; col < 8; col++) {
uint8_t keyState = (bitRead(colPrevState, col) << 0) |
(bitRead(colState, col) << 1);
handleKeyswitchEvent(Key_NoKey, row, startPos - col, keyState);
}
}
}
void Model01::actOnMatrixScan() {
for (byte row = 0; row < 4; row++) {
for (byte col = 0; col < 8; col++) {
uint8_t colState = leftHandState.rows[row];
uint8_t colPrevState = previousLeftHandState.rows[row];
uint8_t keynum = (row * 8) + (col);
actOnHalfRow(row, colState, colPrevState, 7);
uint8_t keyState = (bitRead(previousLeftHandState.all, keynum) << 0) |
(bitRead(leftHandState.all, keynum) << 1);
handleKeyswitchEvent(Key_NoKey, row, 7 - col, keyState);
colState = rightHandState.rows[row];
colPrevState = previousRightHandState.rows[row];
keyState = (bitRead(previousRightHandState.all, keynum) << 0) |
(bitRead(rightHandState.all, keynum) << 1);
handleKeyswitchEvent(Key_NoKey, row, (15 - col), keyState);
}
actOnHalfRow(row, colState, colPrevState, 15);
}
}

@ -55,6 +55,8 @@ class Model01 {
keydata_t previousRightHandState;
private:
static void actOnHalfRow(byte row, byte colState, byte colPrevState, byte startPos);
static bool isLEDChanged;
static KeyboardioScanner leftHand;
static KeyboardioScanner rightHand;

Loading…
Cancel
Save