Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08960c9eec | ||
|
|
f0c21af220 | ||
|
|
8602ee3add |
@@ -0,0 +1,128 @@
|
||||
---
|
||||
name: build-firmware
|
||||
description: Compile the espresso_frame ESP32-C6 firmware (firmware/) for both board variants without Docker -- a native, non-container ESP-IDF v6.0 install. Use when asked to build the firmware, verify a firmware/main/*.c change actually compiles, or check both the devkit and xiao board targets.
|
||||
---
|
||||
|
||||
Compiles `firmware/` (ESP-IDF, targeting ESP32-C6) locally, without
|
||||
Docker -- CI's `firmware-build-check.yml`/`firmware-release-build.yml`
|
||||
build inside the `espressif/idf:release-v6.0` container image, but
|
||||
**this sandbox cannot run containers at all**: `docker.io` installs and
|
||||
`dockerd` starts fine even as root, but the sandbox strips
|
||||
`cap_sys_admin` (and blocks the bare `unshare` syscall) from the
|
||||
capability set regardless of uid, which container image-layer
|
||||
extraction and namespace setup both require. Confirmed by hand:
|
||||
`docker run hello-world` fails to extract even the tiny hello-world
|
||||
layer ("failed to extract layer... operation not permitted" with the
|
||||
overlayfs snapshotter; "unshare: operation not permitted" even with
|
||||
the vfs storage driver instead). This is a hard restriction of the
|
||||
sandbox itself, not a permissions/setup problem -- don't spend time
|
||||
re-trying `--privileged`-equivalent flags or alternate storage drivers,
|
||||
none of it routes around a missing `cap_sys_admin`.
|
||||
|
||||
The workaround: skip containers entirely and install ESP-IDF the same
|
||||
way a developer would set it up on their own machine (`git clone` +
|
||||
ESP-IDF's own `install.sh`) -- that path needs nothing this sandbox
|
||||
disallows, just normal file/process operations.
|
||||
|
||||
## Setup (once per fresh container)
|
||||
|
||||
```bash
|
||||
bash .claude/skills/build-firmware/setup.sh
|
||||
```
|
||||
|
||||
Installs (via real `apt-get` -- this container actually has root and a
|
||||
working package manager, unlike run-server's Chromium bootstrap which
|
||||
had neither):
|
||||
- OS build deps: `python3`/`venv`/`pip`, `cmake`, `ninja-build`,
|
||||
`flex`/`bison`/`gperf`, `build-essential`, `libusb-1.0-0`.
|
||||
- ESP-IDF itself: a shallow, single-branch, recursive-submodule clone
|
||||
of `release/v6.0` (~700MB) into `~/.espressif-idf/esp-idf` -- matches
|
||||
the IDF version CI's Docker image pins. Only clones once; re-running
|
||||
`setup.sh` never touches an existing checkout.
|
||||
- The esp32c6 toolchain + Python venv, via ESP-IDF's own
|
||||
`./install.sh esp32c6` -- scoped to just this project's one target
|
||||
(see `firmware/README.md`'s board table), not every chip ESP-IDF
|
||||
supports, to keep the download/disk footprint down. `install.sh` is
|
||||
already idempotent on its own, so `setup.sh` always calls it rather
|
||||
than duplicating that check -- a re-run costs a few seconds once
|
||||
everything's cached.
|
||||
|
||||
Takes a few minutes on a cold run (mostly `install.sh`'s own pip/tool
|
||||
downloads), well under a minute on a re-run. Needs real root (`apt-get
|
||||
install`) -- if this container ever runs as non-root, this setup
|
||||
doesn't apply as-is (would need the same non-root apt-download +
|
||||
`dpkg-deb -x` extraction dance `run-server`'s `setup.sh` uses for
|
||||
Chromium).
|
||||
|
||||
Disk: budget ~4GB free before starting (esp-idf checkout + toolchain +
|
||||
Python env land around 3.4GB in `~/.espressif`, plus the ~700MB
|
||||
checkout itself). Confirmed working with as little as ~7GB free.
|
||||
|
||||
## Build
|
||||
|
||||
```bash
|
||||
bash .claude/skills/build-firmware/build.sh # devkit (default)
|
||||
bash .claude/skills/build-firmware/build.sh xiao
|
||||
bash .claude/skills/build-firmware/build.sh both # both variants
|
||||
```
|
||||
|
||||
Each board gets its own build directory and generated sdkconfig (see
|
||||
`firmware/build_for_board.sh`'s own comment) -- building one never
|
||||
disturbs the other. `build.sh` auto-runs `set-target esp32c6` the very
|
||||
first time a board is built (no generated sdkconfig yet); later builds
|
||||
skip straight to `idf.py build`. Extra arguments pass straight through
|
||||
to `idf.py`, e.g.:
|
||||
|
||||
```bash
|
||||
bash .claude/skills/build-firmware/build.sh xiao flash -p /dev/ttyUSB0
|
||||
```
|
||||
|
||||
`flash`/`monitor` need an actual attached device and serial port --
|
||||
this sandbox has neither, so those only work when this skill runs
|
||||
somewhere hardware is actually plugged in (a real dev machine, or a
|
||||
differently-configured environment with device passthrough).
|
||||
|
||||
A clean build of one board takes ~30s once the target's already been
|
||||
configured (~1,000 build steps total split across both boards, most of
|
||||
it ESP-IDF's own components -- this project's own `firmware/main/*.c`
|
||||
and `firmware/components/*` sources are a small fraction of that and
|
||||
compile in a few seconds). Output lands at
|
||||
`firmware/build/espresso_frame.bin` (devkit) or
|
||||
`firmware/build_xiao/espresso_frame.bin` (xiao) -- both paths are
|
||||
gitignored (`firmware/.gitignore`... actually the repo root
|
||||
`.gitignore`'s "ESP-IDF firmware build output" section), so nothing
|
||||
here needs cleaning up before a commit.
|
||||
|
||||
## Verified
|
||||
|
||||
Both board variants (`devkit` set-target esp32c6 + build, `xiao`
|
||||
set-target esp32c6 + build) built successfully end-to-end using this
|
||||
exact setup.sh/build.sh pair, producing real
|
||||
`espresso_frame.bin` images with normal free-space margins (41%/36%
|
||||
of their respective app partitions) and no errors -- only one
|
||||
pre-existing, unrelated warning (`battery.c`'s unused `TAG` when that
|
||||
file's logging is compiled out). This is a real compile check, not
|
||||
just a syntax read -- if a future change breaks the build, this skill
|
||||
will actually catch it.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
- **`docker: ... unshare: operation not permitted` / `failed to
|
||||
extract layer ... operation not permitted`**: expected in this
|
||||
sandbox, see the top of this file. Don't debug it further -- use this
|
||||
skill's native install instead.
|
||||
- **`ESP-IDF not found at ... -- run setup.sh first`**: `build.sh`'s
|
||||
own check for a missing `$IDF_DIR/export.sh` -- run `setup.sh` (see
|
||||
above) before the first build.
|
||||
- **`idf.py: command not found` if you try to run it directly**: same
|
||||
gotcha `firmware/build_for_board.sh` already documents -- `idf.py` is
|
||||
normally a shell *function* from ESP-IDF's `export.sh`, not on PATH
|
||||
as a real executable, so it isn't inherited into a script's own
|
||||
subshell even after sourcing `export.sh` in your interactive shell
|
||||
first. Use `build.sh` (or `build_for_board.sh`, which calls
|
||||
`python "$IDF_PATH/tools/idf.py"` directly) instead of typing
|
||||
`idf.py` in a fresh script/subshell.
|
||||
- **Disk pressure during `install.sh`**: this environment runs close to
|
||||
full (single-digit GB free is normal, not a sign of a leak) --
|
||||
`df -h /` before running `setup.sh` if a build mysteriously fails
|
||||
partway with a "no space left on device"-shaped error.
|
||||
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# Builds (or flashes/monitors, if a serial port is actually attached)
|
||||
# the espresso_frame firmware for one board variant, via the project's
|
||||
# own firmware/build_for_board.sh -- this script just sources the
|
||||
# ESP-IDF environment first and auto-runs `set-target esp32c6` on a
|
||||
# board's very first build (a fresh clone has no generated sdkconfig
|
||||
# yet, same reasoning as CI's own build steps -- see firmware/README.md's
|
||||
# "Building for the Seeed XIAO ESP32-C6" section).
|
||||
#
|
||||
# Usage:
|
||||
# build.sh # build devkit (default)
|
||||
# build.sh devkit
|
||||
# build.sh xiao
|
||||
# build.sh both # build both board variants
|
||||
# build.sh xiao flash -p /dev/ttyUSB0 # only meaningful with real hardware attached
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
firmware_dir="$(git -C "$script_dir" rev-parse --show-toplevel)/firmware"
|
||||
|
||||
IDF_DIR="$HOME/.espressif-idf/esp-idf"
|
||||
if [ ! -f "$IDF_DIR/export.sh" ]; then
|
||||
echo "ESP-IDF not found at $IDF_DIR -- run setup.sh first" >&2
|
||||
exit 1
|
||||
fi
|
||||
# export.sh is chatty and assumes an interactive shell prompt in spots;
|
||||
# redirect its own stdout, not ours, so build.sh's actual output (and a
|
||||
# real failure's stderr) stays visible.
|
||||
source "$IDF_DIR/export.sh" > /dev/null
|
||||
|
||||
cd "$firmware_dir"
|
||||
|
||||
build_one() {
|
||||
local board="$1"
|
||||
shift
|
||||
local sdkconfig
|
||||
case "$board" in
|
||||
devkit) sdkconfig="sdkconfig" ;;
|
||||
xiao) sdkconfig="sdkconfig.xiao_local" ;;
|
||||
*) echo "Unknown board '$board' -- expected 'devkit' or 'xiao'" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
if [ ! -f "$sdkconfig" ]; then
|
||||
echo "==> $board: no generated sdkconfig yet, setting target esp32c6"
|
||||
./build_for_board.sh "$board" set-target esp32c6
|
||||
fi
|
||||
|
||||
local args=("$@")
|
||||
if [ ${#args[@]} -eq 0 ]; then
|
||||
args=(build)
|
||||
fi
|
||||
./build_for_board.sh "$board" "${args[@]}"
|
||||
}
|
||||
|
||||
board="${1:-devkit}"
|
||||
shift || true
|
||||
|
||||
if [ "$board" = "both" ]; then
|
||||
build_one devkit "$@"
|
||||
build_one xiao "$@"
|
||||
else
|
||||
build_one "$board" "$@"
|
||||
fi
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
# One-time (idempotent) environment bootstrap for compiling the
|
||||
# espresso_frame firmware (firmware/) without Docker -- see this
|
||||
# skill's SKILL.md for why not Docker, even though that's what CI uses.
|
||||
# Re-run any time; every step is safe/fast to repeat once already done.
|
||||
set -euo pipefail
|
||||
|
||||
IDF_ROOT="$HOME/.espressif-idf"
|
||||
IDF_DIR="$IDF_ROOT/esp-idf"
|
||||
# Matches the espressif/idf:release-v6.0 image CI's
|
||||
# firmware-build-check.yml/firmware-release-build.yml use -- keep this
|
||||
# in sync with those workflow files if the project's pinned IDF version
|
||||
# ever changes.
|
||||
IDF_BRANCH="release/v6.0"
|
||||
|
||||
# 1. OS packages ESP-IDF's own install.sh needs (python3 + venv/pip,
|
||||
# cmake, ninja, a C toolchain for the odd host-side code generator, git
|
||||
# for the clone below, flex/bison/gperf for mbedtls/etc.'s generated
|
||||
# parsers, libusb for esptool's USB/JTAG bits even though this skill
|
||||
# doesn't flash real hardware). Installed via apt with real root --
|
||||
# unlike run-server's Chromium bootstrap, this container actually has
|
||||
# root and a working apt, so no non-root extraction dance is needed
|
||||
# here.
|
||||
PKGS="git python3 python3-venv python3-pip cmake ninja-build ccache libusb-1.0-0 wget flex bison gperf build-essential"
|
||||
missing=()
|
||||
for pkg in $PKGS; do
|
||||
dpkg -s "$pkg" >/dev/null 2>&1 || missing+=("$pkg")
|
||||
done
|
||||
if [ ${#missing[@]} -gt 0 ]; then
|
||||
echo "installing OS packages: ${missing[*]}"
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y "${missing[@]}"
|
||||
fi
|
||||
|
||||
# 2. ESP-IDF checkout -- shallow, single branch, recursive submodules
|
||||
# also shallow (~700MB total, vs. several GB for a full clone). Only
|
||||
# clones once; re-running this script never re-clones or resets it, so
|
||||
# any local changes you made for debugging survive a re-run.
|
||||
if [ ! -d "$IDF_DIR/.git" ]; then
|
||||
echo "cloning esp-idf $IDF_BRANCH into $IDF_DIR ..."
|
||||
mkdir -p "$IDF_ROOT"
|
||||
git clone --branch "$IDF_BRANCH" --depth 1 --shallow-submodules --recursive \
|
||||
https://github.com/espressif/esp-idf.git "$IDF_DIR"
|
||||
else
|
||||
echo "esp-idf already cloned at $IDF_DIR"
|
||||
fi
|
||||
|
||||
# 3. Toolchain + Python virtualenv, scoped to esp32c6 only -- this
|
||||
# project's one target (see firmware/README.md's board table). Scoping
|
||||
# avoids downloading toolchains for every chip ESP-IDF supports, which
|
||||
# matters given this container's disk headroom. install.sh is already
|
||||
# idempotent on its own (checks what's present and skips it), so this
|
||||
# always calls it rather than trying to duplicate that check here --
|
||||
# a re-run only costs a few seconds once everything's cached.
|
||||
echo "running esp-idf install.sh esp32c6 (fast if already installed) ..."
|
||||
(cd "$IDF_DIR" && ./install.sh esp32c6)
|
||||
|
||||
echo "setup complete -> $IDF_DIR/export.sh (build.sh sources this for you)"
|
||||
@@ -7,13 +7,9 @@ image processing (crop/dither/quantize/pack), and serves a placeable
|
||||
photos/calendar/whiteboard/weather widget system to the device.
|
||||
|
||||
CURRENT TODO
|
||||
-add more actions for buttons (i.e. change widget/layout)
|
||||
-Fix spurious button assignment stuff (probably but buttons on widget config with sane defaults)
|
||||
-battery life widget
|
||||
-sharing layouts with linked users
|
||||
-a "coming up this week" widget
|
||||
-scan to download for non-immich photos too?
|
||||
-switch button reset action? and on reset dismiss the menu.
|
||||
-on reset dismiss the menu.
|
||||
|
||||
Start here, don't re-derive from scratch:
|
||||
- [`docs/architecture.md`](docs/architecture.md) -- how firmware and
|
||||
|
||||
@@ -102,9 +102,9 @@ placement grid, and button-action dispatch.
|
||||
- Deep sleep for the server-configured interval on success, or a
|
||||
shorter retry interval on any failure.
|
||||
|
||||
The menu/reset button's soft-reset and factory-reset tiers (held ~3s
|
||||
or ~15s) are handled earlier, before any of this, and never return --
|
||||
see [`firmware/README.md`](../firmware/README.md#managing-the-queue-soft-resetting-and-factory-resetting).
|
||||
The menu/reset button's soft-reset (quick press) and factory-reset
|
||||
(held ~15s) tiers are handled earlier, before any of this, and never
|
||||
return -- see [`firmware/README.md`](../firmware/README.md#managing-the-queue-soft-resetting-and-factory-resetting).
|
||||
|
||||
See [`docs/hardware.md`](hardware.md) for wiring and
|
||||
[`server/README.md`](../server/README.md) for the server side.
|
||||
|
||||
+4
-4
@@ -40,10 +40,10 @@ pressed):
|
||||
photo; see
|
||||
[`firmware/README.md`](../firmware/README.md#going-back-to-the-previous-photo).
|
||||
- **Menu / reset (GPIO1)**: one button, three actions by hold duration --
|
||||
a quick press overlays a "scan to manage" QR code on the current photo
|
||||
for 30 seconds; holding ~3s then releasing soft-resets the device
|
||||
(config kept); holding ~15s factory-resets it (clears WiFi/server
|
||||
config, reprovisions); see
|
||||
a quick press soft-resets the device (config kept); holding ~3s then
|
||||
releasing overlays a "scan to manage" QR code on the current photo for
|
||||
30 seconds; holding ~15s factory-resets it (clears WiFi/server config,
|
||||
reprovisions); see
|
||||
[`firmware/README.md`](../firmware/README.md#managing-the-queue-soft-resetting-and-factory-resetting).
|
||||
|
||||
All three pins were picked because they're within GPIO 0-7 -- the only
|
||||
|
||||
+12
-11
@@ -66,7 +66,7 @@ Under **ESPresso Frame Configuration**:
|
||||
| `FRAME_NEXT_BUTTON_GPIO` | 2 | Next-photo button GPIO (-1 to disable). Must be 0-7 (ESP32-C6's deep-sleep-wakeup-capable pins) |
|
||||
| `FRAME_BACK_BUTTON_GPIO` | 0 | Back-photo button GPIO (-1 to disable). Must be 0-7 |
|
||||
| `FRAME_COMBO_BUTTON_GPIO` | 1 | Menu/reset button GPIO (-1 to disable). Must be 0-7 |
|
||||
| `FRAME_COMBO_SOFT_RESET_HOLD_MS` | 3000 | How long the combo button must be held (then released) to soft-reset |
|
||||
| `FRAME_COMBO_MENU_HOLD_MS` | 3000 | How long the combo button must be held (then released) to show the management menu |
|
||||
| `FRAME_COMBO_FACTORY_RESET_HOLD_MS` | 15000 | How long the combo button must be held to factory-reset |
|
||||
| `FRAME_HOLD_ACTION_MS` | 3000 | **Fallback only** -- how long NEXT/BACK must be held to trigger a global action instead of a short press; see below |
|
||||
| `FRAME_BATTERY_ADC_GPIO` | -1 (disabled) | Battery voltage-divider ADC GPIO; see the Battery section below |
|
||||
@@ -294,9 +294,13 @@ One more button, wired between GPIO1 and GND (same wiring style as the
|
||||
other buttons), covers three actions -- disambiguated purely by how
|
||||
long it's held:
|
||||
|
||||
**A quick press** wakes the device and overlays several corners of
|
||||
whatever photo is currently showing, leaving the middle of the photo
|
||||
visible and unchanged:
|
||||
**A quick press** soft-resets the device -- `esp_restart()`, keeping the
|
||||
stored WiFi/server config. Useful for recovering a hung device without
|
||||
losing setup.
|
||||
|
||||
**Holding it ~3 seconds, then releasing** wakes the device (if asleep)
|
||||
and overlays several corners of whatever photo is currently showing,
|
||||
leaving the middle of the photo visible and unchanged:
|
||||
|
||||
- **Top-right**: a QR code -- "SCAN TO MANAGE" -- linking to the
|
||||
server's config page.
|
||||
@@ -315,8 +319,9 @@ for faces Immich hasn't been told a name for; no face detection happens
|
||||
on the device or the server, this is entirely Immich's own People
|
||||
feature). A third press exits immediately rather than waiting out the
|
||||
30-second timer. Holding the button during this stage doesn't trigger
|
||||
either reset tier below -- the hold-duration read only ever happens
|
||||
once, right when the device first wakes, before any menu is shown.
|
||||
the factory-reset tier below -- the hold-duration read only ever
|
||||
happens once, right when the device first wakes, before any menu is
|
||||
shown.
|
||||
|
||||
The device stays awake for the whole menu interaction (up to three
|
||||
physical refreshes: the base overlay, the escalated one, and
|
||||
@@ -324,17 +329,13 @@ reverting), so this costs meaningfully more power than a normal wake --
|
||||
expected for a deliberate, occasional action, same tradeoff as the
|
||||
other buttons.
|
||||
|
||||
**Holding it ~3 seconds, then releasing** soft-resets the device --
|
||||
`esp_restart()`, keeping the stored WiFi/server config. Useful for
|
||||
recovering a hung device without losing setup.
|
||||
|
||||
**Holding it ~15 seconds** (whether or not you're still holding it --
|
||||
this fires immediately, it doesn't wait for release) clears the stored
|
||||
WiFi/server config and restarts into provisioning. From either power-on
|
||||
or while the device is deep-asleep, since this GPIO is armed as a
|
||||
wakeup source.
|
||||
|
||||
See `FRAME_COMBO_BUTTON_GPIO`, `FRAME_COMBO_SOFT_RESET_HOLD_MS`, and
|
||||
See `FRAME_COMBO_BUTTON_GPIO`, `FRAME_COMBO_MENU_HOLD_MS`, and
|
||||
`FRAME_COMBO_FACTORY_RESET_HOLD_MS` above to change the pin or hold
|
||||
durations, or disable all three actions.
|
||||
|
||||
|
||||
@@ -154,13 +154,12 @@ menu "ESPresso Frame Configuration"
|
||||
Button wired between this GPIO and GND (active-low, internal
|
||||
pull-up enabled in firmware -- no external resistor needed).
|
||||
One pin, three actions depending on how long it's held:
|
||||
a quick press shows the management menu (same as before);
|
||||
holding it FRAME_COMBO_SOFT_RESET_HOLD_MS then releasing
|
||||
soft-resets the device (reboots, keeps the stored WiFi/
|
||||
server config); holding it all the way to
|
||||
FRAME_COMBO_FACTORY_RESET_HOLD_MS clears the stored config
|
||||
and restarts into provisioning, regardless of whether it's
|
||||
released yet. Must be GPIO 0-7 for the same deep-sleep-
|
||||
a quick press soft-resets the device (reboots, keeps the
|
||||
stored WiFi/server config); holding it FRAME_COMBO_MENU_HOLD_MS
|
||||
then releasing shows the management menu; holding it all the
|
||||
way to FRAME_COMBO_FACTORY_RESET_HOLD_MS clears the stored
|
||||
config and restarts into provisioning, regardless of whether
|
||||
it's released yet. Must be GPIO 0-7 for the same deep-sleep-
|
||||
wakeup reason as FRAME_NEXT_BUTTON_GPIO above; defaults to
|
||||
a different pin than the other buttons. Set to -1 to
|
||||
disable the feature entirely (also disables the management
|
||||
@@ -168,14 +167,14 @@ menu "ESPresso Frame Configuration"
|
||||
reconfiguring then only works by erasing NVS over USB, see
|
||||
firmware/README.md).
|
||||
|
||||
config FRAME_COMBO_SOFT_RESET_HOLD_MS
|
||||
int "Soft-reset hold duration (ms)"
|
||||
config FRAME_COMBO_MENU_HOLD_MS
|
||||
int "Management-menu hold duration (ms)"
|
||||
default 3000
|
||||
depends on FRAME_COMBO_BUTTON_GPIO >= 0
|
||||
help
|
||||
How long the menu/reset button must be held before releasing
|
||||
it triggers a soft reset (reboot, config kept). Long enough
|
||||
to be clearly distinct from a quick menu-opening press.
|
||||
it shows the management menu instead of soft-resetting. Long
|
||||
enough to be clearly distinct from a quick reset tap.
|
||||
|
||||
config FRAME_COMBO_FACTORY_RESET_HOLD_MS
|
||||
int "Factory-reset hold duration (ms)"
|
||||
@@ -185,8 +184,8 @@ menu "ESPresso Frame Configuration"
|
||||
How long the menu/reset button must be held continuously
|
||||
before the device clears its stored config and reboots into
|
||||
provisioning, regardless of release. Comfortably longer than
|
||||
FRAME_COMBO_SOFT_RESET_HOLD_MS so the two tiers can't be
|
||||
confused for each other.
|
||||
FRAME_COMBO_MENU_HOLD_MS so the two tiers can't be confused
|
||||
for each other.
|
||||
|
||||
config FRAME_HOLD_ACTION_MS
|
||||
int "Next/back hold-for-global-action duration (ms)"
|
||||
|
||||
@@ -53,8 +53,8 @@ bool combo_button_check(void)
|
||||
return false; /* not pressed, and didn't cause this wake either */
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Combo button held -- quick press for menu, %dms for soft reset, %dms for factory reset",
|
||||
CONFIG_FRAME_COMBO_SOFT_RESET_HOLD_MS, CONFIG_FRAME_COMBO_FACTORY_RESET_HOLD_MS);
|
||||
ESP_LOGI(TAG, "Combo button held -- quick press for soft reset, %dms for menu, %dms for factory reset",
|
||||
CONFIG_FRAME_COMBO_MENU_HOLD_MS, CONFIG_FRAME_COMBO_FACTORY_RESET_HOLD_MS);
|
||||
|
||||
int elapsed_ms = 0;
|
||||
while (gpio_get_level(COMBO_BUTTON_GPIO) == 0) {
|
||||
@@ -70,13 +70,13 @@ bool combo_button_check(void)
|
||||
}
|
||||
}
|
||||
|
||||
if (elapsed_ms >= CONFIG_FRAME_COMBO_SOFT_RESET_HOLD_MS) {
|
||||
ESP_LOGW(TAG, "Held %dms and released, soft-restarting (config kept)", elapsed_ms);
|
||||
esp_restart();
|
||||
if (elapsed_ms >= CONFIG_FRAME_COMBO_MENU_HOLD_MS) {
|
||||
ESP_LOGI(TAG, "Held %dms and released, showing management menu", elapsed_ms);
|
||||
return true;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Quick press (%dms), showing management menu", elapsed_ms);
|
||||
return true;
|
||||
ESP_LOGW(TAG, "Quick press (%dms), soft-restarting (config kept)", elapsed_ms);
|
||||
esp_restart();
|
||||
}
|
||||
|
||||
bool combo_button_is_pressed(void)
|
||||
|
||||
@@ -16,11 +16,11 @@ void combo_button_init(void);
|
||||
* Checks the combined menu/reset button and acts on how long it was
|
||||
* held, evaluated once per wake:
|
||||
* - Not pressed: returns false immediately.
|
||||
* - Released before CONFIG_FRAME_COMBO_SOFT_RESET_HOLD_MS (a quick
|
||||
* press): returns true -- caller should show the management menu.
|
||||
* - Released between the soft-reset and factory-reset thresholds: a
|
||||
* soft reset (esp_restart(), stored WiFi/server config kept) --
|
||||
* - Released before CONFIG_FRAME_COMBO_MENU_HOLD_MS (a quick press):
|
||||
* a soft reset (esp_restart(), stored WiFi/server config kept) --
|
||||
* never returns.
|
||||
* - Released between the menu and factory-reset thresholds: returns
|
||||
* true -- caller should show the management menu.
|
||||
* - Held through CONFIG_FRAME_COMBO_FACTORY_RESET_HOLD_MS: a factory
|
||||
* reset (frame_config_clear() + esp_restart(), fires immediately
|
||||
* without waiting for release) -- never returns.
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.4.0
|
||||
1.4.1
|
||||
|
||||
Reference in New Issue
Block a user