Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions BlocksScreen/lib/panels/controlTab.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class ControlTab(QtWidgets.QStackedWidget):
str, name="request-file-info"
)
call_load_panel = QtCore.pyqtSignal(bool, str, name="call-load-panel")
toggle_conn_page = QtCore.pyqtSignal(bool, name="call-load-panel")
tune_display_buttons: dict = {}
card_options: dict = {}

Expand Down Expand Up @@ -75,6 +76,8 @@ def __init__(
self.move_length: float = 1.0
self.move_speed: float = 25.0
self.probe_helper_page = ProbeHelper(self)
self.probe_helper_page.toggle_conn_page.connect(self.toggle_conn_page)
self.probe_helper_page.disable_popups.connect(self.disable_popups)
self.addWidget(self.probe_helper_page)
self.probe_helper_page.call_load_panel.connect(self.call_load_panel)
self.printcores_page = SwapPrintcorePage(self)
Expand All @@ -90,6 +93,15 @@ def __init__(
self.probe_helper_page.query_printer_object.connect(self.ws.api.object_query)
self.probe_helper_page.run_gcode_signal.connect(self.ws.api.run_gcode)
self.probe_helper_page.request_back.connect(self.back_button)
self.printer.print_stats_update[str, str].connect(
self.probe_helper_page.on_print_stats_update
)
self.printer.print_stats_update[str, dict].connect(
self.probe_helper_page.on_print_stats_update
)
self.printer.print_stats_update[str, float].connect(
self.probe_helper_page.on_print_stats_update
)
self.printer.available_gcode_cmds.connect(
self.probe_helper_page.on_available_gcode_cmds
)
Expand Down
3 changes: 3 additions & 0 deletions BlocksScreen/lib/panels/mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ def __init__(self):
self, LoadingOverlayWidget.AnimationGIF.DEFAULT
)
self.loadscreen.add_widget(self.loadwidget)

self.controlPanel.toggle_conn_page.connect(self.conn_window.set_toggle)

if self.config.has_section("server"):
# @ Start websocket connection with moonraker
self.bo_ws_startup.emit()
Expand Down
13 changes: 10 additions & 3 deletions BlocksScreen/lib/panels/widgets/connectionPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __init__(self, parent: QtWidgets.QWidget, ws: MoonWebSocket, /):
self.state = "shutdown"
self.dot_count = 0
self.message = None
self.conn_toggle: bool = True
self.dot_timer = QtCore.QTimer(self)
self.dot_timer.setInterval(1000)
self.dot_timer.timeout.connect(self._add_dot)
Expand All @@ -54,6 +55,11 @@ def __init__(self, parent: QtWidgets.QWidget, ws: MoonWebSocket, /):
self.ws.klippy_connected_signal.connect(self.on_klippy_connected)
self.ws.klippy_state_signal.connect(self.on_klippy_state)

@QtCore.pyqtSlot(bool, name="toggle_connection_page")
def set_toggle(self, toggle: bool):
"""Toggle connection page showing or not"""
self.conn_toggle = toggle

def show_panel(self, reason: str | None = None):
"""Show widget"""
self.show()
Expand All @@ -65,9 +71,10 @@ def show_panel(self, reason: str | None = None):

def showEvent(self, a0: QtCore.QEvent | None):
"""Handle show event"""
self.ws.api.refresh_update_status()
self.call_load_panel.emit(False, "")
return super().showEvent(a0)
if self.conn_toggle:
self.ws.api.refresh_update_status()
self.call_load_panel.emit(False, "")
return super().showEvent(a0)

@QtCore.pyqtSlot(bool, name="on_klippy_connected")
def on_klippy_connection(self, connected: bool):
Expand Down
99 changes: 71 additions & 28 deletions BlocksScreen/lib/panels/widgets/probeHelperPage.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,17 @@ class ProbeHelper(QtWidgets.QWidget):
)
call_load_panel = QtCore.pyqtSignal(bool, str, name="call-load-panel")

toggle_conn_page = QtCore.pyqtSignal(bool, name="toggles-conn-panel")

disable_popups: typing.ClassVar[QtCore.pyqtSignal] = QtCore.pyqtSignal(
bool, name="disable-popups"
)

