Skip to content

v2.0.0 — rewire onto shared valar-core v0.3.0 + scheduling packages - #5

Merged
daniel-frenkel merged 4 commits into
mainfrom
feature/valar-core-rewire
Jul 23, 2026
Merged

daniel-frenkel merged 4 commits into
mainfrom
feature/valar-core-rewire

Conversation

@daniel-frenkel

Copy link
Copy Markdown
Member

Summary

Rearchitects the firmware from a 2939-line monolith into a board wrapper + product layer that pull the shared valar-core (v0.3.0) and scheduling packages from Valar-Systems/valar-motion. Board infrastructure now comes from core; only Glasscalibur's product hardware and logic stay local.

What moved where

  • From core: Wi-Fi, API, OTA (+ safe_mode), http_request, logger, web UI, the TMC2209 driver + boot config, the Speed/Accel/IRUN/TCOOLTHRS/SGTHRS numbers, SG_RESULT/TSTEP sensors, Restart + GitHub-OTA buttons, Firmware Version + network diagnostics.
  • From the scheduling mixin: time, sun, the Schedule/Sun switches, Lat/Long/offset numbers, Open/Close Time, Timezone, and the sun-poll interval — driven via product schedule_open/schedule_close scripts.
  • Kept local (product): buzzer, i2c, LIS2DH12, TMP1075, cover, limit switches, tamper sensor, child lock, tamper/vibration switches+numbers, the auto-calibration scripts, tamper/vibration/completion intervals, lifetime counters, State/Calibration-Status.
  • Reconciled: product on_stall (via !remove + re-add); num_irun capped at 19; sel_direction and phantom btn2/btn3 !removed (2 buttons, fixed ccw direction via motor_direction_default); on_boot split into priority 650 (current clamp) + 500 (restore + limit homing); global_max_speed → core's global_speed.

Decisions (per review)

  • Fixed ccw direction, no Motor Direction select.
  • Exactly 2 buttons (Button 1 + WiFi Reset); no phantom Button 2.
  • Hardware constants parameterized in core v0.3.0 (rsense 220 mOhm, deceleration inf, etc.).

BREAKING

Tuning entity names now match core across the Valar line (max_speed→Speed, acceleration→Acceleration, irun→IRUN (motor current), SGTHRS→SGTHRS (stall threshold), TSTEP Sensor→TSTEP, SG_RESULT Sensor→SG_RESULT). HA entity_ids change accordingly. New Board diagnostic added.

Verification

  • esphome config valid against the released core v0.3.0 tag.
  • Regression gate (entity + behavior): every diff is intended — verified by normalizing the global_speed rename, after which the calibration scripts/intervals are byte-identical. on_boot reorganization verified action-by-action to lose nothing.
  • Full compile → firmware.factory.bin + firmware.ota.bin.
  • Hardware-tested on a real unit: full auto-calibration (both limits, IRUN search, SG/vib tuning, clean IDLE), manual open/close with limit-switch homing, tamper baseline capture.
  • OTA asset URL (Glasscalibur.ota.bin) and device name preserved byte-for-byte.
  • Adds a build-release CI workflow (the repo had none).

🤖 Generated with Claude Code

daniel-frenkel and others added 4 commits July 21, 2026 22:35
Refactor the 2939-line monolith into a board wrapper + product layer that pull
the shared valar-core (v0.3.0) and scheduling mixin as packages, keeping only
Glasscalibur's product hardware and logic in glasscalibur-product.yaml.

Board wrapper (Glasscalibur-esphome.yml): chip, GPIO map, OTA identity, and the
stepper_* / motor_direction_default substitutions that express Glasscalibur's
220 mOhm / inf-decel / counter-clockwise hardware against core's defaults.

