From 6d2ffeaa1cd136a29852d20722e781fe030ce6b9 Mon Sep 17 00:00:00 2001 From: Stefan Koelle Date: Sat, 1 Aug 2026 23:50:36 +0200 Subject: [PATCH] demo secrets and new build scripts --- include/secrets.h | 11 +++++++++++ scripts/build.cmd | 27 +++++++++++++++++++++++++++ scripts/build.sh | 25 +++++++++++++++++++++++++ scripts/deploy.cmd | 38 ++++++++++++++++++++++++++++++++++++++ scripts/deploy.sh | 29 ----------------------------- 5 files changed, 101 insertions(+), 29 deletions(-) create mode 100644 include/secrets.h create mode 100644 scripts/build.cmd create mode 100644 scripts/build.sh create mode 100644 scripts/deploy.cmd delete mode 100644 scripts/deploy.sh diff --git a/include/secrets.h b/include/secrets.h new file mode 100644 index 0000000..775d156 --- /dev/null +++ b/include/secrets.h @@ -0,0 +1,11 @@ +#pragma once + +// Copy this file to secrets.h and fill in your real values. +// secrets.h is git-ignored and must never be committed. + +#define WIFI_SSID "YOUR_WIFI_SSID" +#define WIFI_PASSWORD "YOUR_WIFI_PASSWORD" + +#define WEATHER_API_URL "http://:/api/weather" +#define CALENDAR_API_URL "http://:/api/events" +#define DEPARTURES_API_URL "http://:/api/departures" diff --git a/scripts/build.cmd b/scripts/build.cmd new file mode 100644 index 0000000..bf420da --- /dev/null +++ b/scripts/build.cmd @@ -0,0 +1,27 @@ +@echo off +REM Local build-only test script for Windows. +REM Compiles the project WITHOUT uploading to any device. +REM Usage: scripts\build.cmd + +setlocal +cd /d "%~dp0\.." + +set VENV_DIR=.venv-platformio + +if not exist "%VENV_DIR%" ( + echo Creating local virtualenv in %VENV_DIR% ... + python -m venv "%VENV_DIR%" + "%VENV_DIR%\Scripts\pip.exe" install --upgrade pip + "%VENV_DIR%\Scripts\pip.exe" install platformio +) + +echo Running build (no upload) ... +"%VENV_DIR%\Scripts\pio.exe" run + +if errorlevel 1 ( + echo Build FAILED. + exit /b 1 +) + +echo Build finished successfully. +endlocal diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100644 index 0000000..dd6aa55 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Local build-only test script for Linux/macOS. +# Compiles the project WITHOUT uploading to any device. +# Useful to quickly check "does it even compile" without touching the M5Stack. +# +# Usage: +# ./scripts/build.sh + +cd "$(dirname "$0")/.." + +VENV_DIR=".venv-platformio" + +if [ ! -d "$VENV_DIR" ]; then + echo "Creating local virtualenv in $VENV_DIR ..." + python3 -m venv "$VENV_DIR" + "$VENV_DIR/bin/pip" install --upgrade pip + "$VENV_DIR/bin/pip" install platformio +fi + +echo "Running build (no upload) ..." +"$VENV_DIR/bin/pio" run + +echo "Build finished successfully." diff --git a/scripts/deploy.cmd b/scripts/deploy.cmd new file mode 100644 index 0000000..958464c --- /dev/null +++ b/scripts/deploy.cmd @@ -0,0 +1,38 @@ +@echo off +REM Build + flash the M5Stack Dashboard project via PlatformIO on Windows. +REM +REM Usage: +REM scripts\deploy.cmd (auto-detect USB port) +REM scripts\deploy.cmd COM5 (force a specific port) +REM +REM Does NOT open the serial monitor afterwards. + +setlocal +cd /d "%~dp0\.." + +set VENV_DIR=.venv-platformio + +if not exist "%VENV_DIR%" ( + echo Creating local virtualenv in %VENV_DIR% ... + python -m venv "%VENV_DIR%" + "%VENV_DIR%\Scripts\pip.exe" install --upgrade pip + "%VENV_DIR%\Scripts\pip.exe" install platformio +) + +set PIO=%VENV_DIR%\Scripts\pio.exe + +if "%~1"=="" ( + echo Auto-detecting upload port... + "%PIO%" run --target upload +) else ( + echo Using forced upload port: %~1 + "%PIO%" run --target upload --upload-port %~1 +) + +if errorlevel 1 ( + echo Deploy FAILED. + exit /b 1 +) + +echo Build + flash complete. +endlocal diff --git a/scripts/deploy.sh b/scripts/deploy.sh deleted file mode 100644 index 602f377..0000000 --- a/scripts/deploy.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# Build + flash the M5Stack Dashboard project via PlatformIO. -# -# Usage: -# ./scripts/deploy.sh # auto-detect USB port -# ./scripts/deploy.sh /dev/ttyUSB0 # force a specific port -# -# This script intentionally does NOT open the serial monitor afterwards. - -cd "$(dirname "$0")/.." - -if ! command -v pio &> /dev/null; then - echo "Error: PlatformIO CLI ('pio') not found in PATH." - echo "Install it via: pip install -U platformio" - exit 1 -fi - -if [ "$#" -ge 1 ]; then - PORT="$1" - echo "Using forced upload port: $PORT" - pio run --target upload --upload-port "$PORT" -else - echo "Auto-detecting upload port..." - pio run --target upload -fi - -echo "Build + flash complete."