Bases: DevicePanel
A control showing buttons for moving the mirror to a target.
Create a new StepperMotorControl.
Source code in src/frog/gui/stepper_motor_view.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 | def __init__(self) -> None:
"""Create a new StepperMotorControl."""
super().__init__(STEPPER_MOTOR_TOPIC, "Target control")
layout = QGridLayout()
# Bundle all the buttons for moving the mirror into one group
self.button_group = QButtonGroup()
self.button_group.buttonClicked.connect(self._preset_clicked)
# Add all the buttons for preset positions
BUTTONS_PER_ROW = 4
for i, preset in enumerate(ANGLE_PRESET_NAMES):
btn = self._add_checkable_button(preset.upper())
self.button_group.addButton(btn)
row, col = divmod(i, BUTTONS_PER_ROW)
layout.addWidget(btn, row, col)
# We also have a way for users to move the mirror to an angle of their choice
self.angle = QDoubleSpinBox()
self.angle.setDecimals(1)
self.angle.setSingleStep(0.1)
self.angle.setMaximum(359.9)
self.goto = self._add_checkable_button("GOTO")
layout.addWidget(self.angle, 1, 2)
layout.addWidget(self.goto, 1, 3)
# Create widgets to show the current mirror position
layout.addWidget(QLabel("Current position"), 0, 4)
self.mirror_position_display = QLabel()
self.mirror_position_display.setAlignment(Qt.AlignmentFlag.AlignCenter)
layout.addWidget(self.mirror_position_display, 1, 4)
self.setLayout(layout)
self.angle_presets: Mapping[str, float]
pub.subscribe(
self._update_preset_angles, f"device.{STEPPER_MOTOR_TOPIC}.angle_presets"
)
pub.subscribe(
self._indicate_moving,
f"device.{STEPPER_MOTOR_TOPIC}.move.begin",
)
pub.subscribe(
self._on_move_end,
f"device.{STEPPER_MOTOR_TOPIC}.move.end",
)
|
Functions