From b2f388fd3c5609c64a80fad1ccb6bc77685fde7f Mon Sep 17 00:00:00 2001 From: Islam Sharabash Date: Fri, 20 Aug 2021 13:56:19 -0700 Subject: [PATCH] Use matrix lite for dygma raise --- .../dygma/raise/{ => ansi}/info.json | 0 keyboards/handwired/dygma/raise/iso/info.json | 1117 +++++++++++++++++ keyboards/handwired/dygma/raise/matrix.c | 57 +- keyboards/handwired/dygma/raise/rules.mk | 2 +- 4 files changed, 1131 insertions(+), 45 deletions(-) rename keyboards/handwired/dygma/raise/{ => ansi}/info.json (100%) create mode 100644 keyboards/handwired/dygma/raise/iso/info.json diff --git a/keyboards/handwired/dygma/raise/info.json b/keyboards/handwired/dygma/raise/ansi/info.json similarity index 100% rename from keyboards/handwired/dygma/raise/info.json rename to keyboards/handwired/dygma/raise/ansi/info.json diff --git a/keyboards/handwired/dygma/raise/iso/info.json b/keyboards/handwired/dygma/raise/iso/info.json new file mode 100644 index 00000000000..3a0c673f093 --- /dev/null +++ b/keyboards/handwired/dygma/raise/iso/info.json @@ -0,0 +1,1117 @@ +{ + "keyboard_name": "Dygma Raise", + "url": "https://github.com/qmk/qmk_firmware/tree/master/keyboards/dygma/raise", + "maintainer": "ibash", + "width": 16.75, + "height": 6, + "layouts": { + "LAYOUT_all": { + "layout": [ + { + "label": "esc", + "x": 0, + "y": 0 + }, + { + "label": "1", + "x": 1, + "y": 0 + }, + { + "label": "2", + "x": 2, + "y": 0 + }, + { + "label": "3", + "x": 3, + "y": 0 + }, + { + "label": "4", + "x": 4, + "y": 0 + }, + { + "label": "5", + "x": 5, + "y": 0 + }, + { + "label": "6", + "x": 6, + "y": 0 + }, + { + "label": "7", + "x": 8.75, + "y": 0 + }, + { + "label": "8", + "x": 9.75, + "y": 0 + }, + { + "label": "9", + "x": 10.75, + "y": 0 + }, + { + "label": "0", + "x": 11.75, + "y": 0 + }, + { + "label": "-", + "x": 12.75, + "y": 0 + }, + { + "label": "+", + "x": 13.75, + "y": 0 + }, + { + "label": "backspace", + "w": 2, + "x": 14.75, + "y": 0 + }, + { + "label": "tab", + "w": 1.5, + "x": 0, + "y": 1 + }, + { + "label": "Q", + "x": 1.5, + "y": 1 + }, + { + "label": "W", + "x": 2.5, + "y": 1 + }, + { + "label": "E", + "x": 3.5, + "y": 1 + }, + { + "label": "R", + "x": 4.5, + "y": 1 + }, + { + "label": "T", + "x": 5.5, + "y": 1 + }, + { + "label": "Y", + "x": 8.25, + "y": 1 + }, + { + "label": "U", + "x": 9.25, + "y": 1 + }, + { + "label": "I", + "x": 10.25, + "y": 1 + }, + { + "label": "O", + "x": 11.25, + "y": 1 + }, + { + "label": "P", + "x": 12.25, + "y": 1 + }, + { + "label": "[", + "x": 13.25, + "y": 1 + }, + { + "label": "]", + "x": 14.25, + "y": 1 + }, + { + "label": "enter", + "h": 2, + "w": 1.25, + "x": 15.5, + "y": 1 + }, + { + "label": "caps", + "w": 1.75, + "x": 0, + "y": 2 + }, + { + "label": "A", + "x": 1.75, + "y": 2 + }, + { + "label": "S", + "x": 2.75, + "y": 2 + }, + { + "label": "D", + "x": 3.75, + "y": 2 + }, + { + "label": "F", + "x": 4.75, + "y": 2 + }, + { + "label": "G", + "x": 5.75, + "y": 2 + }, + { + "label": "H", + "x": 8.5, + "y": 2 + }, + { + "label": "J", + "x": 9.5, + "y": 2 + }, + { + "label": "K", + "x": 10.5, + "y": 2 + }, + { + "label": "L", + "x": 11.5, + "y": 2 + }, + { + "label": ";", + "x": 12.5, + "y": 2 + }, + { + "label": "'", + "x": 13.5, + "y": 2 + }, + { + "label": "#", + "x": 14.5, + "y": 2 + }, + { + "label": "shift", + "w": 1.25, + "x": 0, + "y": 3 + }, + { + "label": "\\", + "x": 1.25, + "y": 3 + }, + { + "label": "Z", + "x": 2.25, + "y": 3 + }, + { + "label": "X", + "x": 3.25, + "y": 3 + }, + { + "label": "C", + "x": 4.25, + "y": 3 + }, + { + "label": "V", + "x": 5.25, + "y": 3 + }, + { + "label": "B", + "x": 6.25, + "y": 3 + }, + { + "label": "N", + "x": 9, + "y": 3 + }, + { + "label": "M", + "x": 10, + "y": 3 + }, + { + "label": ",", + "x": 11, + "y": 3 + }, + { + "label": ".", + "x": 12, + "y": 3 + }, + { + "label": "/", + "x": 13, + "y": 3 + }, + { + "label": "shift", + "w": 2.75, + "x": 14, + "y": 3 + }, + { + "label": "ctrl", + "w": 1.25, + "x": 0, + "y": 4 + }, + { + "label": "os", + "w": 1.25, + "x": 1.25, + "y": 4 + }, + { + "label": "alt", + "w": 1.25, + "x": 2.5, + "y": 4 + }, + { + "label": "...", + "w": 1.5, + "x": 3.75, + "y": 4 + }, + { + "label": "\u2014", + "w": 1.5, + "x": 5.25, + "y": 4 + }, + { + "label": "\u2014", + "w": 1.5, + "x": 8.75, + "y": 4 + }, + { + "label": "...", + "w": 1.5, + "x": 10.25, + "y": 4 + }, + { + "label": "alt", + "w": 1.25, + "x": 11.75, + "y": 4 + }, + { + "label": "fn", + "w": 1.25, + "x": 13, + "y": 4 + }, + { + "label": "os", + "w": 1.25, + "x": 14.25, + "y": 4 + }, + { + "label": "ctrl", + "w": 1.25, + "x": 15.5, + "y": 4 + }, + { + "label": "..", + "w": 1.5, + "x": 3.75, + "y": 5 + }, + { + "label": ".", + "w": 1.5, + "x": 5.25, + "y": 5 + }, + { + "label": ".", + "w": 1.5, + "x": 8.75, + "y": 5 + }, + { + "label": "..", + "w": 1.5, + "x": 10.25, + "y": 5 + } + ] + }, + "LAYOUT_ansi": { + "layout": [ + { + "label": "esc", + "x": 0, + "y": 0 + }, + { + "label": "1", + "x": 1, + "y": 0 + }, + { + "label": "2", + "x": 2, + "y": 0 + }, + { + "label": "3", + "x": 3, + "y": 0 + }, + { + "label": "4", + "x": 4, + "y": 0 + }, + { + "label": "5", + "x": 5, + "y": 0 + }, + { + "label": "6", + "x": 6, + "y": 0 + }, + { + "label": "7", + "x": 8.75, + "y": 0 + }, + { + "label": "8", + "x": 9.75, + "y": 0 + }, + { + "label": "9", + "x": 10.75, + "y": 0 + }, + { + "label": "0", + "x": 11.75, + "y": 0 + }, + { + "label": "-", + "x": 12.75, + "y": 0 + }, + { + "label": "+", + "x": 13.75, + "y": 0 + }, + { + "label": "backspace", + "w": 2, + "x": 14.75, + "y": 0 + }, + { + "label": "tab", + "w": 1.5, + "x": 0, + "y": 1 + }, + { + "label": "Q", + "x": 1.5, + "y": 1 + }, + { + "label": "W", + "x": 2.5, + "y": 1 + }, + { + "label": "E", + "x": 3.5, + "y": 1 + }, + { + "label": "R", + "x": 4.5, + "y": 1 + }, + { + "label": "T", + "x": 5.5, + "y": 1 + }, + { + "label": "Y", + "x": 8.25, + "y": 1 + }, + { + "label": "U", + "x": 9.25, + "y": 1 + }, + { + "label": "I", + "x": 10.25, + "y": 1 + }, + { + "label": "O", + "x": 11.25, + "y": 1 + }, + { + "label": "P", + "x": 12.25, + "y": 1 + }, + { + "label": "{", + "x": 13.25, + "y": 1 + }, + { + "label": "}", + "x": 14.25, + "y": 1 + }, + { + "label": "\\", + "w": 1.5, + "x": 15.25, + "y": 1 + }, + { + "label": "caps", + "w": 1.75, + "x": 0, + "y": 2 + }, + { + "label": "A", + "x": 1.75, + "y": 2 + }, + { + "label": "S", + "x": 2.75, + "y": 2 + }, + { + "label": "D", + "x": 3.75, + "y": 2 + }, + { + "label": "F", + "x": 4.75, + "y": 2 + }, + { + "label": "G", + "x": 5.75, + "y": 2 + }, + { + "label": "H", + "x": 8.5, + "y": 2 + }, + { + "label": "J", + "x": 9.5, + "y": 2 + }, + { + "label": "K", + "x": 10.5, + "y": 2 + }, + { + "label": "L", + "x": 11.5, + "y": 2 + }, + { + "label": ";", + "x": 12.5, + "y": 2 + }, + { + "label": "'", + "x": 13.5, + "y": 2 + }, + { + "label": "enter", + "w": 2.25, + "x": 14.5, + "y": 2 + }, + { + "label": "shift", + "w": 2.25, + "x": 0, + "y": 3 + }, + { + "label": "Z", + "x": 2.25, + "y": 3 + }, + { + "label": "X", + "x": 3.25, + "y": 3 + }, + { + "label": "C", + "x": 4.25, + "y": 3 + }, + { + "label": "V", + "x": 5.25, + "y": 3 + }, + { + "label": "B", + "x": 6.25, + "y": 3 + }, + { + "label": "N", + "x": 9, + "y": 3 + }, + { + "label": "M", + "x": 10, + "y": 3 + }, + { + "label": ",", + "x": 11, + "y": 3 + }, + { + "label": ".", + "x": 12, + "y": 3 + }, + { + "label": "/", + "x": 13, + "y": 3 + }, + { + "label": "shift", + "w": 2.75, + "x": 14, + "y": 3 + }, + { + "label": "ctrl", + "w": 1.25, + "x": 0, + "y": 4 + }, + { + "label": "os", + "w": 1.25, + "x": 1.25, + "y": 4 + }, + { + "label": "alt", + "w": 1.25, + "x": 2.5, + "y": 4 + }, + { + "label": "...", + "w": 1.5, + "x": 3.75, + "y": 4 + }, + { + "label": "\u2014", + "w": 1.5, + "x": 5.25, + "y": 4 + }, + { + "label": "\u2014", + "w": 1.5, + "x": 8.75, + "y": 4 + }, + { + "label": "...", + "w": 1.5, + "x": 10.25, + "y": 4 + }, + { + "label": "alt", + "w": 1.25, + "x": 11.75, + "y": 4 + }, + { + "label": "fn", + "w": 1.25, + "x": 13, + "y": 4 + }, + { + "label": "os", + "w": 1.25, + "x": 14.25, + "y": 4 + }, + { + "label": "ctrl", + "w": 1.25, + "x": 15.5, + "y": 4 + }, + { + "label": "..", + "w": 1.5, + "x": 3.75, + "y": 5 + }, + { + "label": ".", + "w": 1.5, + "x": 5.25, + "y": 5 + }, + { + "label": ".", + "w": 1.5, + "x": 8.75, + "y": 5 + }, + { + "label": "..", + "w": 1.5, + "x": 10.25, + "y": 5 + } + ] + }, + "LAYOUT_iso": { + "layout": [ + { + "label": "esc", + "x": 0, + "y": 0 + }, + { + "label": "1", + "x": 1, + "y": 0 + }, + { + "label": "2", + "x": 2, + "y": 0 + }, + { + "label": "3", + "x": 3, + "y": 0 + }, + { + "label": "4", + "x": 4, + "y": 0 + }, + { + "label": "5", + "x": 5, + "y": 0 + }, + { + "label": "6", + "x": 6, + "y": 0 + }, + { + "label": "7", + "x": 8.75, + "y": 0 + }, + { + "label": "8", + "x": 9.75, + "y": 0 + }, + { + "label": "9", + "x": 10.75, + "y": 0 + }, + { + "label": "0", + "x": 11.75, + "y": 0 + }, + { + "label": "-", + "x": 12.75, + "y": 0 + }, + { + "label": "+", + "x": 13.75, + "y": 0 + }, + { + "label": "backspace", + "w": 2, + "x": 14.75, + "y": 0 + }, + { + "label": "tab", + "w": 1.5, + "x": 0, + "y": 1 + }, + { + "label": "Q", + "x": 1.5, + "y": 1 + }, + { + "label": "W", + "x": 2.5, + "y": 1 + }, + { + "label": "E", + "x": 3.5, + "y": 1 + }, + { + "label": "R", + "x": 4.5, + "y": 1 + }, + { + "label": "T", + "x": 5.5, + "y": 1 + }, + { + "label": "Y", + "x": 8.25, + "y": 1 + }, + { + "label": "U", + "x": 9.25, + "y": 1 + }, + { + "label": "I", + "x": 10.25, + "y": 1 + }, + { + "label": "O", + "x": 11.25, + "y": 1 + }, + { + "label": "P", + "x": 12.25, + "y": 1 + }, + { + "label": "[", + "x": 13.25, + "y": 1 + }, + { + "label": "]", + "x": 14.25, + "y": 1 + }, + { + "label": "enter", + "h": 2, + "w": 1.25, + "x": 15.5, + "y": 1 + }, + { + "label": "caps", + "w": 1.75, + "x": 0, + "y": 2 + }, + { + "label": "A", + "x": 1.75, + "y": 2 + }, + { + "label": "S", + "x": 2.75, + "y": 2 + }, + { + "label": "D", + "x": 3.75, + "y": 2 + }, + { + "label": "F", + "x": 4.75, + "y": 2 + }, + { + "label": "G", + "x": 5.75, + "y": 2 + }, + { + "label": "H", + "x": 8.5, + "y": 2 + }, + { + "label": "J", + "x": 9.5, + "y": 2 + }, + { + "label": "K", + "x": 10.5, + "y": 2 + }, + { + "label": "L", + "x": 11.5, + "y": 2 + }, + { + "label": ";", + "x": 12.5, + "y": 2 + }, + { + "label": "'", + "x": 13.5, + "y": 2 + }, + { + "label": "#", + "x": 14.5, + "y": 2 + }, + { + "label": "shift", + "w": 1.25, + "x": 0, + "y": 3 + }, + { + "label": "\\", + "x": 1.25, + "y": 3 + }, + { + "label": "Z", + "x": 2.25, + "y": 3 + }, + { + "label": "X", + "x": 3.25, + "y": 3 + }, + { + "label": "C", + "x": 4.25, + "y": 3 + }, + { + "label": "V", + "x": 5.25, + "y": 3 + }, + { + "label": "B", + "x": 6.25, + "y": 3 + }, + { + "label": "N", + "x": 9, + "y": 3 + }, + { + "label": "M", + "x": 10, + "y": 3 + }, + { + "label": ",", + "x": 11, + "y": 3 + }, + { + "label": ".", + "x": 12, + "y": 3 + }, + { + "label": "/", + "x": 13, + "y": 3 + }, + { + "label": "shift", + "w": 2.75, + "x": 14, + "y": 3 + }, + { + "label": "ctrl", + "w": 1.25, + "x": 0, + "y": 4 + }, + { + "label": "os", + "w": 1.25, + "x": 1.25, + "y": 4 + }, + { + "label": "alt", + "w": 1.25, + "x": 2.5, + "y": 4 + }, + { + "label": "...", + "w": 1.5, + "x": 3.75, + "y": 4 + }, + { + "label": "\u2014", + "w": 1.5, + "x": 5.25, + "y": 4 + }, + { + "label": "\u2014", + "w": 1.5, + "x": 8.75, + "y": 4 + }, + { + "label": "...", + "w": 1.5, + "x": 10.25, + "y": 4 + }, + { + "label": "alt", + "w": 1.25, + "x": 11.75, + "y": 4 + }, + { + "label": "fn", + "w": 1.25, + "x": 13, + "y": 4 + }, + { + "label": "os", + "w": 1.25, + "x": 14.25, + "y": 4 + }, + { + "label": "ctrl", + "w": 1.25, + "x": 15.5, + "y": 4 + }, + { + "label": "..", + "w": 1.5, + "x": 3.75, + "y": 5 + }, + { + "label": ".", + "w": 1.5, + "x": 5.25, + "y": 5 + }, + { + "label": ".", + "w": 1.5, + "x": 8.75, + "y": 5 + }, + { + "label": "..", + "w": 1.5, + "x": 10.25, + "y": 5 + } + ] + } + } +} diff --git a/keyboards/handwired/dygma/raise/matrix.c b/keyboards/handwired/dygma/raise/matrix.c index dcdbab95fb0..bbcf697a594 100644 --- a/keyboards/handwired/dygma/raise/matrix.c +++ b/keyboards/handwired/dygma/raise/matrix.c @@ -33,25 +33,11 @@ #define MY_I2C_TIMEOUT 10 #define ROWS_PER_HAND (MATRIX_ROWS / 2) -typedef enum { - CHANGED, - OFFLINE, - UNCHANGED -} read_hand_t; +typedef enum { CHANGED, OFFLINE, UNCHANGED } read_hand_t; -static matrix_row_t rows[MATRIX_ROWS]; -static read_hand_t last_state[2] = { OFFLINE, OFFLINE }; +static read_hand_t last_state[2] = {OFFLINE, OFFLINE}; -__attribute__((weak)) void matrix_init_kb(void) { matrix_init_user(); } -__attribute__((weak)) void matrix_scan_kb(void) { matrix_scan_user(); } -__attribute__((weak)) void matrix_init_user(void) {} -__attribute__((weak)) void matrix_scan_user(void) {} - -inline uint8_t matrix_rows(void) { return MATRIX_ROWS; } - -inline uint8_t matrix_cols(void) { return MATRIX_COLS; } - -static read_hand_t i2c_read_hand(int hand) { +static read_hand_t i2c_read_hand(int hand, matrix_row_t current_matrix[]) { // dygma raise firmware says online is true iff we get the number of // expected bytes (e.g. 6 bytes or ROWS_PER_HAND + 1). // In the case where no keys are pressed the keyscanner will send the same 0 @@ -71,8 +57,8 @@ static read_hand_t i2c_read_hand(int hand) { return UNCHANGED; } - int start_row = hand ? ROWS_PER_HAND : 0; - uint8_t *out = &rows[start_row]; + int start_row = hand ? ROWS_PER_HAND : 0; + matrix_row_t *out = ¤t_matrix[start_row]; memcpy(out, &buf[1], ROWS_PER_HAND); return CHANGED; @@ -84,52 +70,35 @@ static int i2c_set_keyscan_interval(int hand, int delay) { return ret; } -void matrix_init(void) { +void matrix_init_custom(void) { i2c_init(); // ref: https://github.com/Dygmalab/Kaleidoscope/blob/7bac53de106c42ffda889e6854abc06cf43a3c6f/src/kaleidoscope/device/dygma/Raise.cpp#L83 // ref: https://github.com/Dygmalab/Kaleidoscope/blob/7bac53de106c42ffda889e6854abc06cf43a3c6f/src/kaleidoscope/device/dygma/raise/Hand.cpp#L73 i2c_set_keyscan_interval(LEFT, 50); i2c_set_keyscan_interval(RIGHT, 50); - memset(rows, 0, sizeof(rows)); - - matrix_init_quantum(); } -uint8_t matrix_scan(void) { +bool matrix_scan_custom(matrix_row_t current_matrix[]) { // HACK(ibash) without the delay between the two calls to i2c_read_hand, the // second call to i2c_read_hand breaks. I observed that the i2s start isn't // sent, or maybe it is, but the address matcher in the attiny can't recognize // it. In any case, a short delay fixes it. - read_hand_t left_state = i2c_read_hand(LEFT); + read_hand_t left_state = i2c_read_hand(LEFT, current_matrix); wait_us(10); - read_hand_t right_state = i2c_read_hand(RIGHT); + read_hand_t right_state = i2c_read_hand(RIGHT, current_matrix); - matrix_scan_quantum(); - if ((last_state[LEFT] == OFFLINE && left_state != OFFLINE) || - (last_state[RIGHT] == OFFLINE && right_state != OFFLINE)) { + if ((last_state[LEFT] == OFFLINE && left_state != OFFLINE) || (last_state[RIGHT] == OFFLINE && right_state != OFFLINE)) { // reinitialize both sides i2c_set_keyscan_interval(LEFT, 50); i2c_set_keyscan_interval(RIGHT, 50); } - last_state[LEFT] = left_state; + last_state[LEFT] = left_state; last_state[RIGHT] = right_state; - bool changed = left_state == CHANGED || right_state == CHANGED; + bool matrix_has_changed = left_state == CHANGED || right_state == CHANGED; - return (uint8_t)changed; -} - -inline matrix_row_t matrix_get_row(uint8_t row) { return rows[row]; } - -void matrix_print(void) { - print("\nr/c 0123456789ABCDEF\n"); - for (uint8_t row = 0; row < MATRIX_ROWS; row++) { - print_hex8(row); - print(": "); - print_bin_reverse16(matrix_get_row(row)); - print("\n"); - } + return matrix_has_changed; } diff --git a/keyboards/handwired/dygma/raise/rules.mk b/keyboards/handwired/dygma/raise/rules.mk index 9bd036295aa..983cd815844 100644 --- a/keyboards/handwired/dygma/raise/rules.mk +++ b/keyboards/handwired/dygma/raise/rules.mk @@ -22,7 +22,7 @@ BLUETOOTH_ENABLE = no # Enable Bluetooth AUDIO_ENABLE = no # Audio output RGB_MATRIX_ENABLE = yes RGB_MATRIX_DRIVER = custom -CUSTOM_MATRIX = yes +CUSTOM_MATRIX = lite # TODO(ibash) we don't actually need to enable raw, but there's some side effect # in the usb driver this triggers that allows mousekeys to work. The same side