Skip to content

fix(mount): Parked status, optional RA/DEC off when parked - #323

Merged
ClutchplateDude merged 4 commits into
developfrom
parking-changes
Nov 17, 2026
Merged

ClutchplateDude merged 4 commits into
developfrom
parking-changes

Conversation

@intercipere

Copy link
Copy Markdown
Member

Problem

STATUS_PARKED was 0, so :GX# reported "Parked" whenever no status flag was set. A mount
with tracking stopped (:MT0#, or tracking off after a stop) read "Parked" although it was not
at the park position.

Two park bugs showed up while testing:

  1. Re-park after the next slew. When the park position equals home (the usual case),
    the "already at park position" branch left _slewingToPark set. The next slew to finish
    (a goto, a stopped goto, a :MX move) ran the "arrived at park" code again and parked the
    mount, which cleared all status flags, tracking included.
  2. Catch-up of the whole parked time. startSlewingToHome() sets _compensateForTrackerOff.
    The catch-up is skipped while parking, and nothing cleared the flag. A move straight from park
    then caught up the entire parked time on RA. Measured: parked 40 s, then :MXr1000# →
    TRK +10142 steps (= 43 s × 235.6 steps/s on an OAE). Parked overnight, that is hours of RA.

Change

  • STATUS_PARKED is now a real flag (bit 0). It is set only on arrival at the park position
    (enterParkedState()) and cleared by setStatusFlag(), or by leaveParkedState() on paths
    that move RA/DEC without setting a flag first (startSlewing(), drift alignment).
  • A stopped mount now reports "Idle" (an existing state string, so clients need no new word).
  • slewStatus() behaves as before for both idle and parked.
  • enterParkedState() clears _slewingToPark and _compensateForTrackerOff (bugs 1 and 2).

New option: RA_DEC_OFF_WHEN_PARKED (default 0)

When set to 1 in the local config, the RA and DEC drivers are switched off (EN high) while the
mount is parked, and back on before anything moves. This is for OAM and OAE only: their gearboxes
hold the axes without power, while an OAT would lose its position. ConfigurationValidation.hpp
refuses the option:

  • without OAM/OAE;
  • together with UART_CONNECTION_TEST_TXRX, because unparking would re-enable a driver that the
    test disabled;
  • on boards with one shared enable pin (RP2040_SHARED_EN_PIN).

Behaviour change for clients

A stopped mount no longer reports "Parked". With TRACK_ON_BOOT 0, a freshly booted mount now
reports "Idle" instead of "Parked".

Testing

OAE board (ESP32), pio run -e oaeboardv1, LX200 over serial:

  • :hP# → Parked, :hU# → Tracking, :MT0# → Idle, :MT1# → Tracking.
  • A :Q# mid-goto, and :MXr1000#/:MXd1000# from park, end in Tracking and no longer park again.
    The build before the re-park fix failed these.
  • Catch-up after 40 s parked: TRK +10142 steps before the fix, -38 after.
  • With motors and RA_DEC_OFF_WHEN_PARKED 1: both axes are free when parked and hold again
    after unparking or after a move from park.
  • Each of the three config checks stops the build when triggered; RA_DEC_OFF_WHEN_PARKED 1
    builds on the OAE.

🤖 Generated with Claude Code

intercipere and others added 2 commits November 15, 2026 21:12
Stopped mounts read Parked, the next slew re-parked, moves from park caught up
parked time. Adds RA_DEC_OFF_WHEN_PARKED (OAM/OAE).

Assisted by: Claude Opus 5.5
@ClutchplateDude

Copy link
Copy Markdown
Member

Rebased onto develop with #322 merged (fb25787 → 015f40d; clean three-way merge, no manual resolution needed). Checked the intersections with #322 rather than trusting the auto-merge:

Verified locally before pushing: standard esp32 build, and an oaeboardv1 build with RA_DEC_OFF_WHEN_PARKED 1 forced on — that option's digitalWrite(RA_EN_PIN/DEC_EN_PIN) path compiles on the real OAE config (it's dead code in every default CI build).

CI is running on the rebased branch.

🤖 Posted with Claude Code

:Q# (or a directional RA stop) mid-park left _slewingToPark/_slewingToHome
and STATUS_PARKING set. The stop itself only stops the steppers; the
waitUntilAllStopped()/loop() pass then runs the arrival block's "arrived
at park position" code at wherever the mount was aborted to, parking it
there - with RA_DEC_OFF_WHEN_PARKED also switching the drivers off
mid-sky, and a first-leg abort even re-launching the park slew after
setHome(false).

