summaryrefslogtreecommitdiff
path: root/keyboards/hub16/matrix.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboards/hub16/matrix.c')
-rw-r--r--keyboards/hub16/matrix.c30
1 files changed, 13 insertions, 17 deletions
diff --git a/keyboards/hub16/matrix.c b/keyboards/hub16/matrix.c
index ad77c923be..a0d8314de6 100644
--- a/keyboards/hub16/matrix.c
+++ b/keyboards/hub16/matrix.c
@@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Encoder things
#define SWITCH_1 F7
#define SWITCH_2 D7
-static bool read_encoder_values(matrix_row_t current_matrix[], uint8_t current_row);
+static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current_row);
#ifdef MATRIX_MASKED
extern const matrix_row_t matrix_mask[];
@@ -128,7 +128,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
}
// Unselect row
- unselect_row(current_row);
+ unselect_row(current_row);
return (last_row_value != current_matrix[current_row]);
}
@@ -223,27 +223,23 @@ uint8_t matrix_scan(void) {
debounce(raw_matrix, matrix, MATRIX_ROWS, changed);
// Read encoder switches, already debounced
- changed |= read_encoder_values(matrix, 4);
+ changed |= read_encoder_switches(matrix, 4);
matrix_scan_quantum();
return (uint8_t)changed;
}
// Customisations for the encoders
-void matrix_init_kb(void){
+void matrix_init_kb(void) {
setPinInput(SWITCH_1);
setPinInput(SWITCH_2);
}
-void matrix_scan_kb(void){
+void matrix_scan_kb(void) {}
-}
-
-void matrix_print(void){
-
-}
+void matrix_print(void) {}
-static bool read_encoder_values(matrix_row_t current_matrix[], uint8_t current_row) {
+static bool read_encoder_switches(matrix_row_t current_matrix[], uint8_t current_row) {
// Store last value of row prior to reading
matrix_row_t last_row_value = current_matrix[current_row];
@@ -253,18 +249,18 @@ static bool read_encoder_values(matrix_row_t current_matrix[], uint8_t current_r
// Debounce the encoder buttons using a shift register
static uint8_t btn_1_array;
static uint8_t btn_2_array;
- bool btn_1_rising = 0;
- bool btn_2_rising = 0;
+ bool btn_1_pressed = 0;
+ bool btn_2_pressed = 0;
btn_1_array <<= 1;
btn_2_array <<= 1;
btn_1_array |= readPin(SWITCH_1);
btn_2_array |= readPin(SWITCH_2);
- (btn_1_array == 0b01111111) ? (btn_1_rising = 1) : (btn_1_rising = 0);
- (btn_2_array == 0b01111111) ? (btn_2_rising = 1) : (btn_2_rising = 0);
+ (btn_1_array == 0b11111111) ? (btn_1_pressed = 1) : (btn_1_pressed = 0);
+ (btn_2_array == 0b11111111) ? (btn_2_pressed = 1) : (btn_2_pressed = 0);
// Populate the matrix row with the state of the encoder
- current_matrix[current_row] |= btn_1_rising ? (1 << 0) : 0;
- current_matrix[current_row] |= btn_2_rising ? (1 << 1) : 0;
+ current_matrix[current_row] |= btn_1_pressed ? (1 << 0) : 0;
+ current_matrix[current_row] |= btn_2_pressed ? (1 << 1) : 0;
return (last_row_value != current_matrix[current_row]);
} \ No newline at end of file