Stripped (now from core/scheduling): api, ota, http_request, safe_mode, wifi,
captive_portal, improv_serial, logger base, web_server base, uart, the tmc2209
driver + its on_boot config, Speed/Accel/IRUN/TCOOLTHRS/SGTHRS numbers, SG_RESULT/
TSTEP sensors, Restart/Update-Firmware buttons, Firmware Version + wifi_info,
WiFi Signal/Uptime/ESP temp, and the entire sun/time schedule (time, sun, the
Schedule/Sun switches, Lat/Long/offset numbers, Open/Close Time, Timezone, and
the sun-poll interval).

Kept (product): buzzer, i2c, LIS2DH12, TMP1075, cover, limit switches, tamper
sensor, child lock, tamper/vibration switches+numbers, auto-calibration scripts,
tamper/vibration/completion intervals, lifetime counters, State/Cal Status.

Reconciled: on_stall replaced via !remove + re-add; num_irun !extended to cap at
19; sel_direction and phantom btn2/btn3 !removed (Glasscalibur has 2 buttons and
fixed ccw direction); on_boot split into priority 650 (irun clamp, before core's
currents) and 500 (restore + limit-switch homing, after core configures);
global_max_speed renamed to core's global_speed; schedule_open/schedule_close
scripts added for the scheduling mixin contract.

Verification: esphome config valid; regression gate (entity + behaviour) shows
only intended diffs — tuning entities adopt core's names, on_boot reorganized
without losing an action, schedule moved to the mixin, plus the new "Board"
diagnostic. OTA URL and device name preserved byte-for-byte.

NOTE: board wrapper uses local includes for dev; swap to remote ref v0.3.0 once
core v0.3.0 is tagged. A build-release CI workflow still needs adding.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…gelog

- Board wrapper now pulls valar-core + scheduling from Valar-Systems/valar-motion
  at ref v0.3.0 (remote packages) instead of dev-time local includes. Config
  re-validated against the released tag; regression gate unchanged.
- Add .github/workflows/build-release.yml (mirrors the Ropener pipeline, single
  board): compiles on push/PR, and on a v* tag stamps fw_version from the tag and
  attaches Glasscalibur.factory.bin / .ota.bin / .ota.bin.md5 to the release.
  The on-device GitHub-OTA button depends on that asset existing.
- CHANGELOG: document v2.0.0 (valar-core rewrite, auto-calibration, breaking
  tuning-entity renames) and switch the version source note to the release tag.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…tion

Vibration-based stall detection is an accelerometer feature, not StallGuard, so
give it its own "Stall Detection" group. Demote the TMC2209 StallGuard controls
to an advanced group at the very bottom (as on the Ropener), and pull the
SG_RESULT/TSTEP readouts down into it.

Page order is now: Control, Motion Tuning (Speed/Accel/Motor Current),
Calibration (Auto-Calibrate + status), Stall Detection (vibration), Schedule,
Security/Tamper, Diagnostics, StallGuard (advanced) — SGTHRS/TCOOLTHRS/SG_RESULT/
TSTEP/enable. Uses product-local groups and !extend to move core entities,
leaving core's group_motion/group_stallguard/group_setup empty (they don't render).

Entity set and behaviour unchanged (regression gate identical; sorting is gate-blind).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…Control

- Add a "Motor Current" number in milliamps to Motion Tuning, driven by the
  driver's own read_run_current_mA / write_run_current_mA (no hand formula). Capped
  at 600 mA = IRUN 19, this motor's thermal ceiling. Keeps global_irun in sync.
- Demote the raw IRUN register to "IRUN value" in the advanced StallGuard group
  for power users (still capped at 19).
- Move the Motion Tuning group to weight 12 so it sits immediately under Control.

Verified on hardware: Motor Current reads 538 mA at IRUN 17 (exact conversion).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@daniel-frenkel
daniel-frenkel merged commit fafe4c7 into main Jul 23, 2026
1 check passed
@daniel-frenkel
daniel-frenkel deleted the feature/valar-core-rewire branch July 23, 2026 21:55
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