feat(m1): local time display and three-button monitoring (#6)
## Summary Two M1 firmware enhancements on the Waveshare ESP32-S3-RLCD-4.2: **Local-time display (UTC+8, fixed offset — China has no DST).** Internal time stays strictly UTC (RTC chip, JSONL `utc`, console `--json` keep the `Z`-suffixed machine format). Only human-facing surfaces convert via the new `board::kLocalUtcOffsetSeconds`: - display RTC line renders `unix + 8*3600` labeled `UTC+8` (split after the date: measured montserrat16 widths 157px + 119px fit the 179px status column; the old one-line layout was already 223px and overflowed) - text `status` and `rtc status` show the labeled UTC+8 line and keep both the raw unix and a UTC line - `rtc set` now takes UTC+8 local time (validates the local calendar round-trip, converts -8h before `set_rtc_time`); help/usage/README updated **Three buttons.** - KEY (GPIO18) unchanged (short <1s / long 1-3s / >=3s portal). - BOOT (GPIO0, strapping pin — input + pull-up, runtime read only): mirrors the KEY 30ms debounce and release bands (short <1s, long >=1s), new `boot_short_presses` / `boot_long_presses`, no portal binding. - RST is hardwired to chip reset, so it is tracked as a persistent boot counter: NVS namespace `frame`, key `rst_cnt`, incremented once per boot after `nvs_flash_init`, exposed as `reset_count`. - Surfaces: display `KEY:a/b BOOT:c/d` + `RST:e` lines, console text + `--json` (`boot_short`, `boot_long`, `reset_count`), JSONL `boot_short`/`boot_long` only — measured 594B worst observed line vs the 640B buffer (46B headroom, gate was >=40B); `reset_count` is static per boot so it is `--json`-only. ## On-device verification (34/34 deterministic asserts PASS + user assist) Evidence: `.omo/evidence/m1wp/tz-buttons-finish-m1-wifi-provisioning.log` - Build 0 warnings; clang-format 18.1.8 clean on whole `main/`. - `rtc status`/text status UTC+8 lines match host `date` +8h (<=3s skew); `rtc set` with a UTC+8 local time round-trips (`1788157541 = 14:25:41 local - 8h`). - JSONL `utc` unchanged UTC-with-Z, crc32c intact, max line 594B < 640. - KEY short press: +1 with BOOT unchanged (user-assisted). BOOT short: +2 (user-assisted). BOOT long: not physically exercised this session — code path is the device-proven KEY band logic (same constants); noted in `.omo/notepads` for the next bench session. - RST/reset_count: host RTS-pulse reboot 3->4 with boot banner; `--json` agrees. - Regressions: wifi auto-connect CONNECTED, tf_logging true, selftest `wifi_config: ok` + `bad ignored`, `prov status` three-state. Co-authored-by: ania-lain <[email protected]>
This commit is contained in:
@@ -23,10 +23,27 @@ hotspot; such a hold is a portal command and does not count as a button press.
|
||||
|
||||
## Buttons
|
||||
|
||||
The only monitored button is the board's **KEY** button (GPIO18, active-low): a release under 1
|
||||
second counts as a short press, 1-3 seconds as a long press, and 3 seconds or more requests the
|
||||
setup hotspot. Both counters appear on the display and in `status`. The **RST** button resets the
|
||||
board, and **BOOT** (GPIO0) is not monitored — pressing either does not change any counter.
|
||||
The board's three buttons are all observable:
|
||||
|
||||
- **KEY** (GPIO18, active-low): a release under 1 second counts as a short press, 1-3 seconds
|
||||
as a long press, and 3 seconds or more requests the setup hotspot (a portal command, not a
|
||||
press). Both counters appear on the display and in `status` as `KEY: short/long`.
|
||||
- **BOOT** (GPIO0, active-low with the internal pull-up): the same release bands, under 1
|
||||
second short and 1 second or more long, counted as `BOOT: short/long`. It is a strapping
|
||||
pin, so the firmware only reads it at runtime and never drives it, and it has no portal
|
||||
binding.
|
||||
- **RST**: hardwired to the chip reset line, so it cannot be sampled as a GPIO. Instead the
|
||||
firmware increments a persistent boot counter once per boot (NVS namespace `frame`, key
|
||||
`rst_cnt`) and reports it as `RST: count` / `reset_count`; pressing RST reboots the board
|
||||
and increments the counter.
|
||||
|
||||
## Timezone
|
||||
|
||||
Internal time handling is strictly UTC: the RTC chip, JSONL telemetry, and the machine `utc`
|
||||
fields all carry UTC with a `Z` suffix. Only human-facing surfaces convert to local time —
|
||||
China Standard Time (UTC+8, no daylight-saving transitions): the display RTC line, the text
|
||||
`status` output, and `rtc status` render local time labeled `UTC+8`, and `rtc set` interprets
|
||||
its argument as UTC+8 local time (the firmware converts it to UTC before writing the chip).
|
||||
|
||||
## Real-Time Clock
|
||||
|
||||
@@ -38,7 +55,8 @@ display (`-`) and in JSONL (`"utc":""`). The firmware now provides two time sour
|
||||
`ntp.aliyun.com` and `pool.ntp.org`, and on the first successful sync writes the UTC time to
|
||||
the RTC (log line `rtc synced from sntp`). SNTP keeps running; periodic re-syncs update the
|
||||
system clock.
|
||||
- **Console:** `rtc set` writes the chip manually (UTC is assumed).
|
||||
- **Console:** `rtc set` writes the chip manually (the argument is UTC+8 local time; see
|
||||
[Timezone](#timezone)).
|
||||
|
||||
A CR1220 coin cell on the board keeps the RTC running across power-off. Without a battery (or
|
||||
with an empty one) every boot loses the time and the OS flag returns — install a fresh cell for
|
||||
@@ -71,9 +89,10 @@ storage status
|
||||
selftest
|
||||
```
|
||||
|
||||
`rtc status` reports validity, unix time, formatted UTC, and the OS-bit state; `rtc raw` dumps
|
||||
PCF85063 registers 0x00-0x0A with a decode; `rtc set` parses `YYYY-MM-DD HH:MM:SS` as UTC,
|
||||
validates the ranges, writes the chip, and re-reads it to confirm.
|
||||
`rtc status` reports validity, unix time, formatted UTC, formatted UTC+8 local time, and the
|
||||
OS-bit state; `rtc raw` dumps PCF85063 registers 0x00-0x0A with a decode; `rtc set` parses
|
||||
`YYYY-MM-DD HH:MM:SS` as UTC+8 local time, validates the ranges (calendar round-trip), converts
|
||||
to UTC, writes the chip, and re-reads it to confirm.
|
||||
|
||||
Do not place real credentials in command transcripts or committed evidence. `wifi set` asks for the
|
||||
password after parsing the command so it is not stored in command history; terminal software must
|
||||
|
||||
Reference in New Issue
Block a user