Close

Daisy-chained touch controller in 105 bytes

A project log for One Kilobyte Operating System (OKOS)

Tiny computer OS for 1kB challenge. OKOS is just ok because OKOS is just OK.

ben-henckeBen Hencke 12/19/2016 at 07:310 Comments

So it looks like having a PS2 keyboard, while making it easier for anyone to jump in and try this, would potentially disqualify OKOS from the 1k challenge. I can't find any documentation on the controller in my particular keyboard, but there's likely some disqualifying mask-rom microcontroller in it.

I could just write my own controller for the PS2 keyboard, figuring out how its wired, scan, translate, etc., but I don't really have any code space left to decode AND scan. Plus this wouldn't be nearly as fun or interesting as making something new.

I've looked at implementing a matrix scan, but don't really care for that. Plus I'd need a pile of mechanical switches. In the end I'd have a keyboard I wouldn't really enjoy typing on without a substantial investment of time. One of the key design drivers for OKOS was a minimal but usable computer, the keyboard has to be usable. For example, I love the idea of the Pocket CHIP, but the bubble-style keyboard is atrocious to use.

I could do some kind of resistive thing, few parts, simple, but those don't work very well.

Yes, capacitive touch is what this calls for. I think it will make for a nice, low parts count keyboard.

Rather than find some chip with 44 touch channels, I can use some chips I already have (PIC16f1574), and take advantage of the 1k rules that allow duplicate code execution.

So I'm making a daisy-chained touch controller. Each controller handles 8 channels, and you could run up to 32 controllers for 256 channels. OKOS only needs 45 keys, or 6 controllers. The code is only 60 instructions, at 14 bits, thats 105 bytes. Each controller is completely identical and requires no identification configuration, its place in the chain determines it's ID.

With a bit of wiring, I can make the key and controller placement align naturally with the OKOS charset.

After removing all of the existing keyboard support, and counting the new keyboard controller code, I'll have 22 bytes left to receive the keyboard data. I think I'll need to borrow the RX uart, which is currently hooked up to the IR receiver on the badge. Putting some tape over it should prevent it from firing spontaneously. It should work!

Then OKOS will qualify for the 1k challenge! Maybe I'll enter the keyboard controller on it's own :)

Discussions