everything works!

teensy_lc_synth
skullY 7 years ago
parent 01887c9b58
commit 2e37c10c53

@ -22,4 +22,10 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
KC_1, KC_2, KC_3, KC_4, KC_5, \ KC_1, KC_2, KC_3, KC_4, KC_5, \
KC_C, KC_D, KC_E, KC_F, KC_G, KC_A, KC_B \ 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 \
)
*/
}; };

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

Loading…
Cancel
Save