mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-17 21:22:05 +00:00
Testing
This commit is contained in:
parent
b3f09108da
commit
d66984ddc1
@ -24,12 +24,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
#define PRODUCT_ID 0x0000
|
#define PRODUCT_ID 0x0000
|
||||||
#define DEVICE_VER 0x0001
|
#define DEVICE_VER 0x0001
|
||||||
#define MANUFACTURER jpskenn
|
#define MANUFACTURER jpskenn
|
||||||
#define PRODUCT test_col2col2
|
#define PRODUCT test_col2col
|
||||||
#define DESCRIPTION A custom keyboard
|
#define DESCRIPTION A custom keyboard
|
||||||
|
|
||||||
/* key matrix size */
|
/* key matrix size */
|
||||||
#define MATRIX_ROWS 1*2 // 右手側と左手側があるので、*2
|
#define MATRIX_ROWS (2+1)*2 // 2行 + 倍マトリクス用の1行。両手で*2。
|
||||||
#define MATRIX_COLS 3*2 // 列数 Duprex Matrix法により、*2
|
#define MATRIX_COLS (2+1) // 2列 + 倍マトリクス用の1列。
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Keyboard Matrix Assignments
|
* Keyboard Matrix Assignments
|
||||||
@ -41,13 +41,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
* ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
|
* ROW2COL = ROW = Anode (+), COL = Cathode (-, marked on diode)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#define MATRIX_ROW_PINS { F6 } // 各行に割り当てるピン番号
|
#define MATRIX_ROW_PINS { F6, F7, B1 } // 各行に割り当てるピン番号
|
||||||
#define MATRIX_COL_PINS { D1, D0, D4 } // 各列に割り当てるピン番号
|
#define MATRIX_COL_PINS { F6, F7, B1 } // 各列に割り当てるピン番号
|
||||||
#define UNUSED_PINS
|
#define UNUSED_PINS
|
||||||
|
|
||||||
/* COL2ROW, ROW2COL*/
|
/* COL2ROW, ROW2COL*/
|
||||||
// #define DIODE_DIRECTION CUSTOM_MATRIX // COL(列)のピンからROW(行)のピンに電流が流れるようにダイオードを付けた場合はCOL2ROW、逆向きの場合はROW2COL、独自にマトリクススキャンを行う場合はCUSTOM_MATRIX
|
// #define DIODE_DIRECTION CUSTOM_MATRIX // COL(列)のピンからROW(行)のピンに電流が流れるようにダイオードを付けた場合はCOL2ROW、逆向きの場合はROW2COL、独自にマトリクススキャンを行う場合はCUSTOM_MATRIX
|
||||||
// #define DIODE_DIRECTION CUSTOM_MATRIX
|
// #define DIODE_DIRECTION CUSTOM_MATRIX
|
||||||
|
#define COL2COL 101
|
||||||
|
#define DIODE_DIRECTION COL2COL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
|
* Split Keyboard specific options, make sure you have 'SPLIT_KEYBOARD = yes' in your rules.mk, and define SOFT_SERIAL_PIN.
|
||||||
|
@ -30,10 +30,12 @@ enum custom_keycodes {
|
|||||||
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
||||||
/* Base */
|
/* Base */
|
||||||
[_BASE] = LAYOUT(
|
[_BASE] = LAYOUT(
|
||||||
KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_A,KC_B,KC_C,KC_D,KC_E,KC_F
|
KC_1, KC_2, KC_3, KC_4, \
|
||||||
|
KC_A, KC_B, KC_C, KC_D
|
||||||
),
|
),
|
||||||
[_FN] = LAYOUT(
|
[_FN] = LAYOUT(
|
||||||
KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_A,KC_B,KC_C,KC_D,KC_E,KC_F
|
KC_1, KC_2, KC_3, KC_4, \
|
||||||
|
KC_A, KC_B, KC_C, KC_D
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ static pin_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
|
|||||||
|
|
||||||
/* matrix state(1:on, 0:off) */
|
/* matrix state(1:on, 0:off) */
|
||||||
static matrix_row_t raw_matrix[MATRIX_ROWS]; //raw values
|
static matrix_row_t raw_matrix[MATRIX_ROWS]; //raw values
|
||||||
static matrix_row_t matrix[MATRIX_ROWS]; //debounced values //ROWS_PER_HAND?
|
static matrix_row_t matrix[MATRIX_ROWS]; //debounced values
|
||||||
|
|
||||||
__attribute__ ((weak))
|
__attribute__ ((weak))
|
||||||
void matrix_init_quantum(void) {
|
void matrix_init_quantum(void) {
|
||||||
@ -181,7 +181,7 @@ static void select_col(uint8_t 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) {
|
static void unselect_cols(void) {
|
||||||
for (uint8_t x = 0; x < MATRIX_COLS / 2 ; x++) {
|
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||||
setPinInputHigh(col_pins[x]);
|
setPinInputHigh(col_pins[x]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,6 +191,7 @@ static void init_pins(void) {
|
|||||||
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
for (uint8_t x = 0; x < MATRIX_COLS; x++) {
|
||||||
setPinInputHigh(col_pins[x]);
|
setPinInputHigh(col_pins[x]);
|
||||||
}
|
}
|
||||||
|
//NOTE rowもcolも同じピンだから、片方やれば十分かな?
|
||||||
unselect_cols();
|
unselect_cols();
|
||||||
for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
|
for (uint8_t x = 0; x < ROWS_PER_HAND; x++) {
|
||||||
setPinInputHigh(row_pins[x]);
|
setPinInputHigh(row_pins[x]);
|
||||||
@ -212,23 +213,29 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)
|
|||||||
wait_us(30);
|
wait_us(30);
|
||||||
|
|
||||||
// For each col...
|
// For each col...
|
||||||
for (uint8_t col_index = 0; col_index < MATRIX_COLS / 2; col_index++) {
|
uint8_t matrix_index = 0;
|
||||||
|
for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++) {
|
||||||
// // Select the col pin to read (active low)
|
// // Select the col pin to read (active low)
|
||||||
// uint8_t pin_state = readPin(col_pins[col_index]);
|
// uint8_t pin_state = readPin(col_pins[col_index]);
|
||||||
//
|
//
|
||||||
// // Populate the matrix row with the state of the col pin
|
// // Populate the matrix row with the state of the col pin
|
||||||
// current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
|
// current_matrix[current_row] |= pin_state ? 0 : (ROW_SHIFTER << col_index);
|
||||||
|
|
||||||
|
// rowと同じインデックスのcol(=同じピン)は読まない
|
||||||
|
if (col_index != current_row) {
|
||||||
// Check col pin pin_state
|
// Check col pin pin_state
|
||||||
if (readPin(col_pins[col_index]) == 0) {
|
if (readPin(col_pins[col_index]) == 0) {
|
||||||
// Pin LO, set col bit
|
// Pin LO, set col bit
|
||||||
current_matrix[current_row] |= (ROW_SHIFTER << col_index);
|
current_matrix[current_row] |= (ROW_SHIFTER << matrix_index);
|
||||||
} else {
|
} else {
|
||||||
// Pin HI, clear col bit
|
// Pin HI, clear col bit
|
||||||
current_matrix[current_row] &= ~(ROW_SHIFTER << col_index);
|
current_matrix[current_row] &= ~(ROW_SHIFTER << matrix_index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matrix_index++;
|
||||||
|
}
|
||||||
|
|
||||||
// Unselect row
|
// Unselect row
|
||||||
unselect_row(current_row);
|
unselect_row(current_row);
|
||||||
// dprintf("\nCoR %d\n" ,(last_row_value != current_matrix[current_row]));
|
// dprintf("\nCoR %d\n" ,(last_row_value != current_matrix[current_row]));
|
||||||
@ -246,10 +253,12 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
|
|||||||
wait_us(30);
|
wait_us(30);
|
||||||
|
|
||||||
// For each row...
|
// For each row...
|
||||||
|
uint8_t matrix_index = 0;
|
||||||
for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) {
|
for (uint8_t row_index = 0; row_index < ROWS_PER_HAND; row_index++) {
|
||||||
// Store last value of row prior to reading
|
// Store last value of row prior to reading
|
||||||
matrix_row_t last_row_value = current_matrix[row_index];
|
matrix_row_t last_row_value = current_matrix[row_index];
|
||||||
|
|
||||||
|
if (row_index != current_col) {
|
||||||
// Check row pin state
|
// Check row pin state
|
||||||
if (readPin(row_pins[row_index]) == 0) {
|
if (readPin(row_pins[row_index]) == 0) {
|
||||||
// Pin LO, set col bit
|
// Pin LO, set col bit
|
||||||
@ -265,6 +274,9 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matrix_index++;
|
||||||
|
}
|
||||||
|
|
||||||
// Unselect col
|
// Unselect col
|
||||||
unselect_col(current_col);
|
unselect_col(current_col);
|
||||||
// dprintf("\nRoC %d\n" ,matrix_changed);
|
// dprintf("\nRoC %d\n" ,matrix_changed);
|
||||||
@ -354,7 +366,7 @@ uint8_t matrix_scan(void) {
|
|||||||
changed |= read_cols_on_row(raw_matrix, current_row);
|
changed |= read_cols_on_row(raw_matrix, current_row);
|
||||||
}
|
}
|
||||||
// Set col, read rows
|
// Set col, read rows
|
||||||
for (uint8_t current_col = 0; current_col < MATRIX_COLS / 2; current_col++) {
|
for (uint8_t current_col = 0; current_col < MATRIX_COLS; current_col++) {
|
||||||
changed |= read_rows_on_col(raw_matrix, current_col);
|
changed |= read_rows_on_col(raw_matrix, current_col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,9 +27,12 @@
|
|||||||
* represents the switch matrix.
|
* represents the switch matrix.
|
||||||
*/
|
*/
|
||||||
#define LAYOUT( \
|
#define LAYOUT( \
|
||||||
l00, l01, l02, l03, l04, l05, r00, r01, r02, r03, r04, r05 \
|
l00, l01, r00, r01, \
|
||||||
|
l10, l11, r10, r11 \
|
||||||
) \
|
) \
|
||||||
{ \
|
{ \
|
||||||
{ l00, l01, l02, l03,l04,l05}, \
|
{ l00, l01, KC_NO }, \
|
||||||
{ r00, r01, r02, r03,r04,r05}, \
|
{ KC_NO, l10, l11 }, \
|
||||||
|
{ r00, r01, KC_NO }, \
|
||||||
|
{ KC_NO, r10, r11 }, \
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user