SHA256
53 lines
1.3 KiB
Bash
Executable File
53 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
MODE="${1:-potentiometer-adc-test}"
|
|
PORT="${PORT:-}"
|
|
|
|
case "$MODE" in
|
|
potentiometer-adc-test)
|
|
SKETCH_DIR="$ROOT_DIR/test_sketches/potentiometer_adc_test"
|
|
BUILD_DIR="$ROOT_DIR/.arduino-build/build-potentiometer-adc-test"
|
|
;;
|
|
potentiometer-breath-monitor)
|
|
SKETCH_DIR="$ROOT_DIR/test_sketches/potentiometer_breath_monitor"
|
|
BUILD_DIR="$ROOT_DIR/.arduino-build/build-potentiometer-breath-monitor"
|
|
;;
|
|
*)
|
|
echo "Unknown mode: $MODE" >&2
|
|
echo "Known modes: potentiometer-adc-test, potentiometer-breath-monitor" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
if [[ -z "$PORT" ]]; then
|
|
PORT="$(arduino-cli board list | awk '/ttyACM|ttyUSB/ {print $1; exit}')"
|
|
fi
|
|
|
|
if [[ -z "$PORT" ]]; then
|
|
echo "No serial port found. Set PORT=/dev/ttyACM0 explicitly." >&2
|
|
exit 1
|
|
fi
|
|
|
|
FQBN="esp32:esp32:esp32s3:USBMode=hwcdc,CDCOnBoot=cdc,UploadSpeed=921600,CPUFreq=240,FlashMode=dio,FlashSize=16M,PartitionScheme=app3M_fat9M_16MB,PSRAM=opi"
|
|
|
|
echo "== Mode: $MODE"
|
|
echo "== Sketch: $SKETCH_DIR"
|
|
echo "== Port: $PORT"
|
|
echo "== FQBN: $FQBN"
|
|
|
|
arduino-cli compile \
|
|
--fqbn "$FQBN" \
|
|
--build-path "$BUILD_DIR" \
|
|
"$SKETCH_DIR"
|
|
|
|
arduino-cli upload \
|
|
--fqbn "$FQBN" \
|
|
-p "$PORT" \
|
|
--input-dir "$BUILD_DIR" \
|
|
"$SKETCH_DIR"
|
|
|
|
echo
|
|
echo "== Done."
|