Skip to content

Commit

Permalink
Position label and regular updates (100ms)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmouchous-ledger committed Nov 10, 2023
1 parent d416b6d commit 359e090
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions pystages/gui/gui.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#!/bin/python3
from PyQt6.QtWidgets import QWidget, QHBoxLayout, QLabel, QComboBox, QPushButton
from PyQt6.QtWidgets import (
QWidget,
QHBoxLayout,
QVBoxLayout,
QLabel,
QComboBox,
QPushButton,
)
from PyQt6.QtCore import QObject, QTimer
from ..cncrouter import CNCRouter
from ..corvus import Corvus
from ..smc100 import SMC100
Expand All @@ -24,23 +32,43 @@ def connect(self, on_off):
self.stage = Corvus()
elif selected == StageType.SMC:
self.stage = SMC100()
self.position_timer.start(100)
else:
del self.stage
self.stage = None
self.position_timer.stop()

def __init__(self):
super().__init__()

# Current stage
self.stage: Stage = None

# This flag is used to limit the communication
# with the stage by not making updates of the position
self.in_motion = False

vbox = QVBoxLayout()
self.setLayout(vbox)

box = QHBoxLayout()
vbox.addLayout(box)
w = QLabel("Stage Selection")
box.addWidget(w)
self.stage_selection = w = QComboBox()
w.addItems([StageType.CNC, StageType.Corvus, StageType.SMC])

box.addWidget(w)
self.setLayout(box)

self.connect_button = w = QPushButton("Connect")
w.setCheckable(True)
w.clicked.connect(self.connect)
box.addWidget(w)
self.position_label = w = QLabel("Pos")
vbox.addWidget(w)
self.position_timer = QTimer()
self.position_timer.timeout.connect(self.update_position)

def update_position(self):
if self.stage is None or self.in_motion:
return
position = self.stage.position
self.position_label.setText(",".join([f"{i:.02f}" for i in position.data]))

0 comments on commit 359e090

Please sign in to comment.