Redesign the settings screens; add sleep sounds, a lamp and time travel to the simulator #4

Merged
paudrow merged 3 commits from claude/focused-cray-fkkb2j into main 2026-09-30 07:48:36 -05:00
paudrow commented 2026-09-29 20:43:43 -05:00 (Migrated from github.com)

What changes on the clock

  • Settings menu: Settings is now a grid of tiles, and each tile shows its current value ("07:00, on", "Pink noise", "21:00-07:00").
  • Pages: every page uses the same row layout (− value + steppers, switches, choices, buttons), with Back and the title in a header. Names are clearer: Alarm sound, Sleep sounds, Day screen, Night screen, Night hours, Soft for, Clock face: 12:34:56 / 12:34 / Hour only / Off.
  • Clock face: new lamp and sleep-sound icons at the top left. A status line under the time shows the next alarm, a snooze, or the sleep sound with its time left.
  • Fits any screen: all sizes come from the screen's width and height (CoreS3 320×240, 4.1″ 616×284, 2.41″ 600×450, and anything from 160×128 up). Text is measured and fitted with a FreeSans size ladder; if it still doesn't fit it is scaled down, then shortened with "..", so it never spills.
  • Sleep sounds:
    • White, pink and brown noise, generated live and levelled to the same loudness.
    • Streamed on its own speaker channel, with a fade-in, a volume setting, and a 15–120 min timer that fades out over its last minute.
    • Stops when the alarm rings.
  • Lamp:
    • On/off and brightness on pin 9 (CoreS3 Port B).
    • A sunrise ramp of 10–60 min before the alarm, then a 30 min wake light after it.
    • The top button (BtnPWR) snoozes while the alarm rings and otherwise switches the lamp.
  • UX fixes:
    • The alarm pulls you back to the clock from any menu, so Snooze and Stop are always on screen.
    • You can't open the menu while it rings.
    • Settings pages go back to the clock after a minute idle.
    • Holding a stepper repeats, but sliding onto one doesn't.
    • Settings are written 1.5 s after the last change rather than on every step.
  • Serial console (115200): lamp, sound, time, alarm, go day|night|sunrise|alarm, button, state (JSON) and help. The same code path is used on the device, in the simulator and in the tests.
  • Settings v2: 32 bytes. Version 1 blobs are upgraded.

Simulator / 3D viewer

  • Firmware drives the model: the lamp's glow in the glass follows the firmware's lamp output, sleep sounds play through Web Audio, and the speaker glows while they play.
  • Clickable parts: the glass or LEDs switch the lamp, the speaker toggles sleep sounds, the top button presses the button, the screen enters Interact, and the clock chip steps through day, night, sunrise and alarm.
  • Jump to: Daytime, Night, Sunrise and Alarm buttons, plus clock speed, a Serial box, and live readouts for alarm, lamp and sound.
  • window.clock API: command(), state(), goTo(), tap(), button(), setSpeed().

Tests

  • test/firmware_test.cpp (new): runs the real main.cpp natively through the shim (test/host/). It covers:
    • every page and control at 10 screen sizes;
    • every draw call on screen, and all text inside its row or tile, not shortened on the 3 target screens;
    • ring, snooze and stop, and skip;
    • sleep sounds: fade, timer, buffers never rewritten while playing, and no underruns with 40–150 ms loops;
    • sunrise and wake light;
    • serial commands;
    • reboots with saved, corrupt and version 1 settings;
    • 12,000 frames of random input per size.
  • Unit tests for the layout rules across a sweep of sizes, noise statistics, the lamp, command parsing and settings loading.
  • test/screens/ are now drawn by the real firmware at all three screen sizes. They replace the hand-drawn mock renderer.
  • sim/smoke_test.js exercises the browser build through the commands.
  • New CI job firmware: builds the CoreS3 firmware with PlatformIO. I couldn't run that build here because the environment blocks the PlatformIO registry, so this PR is its first run. The M5Unified calls were checked against its source in review.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Vwf5rMAYG2NAUB8GMWbq2u


