From a7ff972c5ad809877ba9955acca62eb541cd783f Mon Sep 17 00:00:00 2001 From: Karolis Stasaitis Date: Sat, 30 Dec 2023 20:49:16 +0100 Subject: [PATCH] fixed wrong keycode issue by moving col comparison values to xdata --- Makefile | 4 +++- src/matrix.c | 14 ++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 8ed08df..9abb765 100644 --- a/Makefile +++ b/Makefile @@ -23,12 +23,14 @@ SMK_VERSION ?= alpha USB_VID ?= 0x05ac USB_PID ?= 0x024f +DEBUG ?= 1 + CFLAGS := -V -mmcs51 --model-small \ --xram-size $(XRAM_SIZE) --xram-loc $(XRAM_LOC) \ --code-size $(CODE_SIZE) \ --std-c2x \ -I$(ROOT_DIR)../include \ - -DDEBUG=1 \ + -DDEBUG=$(DEBUG) \ -DFREQ_SYS=$(FREQ_SYS) \ -DWATCHDOG_ENABLE=1 \ -DUSB_VID=$(USB_VID) \ diff --git a/src/matrix.c b/src/matrix.c index 72041e9..050c95e 100644 --- a/src/matrix.c +++ b/src/matrix.c @@ -118,7 +118,7 @@ uint8_t matrix_task() return false; } - bool matrix_changed = false; + __xdata bool matrix_changed = false; for (uint8_t col = 0; col < MATRIX_COLS && !matrix_changed; col++) { matrix_changed |= matrix_previous[col] ^ matrix_get_col(col); @@ -131,25 +131,23 @@ uint8_t matrix_task() } for (uint8_t col = 0; col < MATRIX_COLS; col++) { - const matrix_col_t current_col = matrix_get_col(col); - const matrix_col_t col_changes = matrix_get_col(col) ^ matrix_previous[col]; + __xdata const matrix_col_t current_col = matrix_get_col(col); + __xdata const matrix_col_t col_changes = current_col ^ matrix_previous[col]; if (!col_changes) { continue; } - matrix_col_t row_mask = 1; + __xdata matrix_col_t row_mask = 1; - for (uint8_t row = 0; row < MATRIX_COLS; row++, row_mask <<= 1) { + for (uint8_t row = 0; row < MATRIX_ROWS; row++, row_mask <<= 1) { if (col_changes & row_mask) { - const bool key_pressed = current_col & row_mask; + __xdata const bool key_pressed = current_col & row_mask; process_key_state(row, col, key_pressed); } } - // send_keyboard_report(); - matrix_previous[col] = current_col; }