Skip to content

Dim the status LED and create the SD log at the first sample - #28

Merged
tom-parkinson merged 3 commits into
mainfrom
led-dim-lazy-sd-log
Sep 29, 2026
Merged

tom-parkinson merged 3 commits into
mainfrom
led-dim-lazy-sd-log

Conversation

@tom-parkinson

Copy link
Copy Markdown
Contributor

LED

Linear drive (gamma_correct: 1.0) made the existing levels glaring in a dark room.

Use Before (per lit channel, /255) After
Heartbeat (white) 8% → 20 2% → 5
Alarm solid 25% → 64 4% → 10
Alarm pulse peak 15% → 38 4% → 10
Boot strobe (green) 10% × 50% → 13 3% → 8
Identify (cyan) unchanged, 32 unchanged

Alarms floor at 4% so amber (red + half green) stays distinguishable.

SD log

sd_create no longer runs on on_time_sync (rtc.yaml) or on_mount (sd.yaml); sensor_sample's existing retry path creates the log just before the first row. A boot-looping unit now writes no empty logs.

  • Filename timestamp is the first sample's time, not boot time
  • Header tags are read at the first sample (better after a deploy re-tag)
  • samba deploy's erase gate (sd_logs.py) accepts an empty card; samba_calibration/tests/fake_device.py:640 still models a log appearing immediately after erase, so the fake is now slightly optimistic

Checks

  • esphome config / esphome compile pass on 2026.9.0
  • Safe-mode audit: early return at line 1352, half-wired: none
  • Not bench-tested; no manifest.json change

🤖 Generated with Claude Code

Tom Parkinson and others added 3 commits September 30, 2026 09:24
The LED drives the WS2812 linearly, so even the "low" settings were glaring in a
dark room: the heartbeat lit all three channels at 20/255 and a solid alarm at
64/255. Heartbeat drops to 2%, alarms (solid and pulse peak) to 4% and the boot
strobe to 3%. Alarms stop at 4% because amber is red plus half green and drifts
to red below that. Identify keeps its brightness so a unit can be found in a rack.

sd_create ran on time sync and on mount, so a unit in a boot loop left an empty
log per boot, thousands a day, until the card's directory slowed the unit into
a loop of its own. Only sensor_sample runs it now, just before the first row,
which it already did as a retry. A file exists only if a row goes into it; the
filename carries the first sample's time and the header the tags then in force.
The samba deploy gate accepts an empty card after an erase.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The component remounts on its own after a removal or two failed writes, and
sd_logfile survived it, so a swapped card had the old log name recreated
headerless by append_file. on_mount now keeps the latch only if sd_filename
exists on the card just mounted. A tag change clears the latch and leaves the
new log to the next sample, like every other path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tom-parkinson
tom-parkinson merged commit ec874ee into main Sep 29, 2026
2 checks passed
@tom-parkinson
tom-parkinson deleted the led-dim-lazy-sd-log branch September 29, 2026 23:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant