BLE HID Keyboard Firmware for Puck.js
Converts Puck.js button presses and gestures into Bluetooth keyboard/media key events. Pairs as a standard HID keyboard with any Bluetooth-enabled device.
graph TB
subgraph "Input"
BTN[Button]
TILT[Tilt Gesture]
NFC[NFC Tap]
end
subgraph "Modes"
MACRO[Macro Mode]
GESTURE[Gesture Mode]
MEDIA[Media Mode]
end
subgraph "Output"
KEYS[Key Press]
ARROWS[Arrow Keys]
PLAYBACK[Media Controls]
end
BTN --> MACRO
BTN --> MEDIA
TILT --> GESTURE
TILT --> MEDIA
NFC --> |Cycle| MACRO
NFC --> |Cycle| GESTURE
NFC --> |Cycle| MEDIA
MACRO --> KEYS
GESTURE --> ARROWS
MEDIA --> PLAYBACK
| Config | Example | Description |
|---|---|---|
CONFIG.macroKey = "copy" |
Ctrl+C | Use preset macro |
CONFIG.macroKey = "a" |
‘a’ | Single key |
CONFIG.macroModifier = MODIFIERS.CTRL |
Ctrl+key | Add modifier |
Preset Macros:
copy, paste, cut, undo, redosave, selectAll, findnewTab, closeTab, switchTabenter, escape, space| Tilt | Key |
|---|---|
| Up | Arrow Up |
| Down | Arrow Down |
| Left | Arrow Left |
| Right | Arrow Right |
| Action | Input | Result |
|---|---|---|
| Execute macro/key | Button press | Depends on mode |
| Cycle mode | NFC tap | Macro → Gesture → Media |
| Toggle on/off | Long press (1s) | Green (on) / Red (off) |
Via BLE console:
// Set macro to Ctrl+S (save)
CONFIG.macroKey = "save";
// Or custom key combo
CONFIG.macroKey = "s";
CONFIG.macroModifier = MODIFIERS.CTRL;
// Change mode
CONFIG.mode = "gesture"; // or "macro" or "media"
// Adjust gesture sensitivity
CONFIG.gestureThreshold = 3000;
// Send specific key
sendKey(kb.KEY.ENTER, 0);
// Send key with modifier
sendKey(kb.KEY.C, MODIFIERS.CTRL);
// Execute preset macro
sendMacro("copy");
// Type a string
typeString("Hello World");
// Get status
getTelemetry();
stateDiagram-v2
[*] --> MacroMode: Power on
MacroMode --> GestureMode: NFC tap
GestureMode --> MediaMode: NFC tap
MediaMode --> MacroMode: NFC tap
MacroMode --> Disabled: Long press
GestureMode --> Disabled: Long press
MediaMode --> Disabled: Long press
Disabled --> MacroMode: Long press
Use the Firmware Loader or Espruino Web IDE:
app.jssave()