refactor(doorbell-touch): add build harness with monitor agent and board-specific setup
This commit is contained in:
131
mise.toml
131
mise.toml
@@ -6,6 +6,7 @@
|
||||
[tools]
|
||||
hk = "latest"
|
||||
pkl = "latest"
|
||||
# screen = "latest" # Install via system package manager (brew install screen / apt install screen)
|
||||
# zellij = "latest" # Install manually if needed (brew install zellij)
|
||||
|
||||
# Usage:
|
||||
@@ -36,8 +37,7 @@ arduino-cli compile --fqbn "$FQBN" --libraries ./libraries $LIBS --build-propert
|
||||
arduino-cli upload --fqbn "$FQBN" --port "$PORT" ./boards/$BOARD
|
||||
"""
|
||||
|
||||
[tasks.monitor]
|
||||
description = "Monitor (uses BOARD env var)"
|
||||
[tasks.monitor-raw]
|
||||
run = """
|
||||
source ./boards/$BOARD/board-config.sh
|
||||
source ./scripts/lockfile.sh
|
||||
@@ -67,95 +67,58 @@ source ./scripts/lockfile.sh
|
||||
kill_locked
|
||||
"""
|
||||
|
||||
[tasks.monitor]
|
||||
description = "Monitor agent with JSON log + command pipe (Python-based)"
|
||||
run = """
|
||||
python3 ./scripts/monitor-agent.py "$BOARD"
|
||||
"""
|
||||
|
||||
[tasks.log-tail]
|
||||
description = "Tail the logs with human-readable formatting"
|
||||
run = '''
|
||||
tail -f "/tmp/doorbell-$BOARD.jsonl" | while read -r line; do
|
||||
ts=$(echo "$line" | python3 -c "import sys,json; print(json.load(sys.stdin)['ts'])" 2>/dev/null)
|
||||
txt=$(echo "$line" | python3 -c "import sys,json; print(json.load(sys.stdin)['line'])" 2>/dev/null)
|
||||
if [[ "$txt" == *"[STATE]"* ]]; then
|
||||
echo -e "\\033[1;35m[$ts]\\033[0m $txt"
|
||||
elif [[ "$txt" == *"[ADMIN]"* ]]; then
|
||||
echo -e "\\033[1;36m[$ts]\\033[0m $txt"
|
||||
elif [[ "$txt" == *"[TOUCH]"* ]]; then
|
||||
echo -e "\\033[1;33m[$ts]\\033[0m $txt"
|
||||
elif [[ "$txt" == *"ALERT"* ]]; then
|
||||
echo -e "\\033[1;31m[$ts]\\033[0m $txt"
|
||||
else
|
||||
echo "[$ts] $txt"
|
||||
fi
|
||||
done
|
||||
'''
|
||||
|
||||
[tasks.cmd]
|
||||
description = "Send command to device (COMMAND=dashboard mise run cmd)"
|
||||
run = """
|
||||
echo -n "$COMMAND" > "/tmp/doorbell-$BOARD-cmd.fifo"
|
||||
echo "[SENT] $COMMAND"
|
||||
"""
|
||||
|
||||
[tasks.state]
|
||||
description = "Show current device state"
|
||||
run = """
|
||||
cat "/tmp/doorbell-$BOARD-state.json"
|
||||
"""
|
||||
|
||||
[tasks.install-libs-shared]
|
||||
description = "Install shared (platform-independent) libraries"
|
||||
description = "Install shared Arduino libraries"
|
||||
run = """
|
||||
arduino-cli lib install "ArduinoJson@7.4.1"
|
||||
arduino-cli lib install "NTPClient@3.2.1"
|
||||
echo "[OK] Shared libraries installed"
|
||||
./scripts/install-shared.sh
|
||||
"""
|
||||
|
||||
[tasks.install-libs-32e]
|
||||
description = "Vendor TFT_eSPI into vendor/esp32-32e"
|
||||
[tasks.install]
|
||||
description = "Install libraries for BOARD (shared + board-specific)"
|
||||
run = """
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [ ! -d "vendor/esp32-32e/TFT_eSPI" ]; then
|
||||
echo "Cloning TFT_eSPI..."
|
||||
git clone --depth 1 --branch V2.5.43 \
|
||||
https://github.com/Bodmer/TFT_eSPI.git \
|
||||
vendor/esp32-32e/TFT_eSPI
|
||||
fi
|
||||
echo "Copying board-specific User_Setup.h..."
|
||||
cp boards/esp32-32e/tft_user_setup.h vendor/esp32-32e/TFT_eSPI/User_Setup.h
|
||||
echo "[OK] TFT_eSPI 2.5.43 vendored + configured"
|
||||
./scripts/install-shared.sh
|
||||
./boards/$BOARD/install.sh
|
||||
"""
|
||||
|
||||
[tasks.install-libs-32e-4]
|
||||
description = "Vendor TFT_eSPI into vendor/esp32-32e-4 (ST7796 320x480)"
|
||||
run = """
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [ ! -d "vendor/esp32-32e-4/TFT_eSPI" ]; then
|
||||
echo "Cloning TFT_eSPI..."
|
||||
git clone --depth 1 --branch V2.5.43 \
|
||||
https://github.com/Bodmer/TFT_eSPI.git \
|
||||
vendor/esp32-32e-4/TFT_eSPI
|
||||
fi
|
||||
echo "Copying board-specific User_Setup.h..."
|
||||
cp boards/esp32-32e-4/tft_user_setup.h vendor/esp32-32e-4/TFT_eSPI/User_Setup.h
|
||||
echo "[OK] TFT_eSPI 2.5.43 vendored + configured for 4 inch"
|
||||
"""
|
||||
|
||||
[tasks.install-libs-s3-43]
|
||||
description = "Vendor LovyanGFX into vendor/esp32-s3-lcd-43"
|
||||
run = """
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
LOVyanGFX_DIR="vendor/esp32-s3-lcd-43/LovyanGFX"
|
||||
|
||||
# Clone LovyanGFX (latest)
|
||||
if [ ! -d "$LOVyanGFX_DIR" ]; then
|
||||
echo "Cloning LovyanGFX..."
|
||||
git clone --depth 1 \
|
||||
https://github.com/lovyan03/LovyanGFX.git \
|
||||
"$LOVyanGFX_DIR"
|
||||
else
|
||||
echo "LovyanGFX already exists, skipping"
|
||||
fi
|
||||
|
||||
# Create library.properties that correctly points to source
|
||||
cat > "$LOVyanGFX_DIR/library.properties" << 'EOF'
|
||||
name=LovyanGFX
|
||||
version=1.2.0
|
||||
author=lovyan03
|
||||
maintainer=lovyan03
|
||||
sentence=Display and touch driver library for ESP32
|
||||
paragraph=Universal graphics library for ESP32 with support for various displays and touch controllers
|
||||
category=Display
|
||||
url=https://github.com/lovyan03/LovyanGFX
|
||||
architectures=esp32
|
||||
includes=LovyanGFX.hpp
|
||||
# This tells Arduino to build from src/
|
||||
# Arduino will look in src/ for .cpp files
|
||||
EOF
|
||||
|
||||
# Create a empty src to ensure sources are found
|
||||
mkdir -p "$LOVyanGFX_DIR/src"
|
||||
|
||||
echo "[OK] LovyanGFX vendored"
|
||||
"""
|
||||
|
||||
[tasks.install-libs]
|
||||
description = "Install all libraries (shared + vendored)"
|
||||
depends = [
|
||||
"install-libs-shared",
|
||||
"install-libs-32e",
|
||||
"install-libs-32e-4",
|
||||
"install-libs-s3-43",
|
||||
]
|
||||
|
||||
# Convenience
|
||||
|
||||
[tasks.clean]
|
||||
|
||||
Reference in New Issue
Block a user