geekhack
geekhack Community => Keyboards => Topic started by: zer09 on Sat, 18 November 2017, 21:12:52
-
Hello good day,
I just want know if there is way to get the pressed row and column position?
Thanks.
-
I got the columns and rows using this.
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
if (matrix_is_on(r, c)) {
row_pressed = r;
col_pressed = c;
xprintf("r1:%d c1:%d \n", r, c);
break;
}
}
}
It give me the right result, but I don't know if it is the right way to this.
May be there is already a function to this, I don't want to reinvent the wheel.
-
I don't know much, but in case it matters this will only find and report 1 key that's down.
I suppose that's OK if you're just typing one key at a time to map out a board.
-
Probably. I tried activating two keys, and the debug print show that it alternates between the two keys.
But I can't tell what will be the final result, I am still testing it on the breadboard.
-
Got better solution here: https://www.reddit.com/r/olkb/comments/7dxr2i/the_pressed_key_in_the_matrix/ (https://www.reddit.com/r/olkb/comments/7dxr2i/the_pressed_key_in_the_matrix/)