Browse Source

Use matrix lite for dygma raise

pull/13543/head
Islam Sharabash 2 years ago
parent
commit
b2f388fd3c
4 changed files with 1131 additions and 45 deletions
  1. +0
    -0
      keyboards/handwired/dygma/raise/ansi/info.json
  2. +1117
    -0
      keyboards/handwired/dygma/raise/iso/info.json
  3. +13
    -44
      keyboards/handwired/dygma/raise/matrix.c
  4. +1
    -1
      keyboards/handwired/dygma/raise/rules.mk

keyboards/handwired/dygma/raise/info.json → keyboards/handwired/dygma/raise/ansi/info.json View File


+ 1117
- 0
keyboards/handwired/dygma/raise/iso/info.json
File diff suppressed because it is too large
View File


+ 13
- 44
keyboards/handwired/dygma/raise/matrix.c View File

@ -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 = &current_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;
}

+ 1
- 1
keyboards/handwired/dygma/raise/rules.mk View File

@ -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


Loading…
Cancel
Save