distances = ["0.01", ".025", "0.1", "0.5", "1"]
_calibration_commands: list = []
helper_start: bool = False
helper_initialize: bool = False
_zhop_height: float = float(distances[4])
_zhop_height: float = float(distances[0])
card_options: dict = {}
z_offset_method_type: str = ""
z_offset_config_method: tuple = ()
Expand Down Expand Up @@ -85,6 +91,26 @@ def __init__(self, parent: QtWidgets.QWidget) -> None:
self.block_list = False
self.target_temp = 0
self.current_temp = 0
self._eddy_calibration_state = False

@QtCore.pyqtSlot(str, dict, name="on_print_stats_update")
@QtCore.pyqtSlot(str, float, name="on_print_stats_update")
@QtCore.pyqtSlot(str, str, name="on_print_stats_update")
def on_print_stats_update(self, field: str, value: dict | float | str) -> None:
"""Handle print stats object update"""
if isinstance(value, str):
if "state" in field:
if value in ("standby"):
if self._eddy_calibration_state:
self.call_load_panel.emit(True, "Almost done...\nPlease wait")
self.run_gcode_signal.emit(self._eddy_command)

self.request_page_view.emit()

self.disable_popups.emit(False)
self.toggle_conn_page.emit(True)

self._eddy_calibration_state = False

def on_klippy_status(self, state: str):
"""Handle Klippy status event change"""
Expand Down Expand Up @@ -202,29 +228,28 @@ def on_object_config(self, config: dict | list) -> None:

# BUG: If i don't add if not self.probe_config i'll just receive the configuration a bunch of times
if isinstance(config, list):
...
# if self.block_list:
# return
# else:
# self.block_list = True

# _keys = []
# if not isinstance(config, list):
# return

# list(map(lambda item: _keys.extend(item.keys()), config))

# probe, *_ = config[0].items()
# self.z_offset_method_type = probe[0] # The one found first
# self.z_offset_method_config = (
# probe[1],
# "PROBE_CALIBRATE",
# "Z_OFFSET_APPLY_PROBE",
# )
# self.init_probe_config()
# if not _keys:
# return
# self._configure_option_cards(_keys)
if self.block_list:
return
else:
self.block_list = True

_keys = []
if not isinstance(config, list):
return

list(map(lambda item: _keys.extend(item.keys()), config))

probe, *_ = config[0].items()
self.z_offset_method_type = probe[0] # The one found first
self.z_offset_method_config = (
probe[1],
"PROBE_CALIBRATE",
"Z_OFFSET_APPLY_PROBE",
)
self._init_probe_config()
if not _keys:
return
self._configure_option_cards(_keys)

elif isinstance(config, dict):
if config.get("stepper_z"):
Expand Down Expand Up @@ -393,10 +418,6 @@ def handle_start_tool(self, sender: typing.Type[OptionCard]) -> None:
for i in self.card_options.values():
i.setDisabled(True)

self.call_load_panel.emit(True, "Homing Axes...")
if self.z_offset_safe_xy:
self.run_gcode_signal.emit("G28\nM400")
self._move_to_pos(self.z_offset_safe_xy[0], self.z_offset_safe_xy[1], 100)
self.helper_initialize = True
_timer = QtCore.QTimer()
_timer.setSingleShot(True)
Expand All @@ -408,6 +429,26 @@ def handle_start_tool(self, sender: typing.Type[OptionCard]) -> None:
_cmd = self._build_calibration_command(sender.name) # type:ignore
if not _cmd:
return

self.disable_popups.emit(True)
self.run_gcode_signal.emit("G28\nM400")
if "eddy" in sender.name: # type:ignore
self.call_load_panel.emit(True, "Preparing Eddy Current Calibration...")
self.toggle_conn_page.emit(False)
self.run_gcode_signal.emit(
f"LDC_CALIBRATE_DRIVE_CURRENT CHIP={sender.name.split(' ')[1]}" # type:ignore
)
self.run_gcode_signal.emit("M400\nSAVE_CONFIG")

self._eddy_command = _cmd
self._eddy_calibration_state = True
return
else:
if self.z_offset_safe_xy:
self.call_load_panel.emit(True, "Homing Axes...")
self._move_to_pos(
self.z_offset_safe_xy[0], self.z_offset_safe_xy[1], 100
)
self.run_gcode_signal.emit(_cmd)

@QtCore.pyqtSlot(str, str, float, name="on_extruder_update")
Expand All @@ -417,6 +458,8 @@ def on_extruder_update(
"""Handle extruder update"""
if not self.helper_initialize:
return
if self._eddy_calibration_state:
return
if self.target_temp != 0:
if self.current_temp == self.target_temp:
if self.isVisible:
Expand Down
Loading