Repository navigation
feat(equipment): each telescope keeps its own alignment point - #703
Merged
Merged
Conversation
The alignment point (target pixel) depends on how the PiFinder sits on a particular telescope, but it was one global setting, so moving the PiFinder between telescopes meant re-aligning every time. - Telescope gains target_pixel (None until aligned, excluded from equality so value lookups still find an aligned record). - Config.active_target_pixel() resolves telescope -> global target_pixel -> image centre; Config.save_target_pixel() writes to the active telescope. Both alignment screens, the reset key and the boot-time SharedStateObj go through them. - Selecting a telescope pushes its point to shared_state: a post_callback on the device Telescope menu, and the reload_config handler for the web page. - A web edit of a telescope keeps its point; an unusable stored point is dropped on load instead of costing the whole equipment section. - No migration: unaligned telescopes fall back to the global value, so nothing changes until a telescope is aligned. ADR 0047; glossary, architecture and user docs updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…that clobber each other Review of #703 (per-telescope alignment): - Align screen: entering align mode clears the star left from an earlier alignment, so the marker starts at the active telescope's point and SQUARE cannot re-align on an old star onto the telescope now active. - Deleting a telescope on the web page keeps the active telescope active (Equipment.remove_telescope); a bare pop used to select the next one, and with it that telescope's alignment point. - A stored point must be a (Y, X) pixel inside the 512x512 frame; bools and off-frame values are now dropped like other unusable values. - Tests for the wiring: the real device menu pushes the point to shared state, SharedStateObj boots from it, and all three save sites land on the active telescope. Each was checked by reverting the fix it covers. Config saves (ADR 0048): every process holds its own Config, read at start-up, and set_option wrote that whole copy back to config.json. The camera process saving camera_exp on leaving Align (Day) therefore reverted the alignment the UI had just saved. A save now re-reads the file, changes only its own keys, and replaces the file atomically under an flock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Closes #690.
Each telescope now keeps its own alignment. When you align the PiFinder, it saves the alignment for the active telescope. When you select a different telescope, the PiFinder uses the alignment of that telescope. You do not need to align again when you move the PiFinder between telescopes.
Before this change there was one alignment for all telescopes.
This PR also fixes a problem that made a saved alignment disappear after a restart. See "Config saves" below.
What does not change for users
default_config.jsondoes not get its own alignment.How it works
Telescopehas a new field,target_pixel. It isNoneuntil the telescope is aligned. The field is not used when telescopes are compared (compare=False), because the code finds telescopes by value (telescopes.index(), the device menu, the DeepskyLog import). Without this, selecting a telescope from a menu built before the alignment would fail.Config.active_target_pixel()gives the point to use: the active telescope's point, else the globaltarget_pixel, else (256, 256).Config.save_target_pixel()saves to the active telescope. Both alignment screens, the reset key, and the start-up value inSharedStateObjuse these two functions.shared_state, which the solver reads on every solve:post_callbackon the Telescope menu (callbacks.apply_target_pixel).reload_confighandler inmain.py.Equipment.from_dictfail, and all equipment was replaced by the defaults.Equipment.remove_telescope). Before, deleting a telescope above the active one selected the next telescope, and with it the alignment of that telescope.The reasons and the rejected options are in
docs/adr/0047-alignment-point-belongs-to-the-telescope.md.Config saves (ADR 0048)
Each PiFinder process (UI, camera, web server, integrator) reads its own copy of the settings when it starts. Before this PR, a save wrote that whole copy back to
config.json. This removed every setting that other processes saved after it started.The problem that showed it: when you leave Align (Day) with a manual exposure, the camera process saves
camera_exp. That save wrote the camera's old copy of the file and removed the alignment that you saved a moment before. The same happened when you selected a manual exposure in the Camera Exp menu. Onmain, this already removes the globaltarget_pixel. You saw the problem only after a restart.Now a save reads the file, changes only its own keys, and replaces the file in one step. A file lock (
flock) prevents two processes from saving at the same time. Details are indocs/adr/0048-config-saves-write-only-their-own-keys.md.Tests
test_target_pixel_per_telescope.py: the record, the fallback order, saving, bad values, deleting a telescope.test_target_pixel_wiring.py: the real device menu, the start-up value, the three places that save a point, the Align screen.test_config_persist.py: twoConfigcopies that save different keys, filter reset, atomic write.test_server_equipment_forms.py: web edit keeps the point, web delete keeps the active telescope.nox -s lint format type_hints smoke_tests unit_testsall pass (2344 unit tests). The docs build has no warnings.camera_exp. Before the fix, the saved point was missing fromconfig.jsonafter you left the screen. After the fix, it stays there.Also found
active_telescope_index = -1selects the last telescope, not "no telescope".docs/ax/equipment.mdsaid otherwise and is corrected. The code is not changed.pop, so it can change the active eyepiece. This PR does not change it.Hardware check before merge
All three checks passed on a PiFinder on 2026-11-19.
🤖 Generated with Claude Code