From c418608c1e81fea9987e8faf1d24ecc41bd72c13 Mon Sep 17 00:00:00 2001 From: MechMerlin <30334081+mechmerlin@users.noreply.github.com> Date: Fri, 6 Jul 2018 17:45:07 -0700 Subject: True AL1 Support (#3330) * Initial port of AL1 Keyboard from Triangle Labs * Change REPLACE WITH YOUR NAME and some readme changes * More readme change to indicate Group Buy Link * Give Triangle Lab credit * remove pins from config.h and rely on matrix.c * Add QMK Configurator support --- keyboards/al1/matrix.c | 184 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 keyboards/al1/matrix.c (limited to 'keyboards/al1/matrix.c') diff --git a/keyboards/al1/matrix.c b/keyboards/al1/matrix.c new file mode 100644 index 000000000..f7ed7fbb0 --- /dev/null +++ b/keyboards/al1/matrix.c @@ -0,0 +1,184 @@ +#include +#include +#include +#include +#include "print.h" +#include "debug.h" +#include "util.h" +#include "matrix.h" + +#ifndef DEBOUNCING_DELAY +# define DEBOUNCING_DELAY 5 +#endif +static uint8_t debouncing = DEBOUNCING_DELAY; + +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; + +static uint8_t read_rows(void); +static void init_rows(void); +static void unselect_cols(void); +static void select_col(uint8_t col); + +inline uint8_t matrix_rows(void) { + return MATRIX_ROWS; +} + +inline uint8_t matrix_cols(void) { + return MATRIX_COLS; +} + + +void matrix_init(void) { + // initialize row and col + unselect_cols(); + init_rows(); + + // initialize matrix state: all keys off + for (uint8_t i=0; i < MATRIX_ROWS; i++) { + matrix[i] = 0; + matrix_debouncing[i] = 0; + } + matrix_init_quantum(); +} + +uint8_t matrix_scan(void) { + for (uint8_t col = 0; col < MATRIX_COLS; col++) { + select_col(col); + _delay_us(3); + uint8_t rows = read_rows(); + for (uint8_t row = 0; row < MATRIX_ROWS; row++) { + bool prev_bit = matrix_debouncing[row] & ((matrix_row_t)1<