diff --git a/Makefile b/Makefile index a4cb6d0..2faf4af 100644 --- a/Makefile +++ b/Makefile @@ -4,13 +4,13 @@ F_CPU=16000000 TARGET=menelaus -USB_DEVICE=/dev/ttyACM0 +USB=/dev/ttyACM0 build: $(TARGET).hex upload: $(TARGET).hex - while [ ! -r $(USB_DEVICE) ]; do sleep 1; done; \ - avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB_DEVICE) + while [ ! -r $(USB) ]; do sleep 1; done; \ + avrdude -p $(MCU) -c avr109 -U flash:w:$(TARGET).hex -P $(USB) test: ; racket test.rkt diff --git a/README.md b/README.md index a6cfcd3..863a1b3 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,31 @@ A firmware for the [Atreus](http://atreus.technomancy.us) keyboard, written in [Microscheme](https://ryansuchocki.github.io/microscheme/). +## Features + +* 6KRO (6 simultaneous keys, not including modifiers) +* Software debouncing +* Multiple layers (limited only by memory) +* Bind arbitrary Scheme functions to a key +* Combo keys (a single keystroke can send a modifier and a non-modifier) + +## Usage + +Replace `/dev/ttyACM0` with the path your OS assigns to the USB +bootloader of the microcontroller: + + $ make upload USB=/dev/ttyACM0 + +Currently only the "multidvorak" layout is supported. + +## Development + +The firmware can also be run on a PC rather than on the +microcontroller in the keyboard using `test.rkt` which loads it up +into Racket and simulates the GPIO functions with a test harness: + + $ make test + ## License Copyright © 2014-2019 Phil Hagelberg and contributors diff --git a/keycodes.scm b/keycodes.scm index fd01419..fefad1b 100644 --- a/keycodes.scm +++ b/keycodes.scm @@ -48,6 +48,7 @@ (define key-home 74) (define key-end 77) (define key-insert 73) +(define key-delete 76) (define key-semicolon 51) (define key-comma 54) @@ -71,6 +72,23 @@ (define key-vol-up 128) (define key-vol-down 129) +(define key-f1 58) +(define key-f2 59) +(define key-f3 60) +(define key-f4 61) +(define key-f5 62) +(define key-f6 63) +(define key-f7 64) +(define key-f8 65) +(define key-f9 66) +(define key-f10 67) +(define key-f11 68) +(define key-f12 69) + +(define key-printscreen 70) +(define key-scroll-lock 71) ; lol +(define key-pause 72) + (define (modifier? keycode) (list? keycode)) (define (modify keycode) (list keycode)) (define (unmodify keycode) (car keycode)) @@ -83,3 +101,5 @@ (define mod-shift (modify #x02)) (define mod-alt (modify #x04)) (define mod-super (modify #x08)) + +(define (sft keycode) (combo mod-shift keycode)) ; shorthand diff --git a/layout.scm b/layout.scm index cd4ab09..1c5a1e8 100644 --- a/layout.scm +++ b/layout.scm @@ -14,7 +14,15 @@ (define (set-layer-0) (set! current-layer (vector-ref layers 0))) -(vector-set! +(define (set-layer-hard) + (set! current-layer (vector-ref layers 3))) + +(define (reset) + #f) ;; TODO: uh, seriously. I need this. how. + +;;;; layers + +(vector-set! ; base layers 0 (vector key-q key-w key-e key-r key-t key-backslash key-y key-u key-i key-o key-p @@ -28,23 +36,58 @@ key-esc key-tab mod-super mod-shift key-backspace mod-alt key-space fn key-quote key-left-bracket key-enter)) -(vector-set! +(vector-set! ; fn layers 1 - (vector (combo mod-shift key-1) (combo mod-shift key-2) key-up - (combo mod-shift key-dash) (combo mod-shift key-equal) - 0 key-page-up key-7 key-8 key-9 (combo mod-shift key-8) + (vector (sft key-1) (sft key-2) key-up (sft key-dash) (sft key-equal) 0 + key-page-up key-7 key-8 key-9 (sft key-8) - (combo mod-shift key-3) key-left key-down key-right - (combo mod-shift key-4) 0 - key-page-down key-4 key-5 key-6 (combo mod-shift key-right-bracket) + (sft key-3) key-left key-down key-right (sft key-4) 0 + key-page-down key-4 key-5 key-6 (sft key-right-bracket) - key-dash key-equal (combo mod-shift key-9) - (combo mod-shift key-0) (combo mod-shift key-7) mod-ctrl + key-dash key-equal (sft key-9) (sft key-0) (sft key-7) mod-ctrl key-backtick key-1 key-2 key-3 key-backslash set-layer-2 key-insert mod-super mod-shift key-backspace mod-alt key-space fn key-e key-0 key-right-bracket)) -(vector-set! - layers 2 ; TODO - (vector 0)) +(vector-set! ; l2 (function keys, etc) + layers 2 + (vector key-insert key-home key-up key-end key-page-up 0 + key-up key-f7 key-f8 key-f9 key-f10 + + key-delete key-left key-down key-right key-page-down 0 + key-down key-f4 key-f5 key-f6 key-f11 + + 0 key-vol-up 0 0 reset mod-ctrl + set-layer-hard key-f1 key-f2 key-f3 key-f12 + + 0 key-vol-down mod-super mod-shift key-backspace mod-alt + key-space set-layer-0 key-printscreen key-scroll-lock key-pause)) + +(vector-set! ; hard dvorak + layers 3 + (vector key-quote key-comma key-period key-p key-y key-backslash + key-f key-g key-c key-r key-l + + key-a key-o key-e key-u key-i key-backtick + key-d key-h key-t key-n key-s + + key-semicolon key-q key-j key-k key-x mod-ctrl + key-b key-m key-w key-v key-z + + key-esc key-tab mod-super mod-shift key-backspace mod-alt + key-space fn key-quote key-left-bracket key-enter)) + +(vector-set! ; hard dvorak fn + layers 4 + (vector (sft key-1) (sft key-2) key-up (sft key-left-bracket) (sft key-right-bracket) 0 + key-page-up key-7 key-8 key-9 (sft key-8) + + (sft key-3) key-left key-down key-right (sft key-4) 0 + key-page-down key-4 key-5 key-6 (sft key-equal) + + key-left-bracket key-right-bracket (sft key-9) (sft key-0) (sft key-7) mod-ctrl + key-backtick key-1 key-2 key-3 key-backslash + + set-layer-2 key-insert mod-super mod-shift key-backspace mod-alt + key-space fn key-e key-0 key-right-bracket))