Browse Source

Add instructions, non-working firmware

master
Macoy Madson 6 months ago
parent
commit
2b1be9dfad
  1. 4
      Build.sh
  2. 17
      ReadMe.org
  3. 40
      src/Keypad.cake

4
Build.sh

@ -28,7 +28,7 @@ mv cakelisp_cache/Keypad/Keypad.cake.c cakelisp_cache/Keypad/Keypad.ino || exit
# mv cakelisp_cache/Keypad/LowPower.c cakelisp_cache/Keypad/LowPower.ino || exit $?
/media/macoy/Preserve/Programs/arduino-cli_0.29.0-rc.1_Linux_64bit/arduino-cli --no-color \
compile -b arduino:avr:uno ./cakelisp_cache/Keypad/Keypad.ino || exit $?
compile -b rp2040:rp2040:adafruit_kb2040 ./cakelisp_cache/Keypad/Keypad.ino || exit $?
/media/macoy/Preserve/Programs/arduino-cli_0.29.0-rc.1_Linux_64bit/arduino-cli --no-color \
upload -b arduino:avr:uno --port /dev/ttyACM0 ./cakelisp_cache/Keypad || exit $?
upload -b rp2040:rp2040:adafruit_kb2040 --port /dev/ttyACM0 ./cakelisp_cache/Keypad || exit $?

17
ReadMe.org

@ -1,3 +1,20 @@
#+title: Keyboards
This is my dumping ground for various physical keyboard firmware and designs.
* Building and running
Follow [[https://learn.adafruit.com/adafruit-kb2040/arduino-ide-setup][Arduino IDE Setup]].
In short:
- Get Arduino IDE (and Arduino Console while you're at it)
- Add ~https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json~ to ~Preferences > Additional Boards Manager URLs~
- Search for ~RP2040~ in Board Manager and install the ~Raspberry Pi Pico/RP2040 by Earle F Philhower, III~
The console board name is ~rp2040:rp2040:adafruit_kb2040~.
Run ~Build.sh~.
** Observing output
#+BEGIN_SRC sh
screen /dev/ttyACM0 115200
#+END_SRC
*** Killing screen sessions
~Ctrl + a~ then ~k~

40
src/Keypad.cake

@ -9,5 +9,41 @@
(import "CHelpers.cake")
(defun main (&return int)
(return 0))
(var column-pins (array (const int)) ;; receives power
(array 29 28 27 26)) ;; A3 A2 A1 A0
(var row-pins (array (const int)) ;; samples
(array 2 3 4 5 6)) ;; 2 3 4 5 6
(var matrix (array 4 (array 5 int)) (array 0))
(defun setup ()
(pinMode LED_BUILTIN OUTPUT)
(each-item-in-array column-pins column pin int
(pinMode pin OUTPUT)
(digitalWrite pin LOW))
(each-item-in-array row-pins row pin int
(pinMode pin INPUT_PULLUP))
(call-on begin Serial 115200)
(call-on println Serial "Keypad started up"))
(defun scan-matrix ()
(each-item-in-array column-pins column col-pin int
(digitalWrite col-pin HIGH)
(defer (digitalWrite col-pin LOW))
;; This should be way faster in production
(delay 30)
(each-item-in-array row-pins row row-pin int
(set (at column row matrix) (not (digitalRead row-pin))))))
(defun loop ()
(scan-matrix)
(call-on println Serial "\n-------")
(each-in-range 2 column
(each-in-range 2 row
(when (at column row matrix)
(call-on println Serial "----")
(call-on println Serial column)
(call-on println Serial row)
(call-on println Serial "ON"))))
;; wait for a bit
(delay 500))

Loading…
Cancel
Save