6 ms·
A hand-wired USB and Bluetooth keyboard powered by Python
- mchan889 6y agoThis looks cool, however can someone with some electronics know-how explain to me why the connections on most, if not all the keys are crossed? They don't look like insulated wires, though I could be wrong.
- fenwick67 6y agoLooks like they only appear to be touching in the photo but aren't really.
- n3k5 6y agoInsulated wires that look a lot like bare metal are quite common, e.g. in electromagnet coils. https://en.wikipedia.org/wiki/Magnet_wire https://en.wikipedia.org/wiki/Magnet_wire The insulation melts away where it comes in contact with hot solder, so it's very easy to work with for hand-wiring projects.
- deleted 6y ago[deleted]
- stonecharioteer 6y agoHaha that's amazing. What's the latency on this though? I always assumed firmware written in python would be slow for a use case like a keyboard.
- kfihihc 6y agoIt is a bit slow. It takes 4 ms to scan the matrix once right now. With some optimizations, it may be faster.
- sk0g 6y agoWould Numpy be of use? Haven't looked at the source yet, but for a keyboard, 4 ms per matrix would be noticeably laggy, especially if you add debouncing (is that even a thing in keyboards?)
- kfihihc 6y agoThe best usb keyboard should have 1ms latency due to USB HID interrupt interval. 4 ms is not that bad.
- sk0g 6y agoYeah, read it as 4ms per row at first. Should be fine for general use, and rather impressive as is :)
- JoeSmithson 6y agoHow would 4ms be noticeably laggy?
- sk0g 6y agoI read it first as 4ms per row, but yeah 4ms per scan wouldn't be too bad. There is of course additional time taken for communication etc, which might take another 4-10ms, which could make it almost a frame behind. Not terrible still.
- turbinerneiter 6y agoIt's a microcontroller. It has maybe 512k of storage and 128k of memory. The Numpy package probably is ~100Mb The controller is running CircuitPython which is a fork of MicroPython - a tiny re-implementation Python for microcontrollers.
- sk0g 6y agoValid point! Might still be able to get a speed up if you can write and import your own C code though.
- jonny383 6y agoHonestly, why Python? Writing a much faster equivalent in C really isn't any more complicated...
- kfihihc 6y agoJust for fun :) The hardware includes a QSPI flash which presents as an USB storage that stored Python source code, and you can modify Python directly. BTW, It provides a new way to validate your hardware product ideas quickly.
- jonny383 6y agoSolid answer. I just realised my question sounded cynical - which wasn't my intention.
- hellweaver666 6y agoIf you want to make a little macro-keyboard equivalent at a fraction of the cost, I wrote a little guide (with example code) here: https://makeandymake.github.io/2020/05/02/seeeduino-xiao-circuitpython-usb-hid-macro-keypad.html https://makeandymake.github.io/2020/05/02/seeeduino-xiao-cir...
- kart23 6y agothis is pretty cool! I've wanted to hardwire a keyboard, but a full-size one seems pretty intimidating.
- thecureforzits 6y agoNice, if I made it I would replace the capslock with control and "~" with escape. Make the least used keys require combinations, not the often used ones.
- mvanbaak 6y agoCAPS -> control I can follow, but the ~ key ... Man, that would be annoying as hell.
- StavrosK 6y agoI use Caps Lock for both Ctrl and Esc, wouldn't have it any other way. Shift keys are also open/closing parens, holding down the tilde turns the "yuihjknm," section to a numpad, holding down Tab turns jkl; to {}[], etc. Very handy when programming.
- Keyframe 6y agoHow's caps both ctrl and esc? Can you explain on shifts a bit? I guess you autotab
- Abishek_Muthian 6y agoThis is nice, we need more such open-source, affordable keyboard designs and components; Especially for accessibility keyboards[1] as their costs are exorbitant. [1]https://needgap.com/problems/96-one-hand-keyboard-keyboard-accessibility https://needgap.com/problems/96-one-hand-keyboard-keyboard-a...
- davefp 6y agoGreat job! I've not seen python-based keyboard firmware before, I'm impressed that it's fast enough to run something like a keyboard. Without detracting from the code in the post, I recommend that anyone wanting to make and program their own keyboard should take a look at QMK, a widely supported keyboard firmware project that is FOSS: https://qmk.fm/ https://qmk.fm/
- BiteCode_dev 6y agoA lot of people are asking: - why python? - isn't is slow? Remember that Python is a language spec, there are several implementations. This project uses a particular implementation called CircuitPython ( https://en.wikipedia.org/wiki/CircuitPython https://en.wikipedia.org/wiki/CircuitPython), a derivative project from MicroPython ( https://fr.wikipedia.org/wiki/MicroPython https://fr.wikipedia.org/wiki/MicroPython), by the people at AdaFruit. This implementation runs with a very different VM that can fit within 256k of code space and 16k of RAM. So, while obviously you cannot expect anywhere near C level of perfs, this is way lighter than CPython. The advantage is that you get the ease of Python to program your board, including the clean terce language, the memory management and the rich data structures. You can even have a live shell on some embeded hardwares! The whole dev process is so simple: code, copy your module, run. Of course, some features of CPython are not available.
- mzakharo1 6y agomany people dont realize, but micropython has unix port, and it can be much slower than CPython. micropython's main advantage is size, not speed.