Generated by Claude Code

## What changes on the clock - **Settings menu:** Settings is now a grid of tiles, and each tile shows its current value ("07:00, on", "Pink noise", "21:00-07:00"). - **Pages:** every page uses the same row layout (− value + steppers, switches, choices, buttons), with Back and the title in a header. Names are clearer: *Alarm sound*, *Sleep sounds*, *Day screen*, *Night screen*, *Night hours*, *Soft for*, *Clock face: 12:34:56 / 12:34 / Hour only / Off*. - **Clock face:** new lamp and sleep-sound icons at the top left. A status line under the time shows the next alarm, a snooze, or the sleep sound with its time left. - **Fits any screen:** all sizes come from the screen's width and height (CoreS3 320×240, 4.1″ 616×284, 2.41″ 600×450, and anything from 160×128 up). Text is measured and fitted with a FreeSans size ladder; if it still doesn't fit it is scaled down, then shortened with "..", so it never spills. - **Sleep sounds:** - White, pink and brown noise, generated live and levelled to the same loudness. - Streamed on its own speaker channel, with a fade-in, a volume setting, and a 15–120 min timer that fades out over its last minute. - Stops when the alarm rings. - **Lamp:** - On/off and brightness on pin 9 (CoreS3 Port B). - A sunrise ramp of 10–60 min before the alarm, then a 30 min wake light after it. - The top button (`BtnPWR`) snoozes while the alarm rings and otherwise switches the lamp. - **UX fixes:** - The alarm pulls you back to the clock from any menu, so Snooze and Stop are always on screen. - You can't open the menu while it rings. - Settings pages go back to the clock after a minute idle. - Holding a stepper repeats, but sliding onto one doesn't. - Settings are written 1.5 s after the last change rather than on every step. - **Serial console (115200):** `lamp`, `sound`, `time`, `alarm`, `go day|night|sunrise|alarm`, `button`, `state` (JSON) and `help`. The same code path is used on the device, in the simulator and in the tests. - **Settings v2:** 32 bytes. Version 1 blobs are upgraded. ## Simulator / 3D viewer - **Firmware drives the model:** the lamp's glow in the glass follows the firmware's lamp output, sleep sounds play through Web Audio, and the speaker glows while they play. - **Clickable parts:** the glass or LEDs switch the lamp, the speaker toggles sleep sounds, the top button presses the button, the screen enters Interact, and the clock chip steps through day, night, sunrise and alarm. - **Jump to:** Daytime, Night, Sunrise and Alarm buttons, plus clock speed, a Serial box, and live readouts for alarm, lamp and sound. - **`window.clock` API:** `command()`, `state()`, `goTo()`, `tap()`, `button()`, `setSpeed()`. ## Tests - **`test/firmware_test.cpp` (new):** runs the real `main.cpp` natively through the shim (`test/host/`). It covers: - every page and control at 10 screen sizes; - every draw call on screen, and all text inside its row or tile, not shortened on the 3 target screens; - ring, snooze and stop, and skip; - sleep sounds: fade, timer, buffers never rewritten while playing, and no underruns with 40–150 ms loops; - sunrise and wake light; - serial commands; - reboots with saved, corrupt and version 1 settings; - 12,000 frames of random input per size. - **Unit tests** for the layout rules across a sweep of sizes, noise statistics, the lamp, command parsing and settings loading. - **`test/screens/`** are now drawn by the real firmware at all three screen sizes. They replace the hand-drawn mock renderer. - **`sim/smoke_test.js`** exercises the browser build through the commands. - **New CI job `firmware`:** builds the CoreS3 firmware with PlatformIO. I couldn't run that build here because the environment blocks the PlatformIO registry, so this PR is its first run. The M5Unified calls were checked against its source in review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Vwf5rMAYG2NAUB8GMWbq2u --- _Generated by [Claude Code](https://claude.ai/code/session_01Vwf5rMAYG2NAUB8GMWbq2u)_
Sign in to join this conversation.
No description provided.