Scan the whole matrix.
This commit is contained in:
parent
20df8134c1
commit
5f629927fb
3 changed files with 52 additions and 19 deletions
27
keycodes.scm
27
keycodes.scm
|
@ -28,7 +28,26 @@
|
||||||
(define key-z 29)
|
(define key-z 29)
|
||||||
(define key-semicolon 51)
|
(define key-semicolon 51)
|
||||||
|
|
||||||
(define mod-ctrl #x01)
|
(define key-comma 54)
|
||||||
(define mod-shift #x02)
|
(define key-period 55)
|
||||||
(define mod-alt #x04)
|
(define key-slash 56)
|
||||||
(define mod-gui #x08)
|
(define key-dash 45)
|
||||||
|
(define key-quote 52)
|
||||||
|
|
||||||
|
(define key-space 44)
|
||||||
|
(define key-backspace 42)
|
||||||
|
(define key-esc 41)
|
||||||
|
(define key-tab 43)
|
||||||
|
(define key-enter 40)
|
||||||
|
|
||||||
|
(define mod-ctrl 0)
|
||||||
|
(define mod-shift 0)
|
||||||
|
(define mod-alt 0)
|
||||||
|
(define mod-gui 0)
|
||||||
|
(define mod-fn 0)
|
||||||
|
|
||||||
|
;; (define mod-ctrl #x01)
|
||||||
|
;; (define mod-shift #x02)
|
||||||
|
;; (define mod-alt #x04)
|
||||||
|
;; (define mod-gui #x08)
|
||||||
|
;; (define mod-fn #x16)
|
||||||
|
|
9
layout.scm
Normal file
9
layout.scm
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
(define layout
|
||||||
|
(list (list key-q key-w key-e key-r key-t 0
|
||||||
|
key-y key-u key-i key-o key-p)
|
||||||
|
(list key-a key-s key-d key-f key-g 0
|
||||||
|
key-h key-j key-k key-l key-semicolon)
|
||||||
|
(list key-z key-x key-c key-v key-b mod-alt
|
||||||
|
key-n key-m key-comma key-period key-slash)
|
||||||
|
(list key-esc key-tab mod-gui mod-shift key-backspace mod-ctrl
|
||||||
|
key-space mod-fn key-dash key-quote key-enter)))
|
35
menelaus.scm
35
menelaus.scm
|
@ -1,22 +1,29 @@
|
||||||
;; -*- scheme -*-
|
|
||||||
|
|
||||||
(include "keycodes.scm")
|
(include "keycodes.scm")
|
||||||
|
(include "layout.scm")
|
||||||
|
|
||||||
(define column-pins (list 11 12 18 19 10 7 8 9 5 6))
|
(define row-pins (list 0 1 2 3))
|
||||||
(define layout (list key-a key-s key-d key-f key-g
|
(define column-pins (list 11 12 18 19 10 4 7 8 9 5 6))
|
||||||
key-h key-j key-k key-l key-semicolon))
|
|
||||||
|
|
||||||
(define (scan-column column-pins layout pressed)
|
(define (scan-column columns row-layout pressed)
|
||||||
(if (null? column-pins)
|
(if (null? columns)
|
||||||
pressed
|
pressed
|
||||||
(scan-column (cdr column-pins)
|
(scan-column (cdr columns)
|
||||||
(cdr layout)
|
(cdr row-layout)
|
||||||
(if (low? (car column-pins))
|
(if (low? (car columns))
|
||||||
(car layout)
|
(car row-layout)
|
||||||
pressed))))
|
pressed))))
|
||||||
|
|
||||||
|
(define (scan-rows rows layout-rows pressed)
|
||||||
|
(if (null? rows)
|
||||||
|
pressed
|
||||||
|
(begin
|
||||||
|
(for-each high row-pins)
|
||||||
|
(low (car rows)) ; activate row
|
||||||
|
(scan-rows (cdr rows) (cdr layout-rows)
|
||||||
|
(scan-column column-pins (car layout-rows) 0)))))
|
||||||
|
|
||||||
(define (loop)
|
(define (loop)
|
||||||
(let ((pressed (scan-row column-pins layout 0)))
|
(let ((pressed (scan-rows row-pins layout 0)))
|
||||||
(call-c-func "usb_send" 0 pressed 0 0 0 0 0))
|
(call-c-func "usb_send" 0 pressed 0 0 0 0 0))
|
||||||
(loop))
|
(loop))
|
||||||
|
|
||||||
|
@ -27,8 +34,7 @@
|
||||||
#x23 #x23 #x23 #x29 #x2D #x2D))
|
#x23 #x23 #x23 #x29 #x2D #x2D))
|
||||||
(set! arduino-pins (vector 4 8 2 1 16 64 128 64 16 32 64 128 64 128
|
(set! arduino-pins (vector 4 8 2 1 16 64 128 64 16 32 64 128 64 128
|
||||||
8 2 4 32 65 128))
|
8 2 4 32 65 128))
|
||||||
(output 1)
|
(for-each output row-pins)
|
||||||
(low 1)
|
|
||||||
(for-each input column-pins)
|
(for-each input column-pins)
|
||||||
(for-each high column-pins) ; activate pullup resistors
|
(for-each high column-pins) ; activate pullup resistors
|
||||||
(call-c-func "usb_init")
|
(call-c-func "usb_init")
|
||||||
|
@ -36,4 +42,3 @@
|
||||||
|
|
||||||
(init)
|
(init)
|
||||||
(loop)
|
(loop)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue