Files
clawdmeter/flash.sh
T
Hermann Björgvin HaraldssonandClaude Opus 4.6 94d55a88d2 Add USB HID keyboard input via touch gestures
The SC01 Plus now acts as a composite USB device (CDC serial + HID keyboard).
Touch gestures on the screen send keystrokes to the computer:

- Swipe up/down: arrow keys
- Swipe right: Enter
- Swipe left: Shift+Tab (change mode in Claude Code)
- Double-tap logo: Ctrl+Space (voice mode)
- Tap and hold: Space (held while touching)

Gesture-to-key mapping is defined as a simple config table in hid.cpp.
Touch detection uses a state machine with configurable thresholds in touch.cpp.

Switches to TinyUSB composite mode (ARDUINO_USB_MODE=0). Flashing now
requires flash.sh which handles the DTR/RTS bootloader reset.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 17:29:06 +00:00

45 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
# Flash helper for TinyUSB mode firmware.
# The built-in JTAG bootloader doesn't auto-reset with TinyUSB, so we
# trigger a reset via DTR/RTS on the CDC serial port before flashing.
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PORT="${1:-/dev/ttyACM0}"
echo "=== Flashing Claude Usage Tracker ==="
echo "Port: $PORT"
echo ""
# Build first
echo "[1/3] Building firmware..."
cd "$SCRIPT_DIR/firmware"
~/.platformio/penv/bin/pio run
# Reset the device into bootloader via DTR/RTS
echo "[2/3] Resetting device into bootloader..."
python3 -c "
import serial, time
port = serial.Serial('$PORT', 115200)
port.dtr = False; port.rts = True; time.sleep(0.1)
port.dtr = True; port.rts = False; time.sleep(0.05)
port.dtr = False; time.sleep(0.1); port.close()
"
sleep 0.5
# Flash with no_reset (device is already in bootloader)
echo "[3/3] Flashing..."
python3 ~/.platformio/packages/tool-esptoolpy/esptool.py \
--chip esp32s3 \
--port "$PORT" \
--before no_reset \
--baud 921600 \
write_flash -z \
0x0 .pio/build/sc01plus/bootloader.bin \
0x8000 .pio/build/sc01plus/partitions.bin \
0xe000 ~/.platformio/packages/framework-arduinoespressif32/tools/partitions/boot_app0.bin \
0x10000 .pio/build/sc01plus/firmware.bin
echo ""
echo "=== Done! Device will reboot automatically. ==="