everything works!

This commit is contained in:
skullY 2017-08-08 16:19:33 -07:00
parent 01887c9b58
commit 2e37c10c53
2 changed files with 14 additions and 20 deletions

View File

@ -22,4 +22,10 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_1, KC_2, KC_3, KC_4, KC_5, \
KC_C, KC_D, KC_E, KC_F, KC_G, KC_A, KC_B \
)
/*
KEYMAP(
KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, \
KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO \
)
*/
};

View File

@ -81,7 +81,6 @@ uint8_t matrix_scan(void) {
select_row(i);
wait_us(30); // without this wait read unstable value.
matrix_row_t cols = read_cols();
printf("row:%d cols:%d\n", i, cols);
if (matrix_debouncing[i] != cols) {
matrix_debouncing[i] = cols;
if (debouncing) {
@ -102,9 +101,6 @@ uint8_t matrix_scan(void) {
}
}
print("\n"); // FIXME: only here for debugging
wait_ms(1000); // FIXME: only here for debugging
return 1;
}
@ -131,23 +127,18 @@ void matrix_print(void) {
*/
static void init_cols(void) {
// Set columns to input mode so they can be read.
palSetPadMode(TEENSY_PIN14_IOPORT, TEENSY_PIN14, PAL_MODE_INPUT);
palSetPadMode(TEENSY_PIN15_IOPORT, TEENSY_PIN15, PAL_MODE_INPUT);
palSetPadMode(TEENSY_PIN16_IOPORT, TEENSY_PIN16, PAL_MODE_INPUT);
palSetPadMode(TEENSY_PIN11_IOPORT, TEENSY_PIN11, PAL_MODE_INPUT);
palSetPadMode(TEENSY_PIN14_IOPORT, TEENSY_PIN14, PAL_MODE_INPUT_PULLDOWN);
palSetPadMode(TEENSY_PIN15_IOPORT, TEENSY_PIN15, PAL_MODE_INPUT_PULLDOWN);
palSetPadMode(TEENSY_PIN16_IOPORT, TEENSY_PIN16, PAL_MODE_INPUT_PULLDOWN);
palSetPadMode(TEENSY_PIN11_IOPORT, TEENSY_PIN11, PAL_MODE_INPUT_PULLDOWN);
}
/* Returns status of switches(1:on, 0:off) */
static matrix_row_t read_cols(void) {
printf("pin14:%d, ", (palReadPad(TEENSY_PIN14_IOPORT, TEENSY_PIN14)==PAL_LOW)<<0);
printf("pin15:%d, ", (palReadPad(TEENSY_PIN15_IOPORT, TEENSY_PIN15)==PAL_LOW)<<1);
printf("pin16:%d, ", (palReadPad(TEENSY_PIN16_IOPORT, TEENSY_PIN16)==PAL_LOW)<<2);
printf("pin11:%d\n", (palReadPad(TEENSY_PIN11_IOPORT, TEENSY_PIN11)==PAL_LOW)<<3);
return (palReadPad(TEENSY_PIN14_IOPORT, TEENSY_PIN14)==PAL_LOW) ? 0 : (1<<0) ||
(palReadPad(TEENSY_PIN15_IOPORT, TEENSY_PIN15)==PAL_LOW) ? 0 : (1<<1) ||
(palReadPad(TEENSY_PIN16_IOPORT, TEENSY_PIN16)==PAL_LOW) ? 0 : (1<<2) ||
(palReadPad(TEENSY_PIN11_IOPORT, TEENSY_PIN11)==PAL_LOW) ? 0 : (1<<3);
return ((palReadPad(TEENSY_PIN14_IOPORT, TEENSY_PIN14)==PAL_LOW) ? 0 : (1<<0)) |
((palReadPad(TEENSY_PIN15_IOPORT, TEENSY_PIN15)==PAL_LOW) ? 0 : (1<<1)) |
((palReadPad(TEENSY_PIN16_IOPORT, TEENSY_PIN16)==PAL_LOW) ? 0 : (1<<2)) |
((palReadPad(TEENSY_PIN11_IOPORT, TEENSY_PIN11)==PAL_LOW) ? 0 : (1<<3));
}
/* Row pin configuration
@ -164,15 +155,12 @@ static void select_row(uint8_t row) {
// Output high to select
switch (row) {
case 0:
print("Row 1: ");
palSetPad(TEENSY_PIN13_IOPORT, TEENSY_PIN13);
break;
case 1:
print("Row 2: ");
palSetPad(TEENSY_PIN12_IOPORT, TEENSY_PIN12);
break;
case 2:
print("Row 3: ");
palSetPad(TEENSY_PIN18_IOPORT, TEENSY_PIN18);
break;
}