I need to implement a Forth so I can write firmware for my keyboard so I can write actual code.
Instead of using this, it’s probably better to check out menelaus which is written in MicroScheme. But it could be interesting as a historical curiosity.
This is currently in the middle of a port from the AVR Teensy 2 to the ARM Teensy 3, and it’s not exactly functional yet.
This Forth dialect is a bit weird for two reasons: 0) it was originally designed to run on a chip that has 32kb of flash for storage of C programs but only 2.5kb of RAM for Forth programs and data combined. Because of this, it is less self-hosting than is traditional. 1) It’s also implemented by someone who has barely used Forth and doesn’t really know C.
We use malloc rather than managing our own heap. This gives us a bit
more flexibility, but it also means things like
allot can’t just
assume a contiguous section of dictionary space, so it works more like
variable than traditional
allot. There are
probably other weird idiosyncrasies, but I’m not familiar enough with
Forth to spot them.
rows: 14, 15, 20, 21
cols: 0-8, 11, 12
- 9,10: PWM, serial
- 13: LED
- 16-19: analog, I2C, touch
- 22, 23: analog, PWM, touch
- for each row
- read columns for the current row
- check to see if this row has changed since the last read
- if so, set debounce for this row to cols; reset debounce counter
- if debounce counter
- decrement debounce counter
- if decremented to zero
- set the current matrix row to the last read value