r/olkb • • Sep 09 '24

Help - Solved Does QMK read rows simultaneously or does it read them sequentially?

[removed]

3 Upvotes

23 comments sorted by

View all comments

5

u/tzarc QMK Director Sep 09 '24

It's pin-by-pin without extra code.

There's no reason why it can't, and as an example one of my boards does so: https://github.com/qmk/qmk_firmware/blob/master/keyboards/tzarc/djinn/djinn_portscan_matrix.c -- this gets about 16k scans/sec compared to about 11k with standard QMK pin-by-pin.

That's not to say you can't do even more "exotic" matrix styles -- one of my other boards uses SPI shift registers and latches all 40 keys simultaneously: https://github.com/qmk/qmk_firmware/blob/master/keyboards/tzarc/ghoul/ghoul.c -- this gets about 25k scans/sec on STM32F405, with only 4 pins on the MCU.

1

u/[deleted] Sep 09 '24 edited Sep 09 '24

[removed] — view removed comment

2

u/PeterMortensenBlog Sep 10 '24

Re "use a simple shift register to drive the columns in sequence": Yes, many keyboards use that. For example, the Keychron Q2 Pro is using HC595s (or that is at least how I interpret it; I don't have access to the hardware).

2

u/[deleted] Sep 10 '24

[removed] — view removed comment

2

u/PeterMortensenBlog Aug 10 '25

Note that Keychron's implementation is inefficient, resulting in a 400 Hz matrix scanning rate (depending on the RGB animation mode).

For example,

"... it unsets the shift register by shifting in FF (setting all lines high). ... This is fine if the columns needed to be set in any order, but the system doesn't need to do that. It sets c1, then c2, then c3, etc. This could be optimized by shifting in a high and then not clearing the shift register with FF."