Close

The Code

A project log for Chocolad Keyboard Hacking

Make it run CircuitPython

dehipudeʃhipu 05/02/2021 at 10:310 Comments

I'm using my uKeeb library as usual, but some small modifications were needed to make the split keyboard work. On the left hand side I removed all the key handling logic, leaving just the matrix scanning and debouncing, and two methods:

    def press(self, x, y):
        self.buf[0] = x | (y << 4) | 128
        self.uart.write(self.buf)

    def release(self, x, y):
        self.buf[0] = x | (y << 4)
        self.uart.write(self.buf)

(Of course I also create the UART object earlier.)

Then on the left hand side I added a method to be always called right after scanning:

    def read_uart(self):
        while self.uart.in_waiting:
            self.uart.readinto(self.buf)
            x = self.buf[0] & 0x0f
            y = (self.buf[0] & 0x70) >> 4
            if self.buf[0] & 0x80:
                self.press(9 - x, y)
            else:
                self.release(9 - x, y)

And that's it.  

Discussions