Custom firmware for a 3-key + rotary encoder macropad.
Forked from biemster/3keys_1knob, which is based on wagiminator/CH552-Macropad-mini.
Compared to original, keypresses are generated on key release, to allow key combinations.
Also, layer and combination support is added, and sending multimedia (consumer) keycodes.
$ make bin
- if on original firmware: connect P1.5 to GND and connect USB
- alternate method, on some boards: USB- to 3.3V, using 10k resistor
- if on this firmware: press key1 while connecting USB
- alternate method: press and hold all three keys
$ make flash
$ make get_isp(first time only)$ make dump- edit
flashdata.bin(for example withhexedit) $ make data
| Position | Layer | Key 1 | Key 2 | Key 3 | Encoder Switch | Encoder CW | Encoder CCW | Foreground | Max layers |
|---|---|---|---|---|---|---|---|---|---|
0-15 |
0 |
MMCC |
MMCC |
MMCC |
MMCC |
MMCC |
MMCC |
RRGGBB |
NN |
| Position | Layer | Key 1+2 | Key 2+3 | Key 1+3 | Encoder pressed CW | Encoder pressed CCW | Fade | Encoder pressed CW | Background | Encoder pressed CCW |
|---|---|---|---|---|---|---|---|---|---|---|
16-32 |
0 |
MMCC |
MMCC |
MMCC |
CC |
CC |
RRGGBB |
MM |
RRGGBB |
MM |
Layers 1, 2, 3 and have the same layout. Layer 1 starts at 33, and so on.
Max layers exists only on layer 0. On others, this value can be used as delay, if layer is used as sequence (delay will be value * ~100 ms).
MMCC- four bytes, key settingsMM- modifier:- if set to
0xFF, character code will be sent as Consumer Keyboard Keycode- also, character codes
0xF0-0xFB(0xFFF0-0xFFFB) allow layer manipulation.
- also, character codes
- otherwise, modifier keys bits in order:
(7) RG RA RS RC LG LA LS LC (0) R- right,L- left,C- ctrl,S- shift,A- alt,G- gui (win)
- if set to
CC- keycode (ASCII, or fromusb_conkbd.h)- also layer manipulation, when
MMis set to0xFF:0xF0-0xF3: setlayerto0-3,0xF5-0xF8: setmax layerto0-3,0xFA: switch to layer-1,0xFB: switch to layer+1.0xFD: print currentlayeras 1 character.
- also layer manipulation, when
MMandCC- encoder pressed settings are split into two halves- this indicates settings for when encoder is pressed down and then turned
- it is active only when layers are disabled (
max_layersset to0)
RRGGBB- 24-bit colour, byte for red, green and blue:- foreground - layer colour, used when switching, and after switch has been pressed,
- background - default level, foreground will fade out to it,
- fade - fade step, each loop removes these values from current level, until background level is reached,
max layers-NN-0-3controls keyboard behaviour, as explained below.
As data memory is very limited, some tradeoffs had to be made.
This keyboard can operate in four different modes, as selected by max layers value.
0- only layer0is active, but each key can use up to four keys in sequence.- first key from layer
0will be pressed, then from1,2, and3
- first key from layer
1- layers0and3will be active. Up to three keys on layer0, and one on3.- layer
0will press keys from0,1, and2
- layer
2- layers0,2, and3active, layer0uses keys from0and1, in sequence.3- all layers are active, no sequences available, only one keypress per layer.
To switch between layers:
- press and hold encoder's switch to switch to layer
0, - assign keycodes from group
0xFFF0-0xFFFFto switch to other layers.