From 52b8d216cc69bfcd69049c7140d6a2378cc7d471 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 26 Jan 2016 23:31:03 -0800 Subject: [PATCH] Broken initial implementation of passing the previous key matrix state by reference --- KeyboardConfig.cpp | 18 ++++++++---------- KeyboardConfig.h | 4 ++-- KeyboardioFirmware.ino | 4 ++-- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/KeyboardConfig.cpp b/KeyboardConfig.cpp index 68207380..32cb6434 100644 --- a/KeyboardConfig.cpp +++ b/KeyboardConfig.cpp @@ -54,35 +54,33 @@ void implementation_finish_scanning_row(byte row) { rightsx1509.updatePinState(right_rowpins[row], HIGH); } -uint8_t implementation_scan_left_col(byte row, byte col,uint8_t state) { +void implementation_scan_left_col(byte row, byte col,uint8_t *state) { //If we see an electrical connection on I->J, - state <<= 1; + *state <<= 1; if (left_initted && leftsx1509.readPrefetchedPin(left_colpins[col])) { - state |= 0; + *state |= 0; } else { - state |= 1; + *state |= 1; } - return state; } -uint8_t implementation_scan_right_col(byte row, byte col, uint8_t state) { +void implementation_scan_right_col(byte row, byte col, uint8_t *state) { //If we see an electrical connection on I->J, - state <<= 1; + *state <<= 1; if (right_initted && rightsx1509.readPrefetchedPin(right_colpins[col])) { - state |= 0; + *state |= 0; } else { - state |= 1; + *state |= 1; } - return state; } diff --git a/KeyboardConfig.h b/KeyboardConfig.h index eb21a52e..43d8959d 100644 --- a/KeyboardConfig.h +++ b/KeyboardConfig.h @@ -29,8 +29,8 @@ static uint8_t right_rowpins[]= {8,9,10,11}; void implementation_scan_row(byte row); void implementation_finish_scanning_row(byte row); -uint8_t implementation_scan_right_col(byte row, byte col, uint8_t state); -uint8_t implementation_scan_left_col(byte row, byte col, uint8_t state); +void implementation_scan_right_col(byte row, byte col, uint8_t *state); +void implementation_scan_left_col(byte row, byte col, uint8_t *state); void implementation_pins_setup(); void make_input(sx1509Class sx1509, uint8_t pin) ; void make_output(sx1509Class sx1509, uint8_t pin) ; diff --git a/KeyboardioFirmware.ino b/KeyboardioFirmware.ino index 447d854f..e3fbab69 100644 --- a/KeyboardioFirmware.ino +++ b/KeyboardioFirmware.ino @@ -17,8 +17,8 @@ void scan_matrix() { implementation_scan_row(row); for (byte col = 0; col < LEFT_COLS; col++) { - matrixState[row][col] = implementation_scan_left_col(row,col,matrixState[row][col]); - matrixState[row][(COLS - 1) - col] = implementation_scan_right_col(row,col,matrixState[row][(COLS - 1) - col]); + implementation_scan_left_col(row,col,&matrixState[row][col]); + implementation_scan_right_col(row,col,&matrixState[row][(COLS - 1) - col]); handle_key_event(row, col);