Giter VIP home page Giter VIP logo

python-keyboard's Introduction

Makerdiary M60

I got interested in the Makerdiary M60 because I wanted a 60% keyboard with dedicated, physical arrow keys in the lower-right corner. Most 60% keyboards I've seen, even ones with very powerful remapping capabilities, have a FN key in the lower-right which for safety reasons cannot be moved or remapped. When the documentation said "If you already Python, configuring the keyboard is simple", I knew I had found the right board for me.

The M60 comes preloaded with very old firmware, and no instructions for how to get caught up with upstream CircuitPython. Thus, this howto!

About

In this repo, you will find the configuration that I use on my own keyboard. It comes with the following keymap and special features:

  • FN key on the left, between Tab and Shift (i.e. where Caps Lock usually goes)
  • Arrow keys in the lower right, Left-Down-Up-Right
  • ESC next to 1
    • tilde available with Shift-ESC
    • backtick available with FN-ESC
  • F1-F12 available with FN-1234567890-=
  • All tenkeyless special keys, in hopefully-obvious places
  • Alternate arrows available with FN-hjkl, just like vi
  • Keyboard-adjustable RGB lighting
    • FN-q to cycle through the builtin modes
    • FN-ws to adjust brightness
    • FN-ad to adjust hue
    • FN-TAB to save current settings
  • CIRCUITPY drive and serial console hidden
    • Hold d (for "drive", natch) while plugging in the keyboard to make them available temporarily
  • Optional USB Boot Keyboard support
    • This is required for old Macs, some BIOSes, and certain KVMs
    • This is incompatible with using the Consumer Control keys (e.g. Play, Pause, Eject)
    • To enable Boot Keyboard support, uncomment the appropriate line in boot.py

Links

Getting Started

Update Bootloader

First, you will have to update UF2. Unfortunately, the M60 ships with a UF2 that predates the UF2 auto-updater. If you're already well-versed in Arduino development, you know what to do.

I'm new to Arduino, so I followed the command-line update documentation.

On Ubuntu, I did it like this:

wget "https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases/download/0.8.3/m60_keyboard_bootloader-0.8.3_s140_6.1.1.zip"
  • Install adafruit-nrfutil into a virtualenv
mkdir adafruit-nrfutil
virtualenv adafruit-nrfutil
./adafruit-nrfutil/bin/pip3 install adafruit-nrfutil
  • Update UF2 firmware
./adafruit-nrfutil/bin/adafruit-nrfutil --verbose dfu serial -p /dev/ttyACM0 -b 115200 --singlebank --touch 1200 --package m60_keyboard_bootloader-0.8.3_s140_6.1.1.zip
  • Check that it worked
cat "/media/${USERNAME}/M60KEYBOARD/INFO_UF2.TXT"

Update CircuitPython

With UF2 updated, we can download the newest CircuitPython for M60 and copy it onto the M60KEYBOARD drive to install it.

For example:

wget "https://downloads.circuitpython.org/bin/makerdiary_m60_keyboard/en_US/adafruit-circuitpython-makerdiary_m60_keyboard-en_US-8.2.9.uf2"
cp adafruit-circuitpython-makerdiary_m60_keyboard-en_US-8.2.9.uf2 "/media/${USERNAME}/M60KEYBOARD/"

Load python-keyboard

Now, we can load modules, code.py, and boot.py onto the keyboard by copying them onto the CIRCUITPY drive.

For example:

  • Download the code
git clone "https://github.com/tabbysable/python-keyboard.git"
  • Copy keyboard module
cp -r python-keyboard/keyboard/ "/media/${USERNAME}/CIRCUITPY/lib/"
  • Install dependencies
pip3 install -r python-keyboard/requirements.txt --no-deps -t "/media/${USERNAME}/CIRCUITPY/lib/"
  • Copy code.py and boot.py, and make sure it finishes
cp python-keyboard/boot.py "/media/${USERNAME}/CIRCUITPY/"
sync
cp python-keyboard/code.py "/media/${USERNAME}/CIRCUITPY/"
sync
  • Unplug / replug they keyboard and celebrate
    • You should see purple lights!

Make It Your Own

Now that your keyboard is working, you may customize it by modifying code.py and boot.py according to your preferences. Hold d while plugging in the keyboard to make the CIRCUITPY drive visible, and do whatever sounds cool.

Good luck, and have fun!

python-keyboard's People

Contributors

cvyy39 avatar jiapengli avatar kfihihc avatar mehalter avatar tabbysable avatar windoze avatar xiongyihui avatar

Watchers

 avatar

python-keyboard's Issues

Add caps lock and scroll lock LEDs

Unsure if it will be better to listen to OS events to update these, or to update them directly when the keys are pressed.

This will likely require modifications in the keyboard module.

Support MacOS 9

MacOS 9 doesn't know what to do with this thing.

It sees it as a USB HID and attaches the generic HID driver, which does nothing.

By making it a boot keyboard, I am able to get the HIDKeyboardDriver to attach to it, but it still doesn't register keystrokes.

I suspect this has something to do with the CircuitPython HID keyboard class implementing both IN and OUT endpoints; every keyboard I've tried that works with MacOS 9 has only an IN endpoint.

Next step would be to set aside the entire firmware and try a minimal CircuitPython USB HID example that builds a keyboard manually from the documented Report Descriptor and sends a repeating test pattern or something, to see what is required to get keystrokes to register.

TODO: Save RGB Settings

It should be fairly straightforward to write a macro that saves the current RGB settings into a file on the CIRCUITPY drive, and modify code.py to load them at boot time. This would let you persist them across restarts without needing to edit code.py yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.