stopSlewing() now clears the park-slew state when the RA axis is stopped,
so an aborted park ends Idle (a full stop also skips catch-up and stays
unparked via the existing TRACKING handling). The pre-existing mislabel
of an aborted park as "Parked" goes away with it.

Found in review of #323; the mid-park :Q# path was untested there.

Co-Authored-By: Claude Code <noreply@anthropic.com>

@ClutchplateDude ClutchplateDude left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completed the review of this PR (on top of the rebase onto #322). The core design holds up under deep tracing: bit 0 was free, all STATUS_PARKED consumers updated, atomicity via setStatus()'s own guard, leaveParkedState() ordering ahead of motion on every path we checked (goto, :MX#, manual, drift alignment, Hall homing), and the two park bugs are real and well-measured.

Findings below. The first is already fixed on the branch (cf29867) — it needed a small change in stopSlewing(), described inline. 2–4 are follow-up material, none blocking.

Comment thread src/Mount.cpp Resolved
Comment thread ConfigurationValidation.hpp Resolved
Comment thread src/Mount.cpp Resolved
Comment thread src/Mount.cpp Resolved
cf29867 made loop()'s own setHome() cancel the park: it never got to Parked.
A stop in the second leg, or of DEC alone, now cancels the park as well.

Assisted by: Claude Fable 5.2
@intercipere

Copy link
Copy Markdown
Member Author

Thanks for the rebase and the review. The mid-park :Q# finding is real, but cf29867 breaks every normal park. Tested on an OAE (oaeboardv1, RA_DEC_OFF_WHEN_PARKED 1), LX200 over serial:

  • cf29867: :hP# from 1000 steps away goes "Parking", then "Idle" at home, and never reaches "Parked". 015f40d with the same sequence ends "Parked".
  • Cause: on arrival at home loop() calls setHome(false), which calls stopSlewing(ALL_DIRECTIONS), so the park cancels itself. loop() restored _slewingToHome but not STATUS_PARKING, so the second leg and enterParkedState() were skipped.

Fix (pushed as 395fc9d):

  • loop() saves and restores the park status around its own setHome().
  • An abort also clears STATUS_PARKING_POS; without that, a stop in the second leg leaves "Parking" set and a later arrival sets home at the aborted position.
  • A DEC-only stop cancels a park the same way an RA stop does.

Tested with the fix:

  • :hP# ends "Parked", with park offset 0 and with offsets of -15000 (park at 15000/15000); both axes are free when parked.
  • :Q# in the first leg and in the second leg ends "Idle" at the aborted position and stays there.
  • A move after the second-leg abort keeps the step counts (home not overwritten), and a new :hP# ends "Parked" at the same coordinates as before.

Two things I left alone: a single-direction stop (:Qn# etc.) in the first leg cancels the park, the other axis still runs home and tracking resumes, as after a goto aborted the same way. And a goto during a park does not cancel the park (older than this PR, from reading the code, not tested). The three follow-ups (OAE CI job, enable/configure order, enable helper) are fine as later PRs.

@ClutchplateDude

ClutchplateDude commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Confirmed — cf29867 was our bug, and your diagnosis is exactly right. The first-leg arrival calls setHome(false), which calls stopSlewing(ALL_DIRECTIONS) internally, so the park-cancel clearing fired inside the normal park flow itself. We had enumerated the direct stopSlewing() callers before pushing but missed that caller-of-caller path. Your hardware tests have now caught two of our review fixes — the verification culture is doing its job.

395fc9d checks out from our side as well: the save/restore of STATUS_PARKING | STATUS_PARKING_POS around loop()'s own setHome() is the right seam (user-initiated setHome still cancels a park, as it should); clearing STATUS_PARKING_POS on abort is load-bearing, not redundant — isParking() and the "Parking" status string both consult it, so a stale flag would keep reporting Parking and route a later arrival through the set-home-at-abort path. The move to any-axis-stop (excluding TRACKING, so :MT0# mid-park doesn't cancel) and DEC-only-stop handling all read correct. And the hardware matrix you ran — both abort legs, park with and without offsets, step-count preservation after abort, re-park coordinates — is exactly what we'd asked for, thank you.

Agreed on the two leave-alones: the single-direction first-leg stop matching goto-abort semantics is consistent, and goto-during-park not canceling is pre-existing behavior worth its own issue rather than scope creep here. The three follow-ups as later PRs too.

This is merge-ready from our side.

🤖 Posted with Claude Code

Guess my Claude models are not smart enough :-)

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.

3 participants