IoT macro pad. Thought that internet-connected lightbulbs were a bad idea? Well I internet-connected a keyboard.
Basically a normal macro pad that can interface with your smart home.
- Base keyboard layer
- Layer with serial output
- ESPhome (ESP8266)
- Home Assistant blueprint
- Display
- Encoder
- Get the hardware out of prototype stage and make a PCB
The baud rate can be configured in config.h
, the default is #define SERIAL_BAUD 9600
.
As an example, the format of the data for a single tap of the first key is:
Byte | 1st | 2nd | 3rd | 4th |
---|---|---|---|---|
Output | 0 | 0 | T | \n |
The serial layer outputs (with the default 8-key UART layer) 4 bytes when the key is tapped, held, double-tapped, or held after a tap, and after their release. It handles invalid tap dances (triple tap, triple hold, etc) with an invalid code, and in that case it doesn't output a release code.
The first 2 bytes are the number of the key (by default, 00 to 07). The fourth is always a newline. The third byte contains the type of press:
Code | Description |
---|---|
T | Tap |
H | Hold |
D | Double-tap |
B | Both (double tap ending with a hold) |
R | Release |
X | Invalid |
ESPhome exposes a text sensor/action entity to Home Assistant with the key code. The included blueprint parses the code and runs the action picked by the user.
Due to limitations of Home Assistant, I can't add accordions or anything like that to make the blueprint easier to look at.
- Add new codes in
uart_tap_dance.h
inside thedance_kcodes
enum. - In
uart_tap_dance.c
add elements in thetap_dance_actions
array, one for each of the new codes. They contain theACTION_TAP_DANCE_FN_ADVANCED
macro that accepts three functions as parameters (first tap of the key, end of tap dance, and release).- Those functions can't have parameters: basically, it means you'll have to repeat a lot of code with differently named functions. Solving this would require changes to the QMK code, so this is out of my and your control (unless you feel like making a pull request to QMK). With that said, since the use case allowed it, I tried to minimize the issue, check the functions I wrote.
- Add the keys to the keymap using
TD(keycode)
. - Add input boxes, code variables, and triggers to
hakase_blueprint.yaml
.
- Add new codes in
uart_tap_dance.h
inside thetd_state_t
enum. - In
uart_tap_dance.c
adjust the switch-cases in both thecurr_dance()
,dance_reg_switching()
, anduart_data_code()
functions. - Add input boxes, code variables, and triggers to
hakase_blueprint.yaml
.