Skip to content

stepper_motor_view

frog.gui.stepper_motor_view ¤

Code for controlling the stepper motor which moves the mirror.

Attributes¤

Classes¤

StepperMotorControl() ¤

Bases: DevicePanel

A control showing buttons for moving the mirror to a target.

Create a new StepperMotorControl.

Source code in frog/gui/stepper_motor_view.py
14
15
16
17
18
19
20
21
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
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_PRESETS):
        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 = QSpinBox()
    self.angle.setMaximum(359)
    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)

    pub.subscribe(
        self._indicate_moving,
        f"device.{STEPPER_MOTOR_TOPIC}.move.begin",
    )
    pub.subscribe(
        self._update_mirror_position_display,
        f"device.{STEPPER_MOTOR_TOPIC}.move.end",
    )
Functions¤