STILL DRAFT BUT SHARING ANYWAY
Another WIP this is to replace the keyboard controller in the Tek keyboard with a Pi Pico. The first attempt I wired it directly but it looks like I might not have enough pins to do everything including the rotary encoder and the serial port to the Tek terminal. So the current plan is to weed out some of the wires and clean out the chips that I removed. They were 74138s for the columns. I will replace them with 3V 74LV138 parts and use more of the existing wiring. This will save pins and reduce the rats nest of wires. I will also replace the encode schmidt trigger chip with the LV version. I can get 10 of each at DigiKey for $15 including shipping. But they are SOIC chips I will need to get a carrier adapter for them.
To use the 3-to-8 chips I need to figure out how to set KMK correctly. So I just asked an AI (Gemeni in this case). It looks like it delivered the goods:
import board
from kmk.kmk_keyboard import KMKKeyboard
from kmk.keys import KC
from kmk.modules.io_expander import IOExpander
from kmk.matrix import DiodeOrientation
keyboard = KMKKeyboard()
# IO Expander 1 (74HC138 #1)
io_expander1 = IOExpander(pins=(board.GP0, board.GP1, board.GP2))
# IO Expander 2 (74HC138 #2)
io_expander2 = IOExpander(pins=(board.GP3, board.GP4, board.GP5))
# Enable pin control. If you have enable pins, you can control them like this.
enable1 = digitalio.DigitalInOut(board.GP6)
enable1.direction = digitalio.Direction.OUTPUT
enable1.value = True #set to true to enable.
enable2 = digitalio.DigitalInOut(board.GP7)
enable2.direction = digitalio.Direction.OUTPUT
enable2.value = True
keyboard.col_pins = [
io_expander1.output_pin(0), # 74HC138 #1 - Y0
io_expander1.output_pin(1), # 74HC138 #1 - Y1
io_expander1.output_pin(2), # 74HC138 #1 - Y2
io_expander1.output_pin(3), # 74HC138 #1 - Y3
io_expander1.output_pin(4), # 74HC138 #1 - Y4
io_expander1.output_pin(5), # 74HC138 #1 - Y5
io_expander1.output_pin(6), # 74HC138 #1 - Y6
io_expander1.output_pin(7), # 74HC138 #1 - Y7
io_expander2.output_pin(0), # 74HC138 #2 - Y0
io_expander2.output_pin(1), # 74HC138 #2 - Y1
io_expander2.output_pin(2), # 74HC138 #2 - Y2
io_expander2.output_pin(3), # 74HC138 #2 - Y3
io_expander2.output_pin(4), # 74HC138 #2 - Y4
io_expander2.output_pin(5), # 74HC138 #2 - Y5
io_expander2.output_pin(6), # 74HC138 #2 - Y6
io_expander2.output_pin(7), # 74HC138 #2 - Y7
]
keyboard.row_pins = [board.GP8, board.GP9, board.GP10]
keyboard.diode_orientation = DiodeOrientation.COL2ROW
keyboard.keymap = [
[KC.A, KC.B, KC.C, KC.D, KC.E, KC.F, KC.G, KC.H, KC.I, KC.J, KC.K, KC.L, KC.M, KC.N, KC.O, KC.P],
[KC.Q, KC.R, KC.S, KC.T, KC.U, KC.V, KC.W, KC.X, KC.Y, KC.Z, KC.N1, KC.N2, KC.N3, KC.N4, KC.N5, KC.N6],
[KC.N7, KC.N8, KC.N9, KC.N0, KC.MINS, KC.EQL, KC.BSPC, KC.TAB, KC.Q, KC.W, KC.E, KC.R, KC.T, KC.Y, KC.U, KC.I],
]
if __name__ == '__main__':
keyboard.go()
