Skip to content

Commit

Permalink
Display angle value as well as preset name
Browse files Browse the repository at this point in the history
  • Loading branch information
dc2917 committed Nov 14, 2024
1 parent 0064b0e commit 7b1a7f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions finesse/gui/stepper_motor_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,9 @@ def _indicate_moving(self, target) -> None:
def _update_mirror_position_display(self, moved_to: float) -> None:
"""Display the angle the mirror has moved to.
If angle corresponds to a preset, show the associated name, otherwise just show
the value.
If angle corresponds to a preset, show the associated name as well as the value.
"""
preset = next((k for k, v in ANGLE_PRESETS.items() if v == moved_to), None)
if preset:
self.mirror_position_display.setText(preset.upper())
else:
self.mirror_position_display.setText(f"{moved_to}°")
text = f"{moved_to}°"
if preset := next((k for k, v in ANGLE_PRESETS.items() if v == moved_to), None):
text += f" ({preset})"
self.mirror_position_display.setText(text)
2 changes: 1 addition & 1 deletion tests/gui/test_stepper_motor_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_update_mirror_position_display(qtbot: QtBot) -> None:
control = StepperMotorControl()

control._update_mirror_position_display(moved_to=ANGLE_PRESETS["zenith"])
assert control.mirror_position_display.text() == "ZENITH"
assert control.mirror_position_display.text() == "180.0\u00b0 (zenith)"

control._update_mirror_position_display(moved_to=12.34)
assert control.mirror_position_display.text() == "12.34" + "\u00b0"

0 comments on commit 7b1a7f1

Please sign in to comment.