forked from mirrors/qmk_firmware
Merge remote-tracking branch 'origin/master' into develop
This commit is contained in:
commit
a75204743a
1 changed files with 85 additions and 79 deletions
|
@ -129,54 +129,7 @@ void matrix_init(void) {
|
|||
uint8_t matrix_scan(void) {
|
||||
bool changed = false;
|
||||
|
||||
matrix_row_t data = 0;
|
||||
// actual matrix
|
||||
for (uint8_t row = 0; row < ROWS_PER_HAND; row++) {
|
||||
// strobe row
|
||||
switch (row) {
|
||||
case 0: writePinHigh(B10); break;
|
||||
case 1: writePinHigh(B11); break;
|
||||
case 2: writePinHigh(B12); break;
|
||||
case 3: writePinHigh(B13); break;
|
||||
case 4: writePinHigh(B14); break;
|
||||
case 5: writePinHigh(B15); break;
|
||||
}
|
||||
|
||||
// need wait to settle pin state
|
||||
matrix_io_delay();
|
||||
|
||||
// read col data
|
||||
data = (
|
||||
(readPin(A0) << 0 ) |
|
||||
(readPin(A1) << 1 ) |
|
||||
(readPin(A2) << 2 ) |
|
||||
(readPin(A3) << 3 ) |
|
||||
(readPin(A6) << 4 ) |
|
||||
(readPin(A7) << 5 ) |
|
||||
(readPin(B0) << 6 )
|
||||
);
|
||||
|
||||
// unstrobe row
|
||||
switch (row) {
|
||||
case 0: writePinLow(B10); break;
|
||||
case 1: writePinLow(B11); break;
|
||||
case 2: writePinLow(B12); break;
|
||||
case 3: writePinLow(B13); break;
|
||||
case 4: writePinLow(B14); break;
|
||||
case 5: writePinLow(B15); break;
|
||||
}
|
||||
|
||||
if (matrix_debouncing[row] != data) {
|
||||
matrix_debouncing[row] = data;
|
||||
debouncing = true;
|
||||
debouncing_time = timer_read();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
for (uint8_t row = 0; row <= ROWS_PER_HAND; row++) {
|
||||
// right side
|
||||
|
||||
// Try to re-init right side
|
||||
if (!mcp23018_initd) {
|
||||
if (++mcp23018_reset_loop == 0) {
|
||||
// if (++mcp23018_reset_loop >= 1300) {
|
||||
|
@ -195,11 +148,26 @@ uint8_t matrix_scan(void) {
|
|||
}
|
||||
}
|
||||
|
||||
matrix_row_t data = 0;
|
||||
// actual matrix
|
||||
for (uint8_t row = 0; row <= ROWS_PER_HAND; row++) {
|
||||
// strobe row
|
||||
switch (row) {
|
||||
case 0: writePinHigh(B10); break;
|
||||
case 1: writePinHigh(B11); break;
|
||||
case 2: writePinHigh(B12); break;
|
||||
case 3: writePinHigh(B13); break;
|
||||
case 4: writePinHigh(B14); break;
|
||||
case 5: writePinHigh(B15); break;
|
||||
case 6: break; // Left hand has 6 rows
|
||||
}
|
||||
|
||||
// right side
|
||||
if (mcp23018_initd) {
|
||||
// #define MCP23_ROW_PINS { GPB5, GBP4, GBP3, GBP2, GBP1, GBP0 } outputs
|
||||
// #define MCP23_COL_PINS { GPA0, GBA1, GBA2, GBA3, GBA4, GBA5, GBA6 } inputs
|
||||
|
||||
// select row
|
||||
|
||||
mcp23018_tx[0] = 0x12; // GPIOA
|
||||
mcp23018_tx[1] = (0b01111111 & ~(1 << (row))) | ((uint8_t)!mcp23018_leds[2] << 7); // activate row
|
||||
mcp23018_tx[2] = ((uint8_t)!mcp23018_leds[1] << 6) | ((uint8_t)!mcp23018_leds[0] << 7); // activate row
|
||||
|
@ -228,6 +196,44 @@ uint8_t matrix_scan(void) {
|
|||
}
|
||||
}
|
||||
|
||||
// left side
|
||||
if (row < ROWS_PER_HAND) {
|
||||
// i2c comm incur enough wait time
|
||||
if (!mcp23018_initd) {
|
||||
// need wait to settle pin state
|
||||
matrix_io_delay();
|
||||
}
|
||||
// read col data
|
||||
data = (
|
||||
(readPin(A0) << 0 ) |
|
||||
(readPin(A1) << 1 ) |
|
||||
(readPin(A2) << 2 ) |
|
||||
(readPin(A3) << 3 ) |
|
||||
(readPin(A6) << 4 ) |
|
||||
(readPin(A7) << 5 ) |
|
||||
(readPin(B0) << 6 )
|
||||
);
|
||||
// unstrobe row
|
||||
switch (row) {
|
||||
case 0: writePinLow(B10); break;
|
||||
case 1: writePinLow(B11); break;
|
||||
case 2: writePinLow(B12); break;
|
||||
case 3: writePinLow(B13); break;
|
||||
case 4: writePinLow(B14); break;
|
||||
case 5: writePinLow(B15); break;
|
||||
case 6: break;
|
||||
}
|
||||
|
||||
if (matrix_debouncing[row] != data) {
|
||||
matrix_debouncing[row] = data;
|
||||
debouncing = true;
|
||||
debouncing_time = timer_read();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Debounce both hands
|
||||
if (debouncing && timer_elapsed(debouncing_time) > DEBOUNCE) {
|
||||
for (int row = 0; row < ROWS_PER_HAND; row++) {
|
||||
matrix[row] = matrix_debouncing[row];
|
||||
|
|
Loading…
Reference in a new issue