MATRIX_KB(9)

πŸ“¦
version 2.9.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– MATRIX_KB(9) πŸ’–

bestie. sit down. we're talking about matrix_kb, a HAL component, and honestly? it's giving keyboard-whisperer. no cap. πŸ’…

✨ NAME ✨

matrix_kb β€” turns integers into HAL pins. and if you want, it will also go out there and scan a whole matrix of IO ports to make those integers in the first place. main character energy fr fr. πŸ‘‘

🌈 SYNOPSIS 🌈

loadrt matrix_kb config=RxCs,RxCs... names=name1,name2...

this sets up a component built for R rows and N columns of matrix keyboard. 🎹

if the s option is in the mix, then a set of output rows gets cyclically toggled, and a set of input columns gets scanned. that's the whole vibe.

the names parameter is optional β€” but if you use it, the HAL pins and functions will use your names instead of the default ones. super useful for readability and for 2-pass HAL parsing, iykyk. πŸ’–

⚠️ there must be no spaces in the parameter lists. none. zero. zip. 🚫

🧚 DESCRIPTION 🧚

okay so the origin story: this component was written to convert matrix keyboard scancodes into HAL pins. but plot twist β€” it might also find uses in converting integers from 0 to N into N HAL pins. versatility, we love to see it. ✨

it can work in two ways, and the HAL pins it creates vary according to the mode. let's break it down.

the default mode πŸ’œ

the component expects to be given a scan code from a separate driver β€” but honestly it could be any integer from any source. most typically it's the keypad scancode from a Mesa 7I73. the default codes for keyup and keydown are based on the Mesa 7I73 specification, with 0x40 indicating a keydown and 0x80 a keyup event. πŸŽ€

if you're using the 7I73, it is important to match the keypad size jumpers with the HAL component. valid configs for the 7I73 are 4x8 and 8x8.

πŸ’€ also, heads up: the component will only work properly with the version 12 (0xC) 7I73 firmware. the firmware version is visible on the component parameters in HAL, so go peek. πŸ™ˆ

the optional scan-generation mode πŸ¦‹

here, the matrix_kb.N.keycode pin changes into an output pin, and a set of output row pins plus input column pins gets created. those need to be connected to physical inputs and outputs so the matrix actually gets scanned and the values come back to HAL. πŸ”₯

also β€” clock the negative-logic parameter described below (scroll down, bestie), you'll need to set it on the most common forms of inputs, the ones that float high when unconnected. 🫢

both modes 🌸

in both modes, a set of HAL output pins is created, corresponding to each node of the matrix. every single node. periodt.

⭐ FUNCTIONS ⭐

  • matrix_kb.N β€” performs all requested functions. should be run in a slow thread for effective debouncing. don't rush her. 😌

πŸŽ€ PINS πŸŽ€

  • matrix_kb.N.col-CC-in bit in β€” the input pin corresponding to column C. 🌈
  • matrix_kb.N.key.rRcC bit out β€” the pin corresponding to the key at row R, column C of the matrix. that's your key right there. πŸ’–
  • matrix_kb.N.keycode unsigned β€” in or out depending on mode. this pin should be connected to the scancode generator if hardware such as a 7I73 is being used, and in this mode it is an input pin. in the internally-generated scanning mode this pin is an output β€” but it will not normally be connected. ✨
  • matrix_kb.N.row-RR-out bit out β€” the row scan drive pins. should be connected to external hardware pins connected to the keypad. the row scan drive pins. should be connected to external hardware pins connected to the keypad. (yes bestie, she said it twice, and we are keeping it twice πŸ’…)

πŸ’… PARAMETERS πŸ’…

  • matrix_kb.N.key_rollover unsigned r/w (default 2) β€” with most matrix keyboards the scancodes are only unambiguous with 1 or 2 keys pressed. press more and phantom keystrokes can appear. πŸ‘» some keyboards are optimised to reduce this problem, and some have internal diodes so that any number of keys may be pressed simultaneously. increase the value of this parameter if such a keyboard is connected β€” or if phantom keystrokes are more acceptable to you than only two keys being active at one time. your call, your vibe.
  • matrix_kb.N.negative-logic bit r/w (default 1) β€” only in scan mode. when no keys are pressed a typical digital input will float high, and then the input gets pulled low by the keypad when the corresponding poll line is low. set this parameter to 0 if the IO in use requires one row at a time to be high, and a high input corresponds to a button press. πŸŽ€

and that's the whole page bestie!! this was MATRIX_KB(9) from LinuxCNC Documentation, dated 2013-03-24. slay, go build a keyboard. πŸ’–βœ¨πŸŽ€πŸ¦‹