Update IKeJIさんの方法(とりあえずCOL2COLと呼ぶ)の動作テストOK

This commit is contained in:
Takeshi Nishio 2020-03-19 21:45:06 +09:00
parent d66984ddc1
commit 9d3f491fb7
3 changed files with 60 additions and 55 deletions

View File

@ -31,11 +31,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Base */
[_BASE] = LAYOUT(
KC_1, KC_2, KC_3, KC_4, \
KC_A, KC_B, KC_C, KC_D
KC_A, KC_B, KC_C, KC_D, \
KC_MINS, KC_EQL, KC_SPC, KC_ENT
),
[_FN] = LAYOUT(
KC_1, KC_2, KC_3, KC_4, \
KC_A, KC_B, KC_C, KC_D
KC_A, KC_B, KC_C, KC_D, \
KC_MINS, KC_EQL, KC_SPC, KC_ENT
)
};

View File

@ -173,12 +173,12 @@ static void unselect_rows(void) {
}
}
static void select_col(uint8_t col) {
setPinOutput(col_pins[col]);
writePinLow(col_pins[col]);
}
// static void select_col(uint8_t col) {
// setPinOutput(col_pins[col]);
// writePinLow(col_pins[col]);
// }
static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); }
// static void unselect_col(uint8_t col) { setPinInputHigh(col_pins[col]); }
static void unselect_cols(void) {
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
@ -243,45 +243,45 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
return (last_row_value != current_matrix[current_row]);
}
static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
bool matrix_changed = false;
// Select col and wait for col selecton to stabilize
select_col(current_col);
// matrix_io_delay();
wait_us(30);
// For each row...
uint8_t matrix_index = 0;
for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) {
// Store last value of row prior to reading
matrix_row_t last_row_value = current_matrix[row_index];
if (row_index != current_col) {
// Check row pin state
if (readPin(row_pins[row_index]) == 0) {
// Pin LO, set col bit
current_matrix[row_index] |= (ROW_SHIFTER << (current_col + MATRIX_COLS / 2));
} else {
// Pin HI, clear col bit
current_matrix[row_index] &= ~(ROW_SHIFTER << (current_col + MATRIX_COLS / 2));
}
// dprintf("\nRoC %d\n", current_matrix[row_index]);
// Determine if the matrix changed state
if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) {
matrix_changed = true;
}
}
matrix_index++;
}
// Unselect col
unselect_col(current_col);
// dprintf("\nRoC %d\n" ,matrix_changed);
return matrix_changed;
}
// static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col) {
//
// bool matrix_changed = false;
//
// // Select col and wait for col selecton to stabilize
// select_col(current_col);
// // matrix_io_delay();
// wait_us(30);
//
// // For each row...
// uint8_t matrix_index = 0;
// for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) {
// // Store last value of row prior to reading
// matrix_row_t last_row_value = current_matrix[row_index];
//
// if (row_index != current_col) {
// // Check row pin state
// if (readPin(row_pins[row_index]) == 0) {
// // Pin LO, set col bit
// current_matrix[row_index] |= (ROW_SHIFTER << (current_col + MATRIX_COLS / 2));
// } else {
// // Pin HI, clear col bit
// current_matrix[row_index] &= ~(ROW_SHIFTER << (current_col + MATRIX_COLS / 2));
// }
// // dprintf("\nRoC %d\n", current_matrix[row_index]);
// // Determine if the matrix changed state
// if ((last_row_value != current_matrix[row_index]) && !(matrix_changed)) {
// matrix_changed = true;
// }
// }
//
// matrix_index++;
// }
//
// // Unselect col
// unselect_col(current_col);
// // dprintf("\nRoC %d\n" ,matrix_changed);
// return matrix_changed;
// }
@ -366,9 +366,9 @@ uint8_t matrix_scan(void) {
changed |= read_cols_on_row(raw_matrix, current_row);
}
// Set col, read rows
for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
changed |= read_rows_on_col(raw_matrix, current_col);
}
// for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
// changed |= read_rows_on_col(raw_matrix, current_col);
// }
debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed);

View File

@ -27,12 +27,15 @@
* represents the switch matrix.
*/
#define LAYOUT( \
l00, l01, r00, r01, \
l10, l11, r10, r11 \
l13, l23, r13, r23, \
l31, l21, r31, r21, \
l32, l12, r32, r12 \
) \
{ \
{ l00, l01, KC_NO }, \
{ KC_NO, l10, l11 }, \
{ r00, r01, KC_NO }, \
{ KC_NO, r10, r11 }, \
{ KC_NO, l21, l31 }, \
{ l12, KC_NO, l32 }, \
{ l13, l23, KC_NO }, \
{ KC_NO, r21, r31 }, \
{ r12, KC_NO, r32 }, \
{ r13, r23, KC_NO }, \
}