Skip to content

Commit

Permalink
Probe pushbutton background color changes with probe activation and t…
Browse files Browse the repository at this point in the history
…ouch.

Enable/disable control elements of sender tab when controller is connected/disconnected.
  • Loading branch information
TheAntTeam committed Dec 4, 2023
1 parent 0ec14ea commit 6173016
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 192 deletions.
4 changes: 3 additions & 1 deletion src/TheAntFarm/controller/controller_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ class ControllerWorker(QObject):
update_layer_s = Signal(Od, str, str, bool) # Signal to update layer visualization
update_path_s = Signal(str, list) # Signal to update path visualization
update_camera_image_s = Signal(QPixmap) # Signal to update Camera Image
update_camera_list_s = Signal(list)
update_camera_list_s = Signal(list) # Signal to update Camera list detected
update_status_s = Signal(Od) # Signal to update controller status
update_console_text_s = Signal(str) # Signal to send text to the console textEdit
serial_send_s = Signal(bytes) # Signal to send text to the serial
serial_tx_available_s = Signal() # Signal to send text to the serial

touched_probe_s = Signal() # Signal the probe touched
update_probe_s = Signal(list) # Signal to update probe value
send_abl_s = Signal(tuple, tuple)
update_abl_s = Signal(list) # Signal to update Auto-Bed-Levelling value
Expand Down Expand Up @@ -179,6 +180,7 @@ def parse_rx_queue(self):
[ack_prb_flag, ack_abl_flag, send_next, other_cmd_flag] = \
self.control_controller.process_probe_and_abl()
if ack_prb_flag:
self.touched_probe_s.emit()
self.ack_probe()
if ack_abl_flag:
self.ack_auto_bed_levelling()
Expand Down
8 changes: 7 additions & 1 deletion src/TheAntFarm/style_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def __init__(self, app_ptr):
self.app_ptr = app_ptr
self.native_styles = QStyleFactory.keys()
self.default_palette = QPalette()
self.default_style = "Fusion" # None
self.default_style = "Fusion"
self.dark_palette_action = None

def list_styles(self):
Expand Down Expand Up @@ -113,6 +113,12 @@ def set_radio_btn_style_sheet():
"height: 7px;}"
return radio_btn_ss

@staticmethod
def set_button_color(bg_color = "dark_gray", color = "white"):
push_btn_ss = "QPushButton { background-color: " + bg_color + ";color: " + color + \
"; border: : 3px solid; font-weight: bold;}"
return push_btn_ss


if __name__ == "__main__":
pass
32 changes: 16 additions & 16 deletions src/TheAntFarm/the_ant_farm.ui
Original file line number Diff line number Diff line change
Expand Up @@ -3589,7 +3589,7 @@
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QToolButton" name="xYMinusPlusButton">
<widget class="QToolButton" name="x_minus_y_plus_pb">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -3618,7 +3618,7 @@
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="xYPlusMinuButton">
<widget class="QToolButton" name="x_plus_y_minus_pb">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -3647,7 +3647,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="xMinusButton">
<widget class="QToolButton" name="x_minus_pb">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -3676,7 +3676,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QToolButton" name="xYMinusButton">
<widget class="QToolButton" name="x_minus_y_minus_pb">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -3705,7 +3705,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="yPlusButton">
<widget class="QToolButton" name="y_plus_pb">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -3763,7 +3763,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QToolButton" name="yMinusButton">
<widget class="QToolButton" name="y_minus_pb">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -3792,7 +3792,7 @@
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="xYPlusButton">
<widget class="QToolButton" name="x_plus_y_plus_pb">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -3821,7 +3821,7 @@
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="xPlusButton">
<widget class="QToolButton" name="x_plus_pb">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -6323,7 +6323,7 @@
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QToolButton" name="xYMinusPlusButton_2">
<widget class="QToolButton" name="x_minus_y_plus_pb_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -6352,7 +6352,7 @@
</widget>
</item>
<item row="2" column="2">
<widget class="QToolButton" name="xYPlusMinuButton_2">
<widget class="QToolButton" name="x_plus_y_minus_pb_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -6381,7 +6381,7 @@
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="xMinusButton_2">
<widget class="QToolButton" name="x_minus_pb_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -6410,7 +6410,7 @@
</widget>
</item>
<item row="2" column="0">
<widget class="QToolButton" name="xYMinusButton_2">
<widget class="QToolButton" name="x_minus_y_minus_pb_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -6439,7 +6439,7 @@
</widget>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="yPlusButton_2">
<widget class="QToolButton" name="y_plus_pb_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -6497,7 +6497,7 @@
</widget>
</item>
<item row="2" column="1">
<widget class="QToolButton" name="yMinusButton_2">
<widget class="QToolButton" name="y_minus_pb_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -6526,7 +6526,7 @@
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="xYPlusButton_2">
<widget class="QToolButton" name="x_plus_y_plus_pb_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down Expand Up @@ -6555,7 +6555,7 @@
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="xPlusButton_2">
<widget class="QToolButton" name="x_plus_pb_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
Expand Down
69 changes: 51 additions & 18 deletions src/TheAntFarm/ui_manager/ui_control_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(self, ui, control_worker, serial_worker, ctrl_layer, settings):
self.ui_serial_close_s.connect(self.serialWo.close_port)
self.controlWo.reset_controller_status_s.connect(self.controlWo.reset_dro_status_updated)
self.controlWo.update_status_s.connect(self.update_status)
self.controlWo.touched_probe_s.connect(self.touched_probe)
self.controlWo.update_probe_s.connect(self.update_probe)
self.controlWo.send_abl_s.connect(self.controlWo.cmd_auto_bed_levelling)
self.controlWo.update_bbox_s.connect(self.update_bbox)
Expand Down Expand Up @@ -110,26 +111,26 @@ def __init__(self, ui, control_worker, serial_worker, ctrl_layer, settings):
self.ui.zero_y_pb.clicked.connect(self.handle_y_0)
self.ui.zero_z_pb.clicked.connect(self.handle_z_0)
self.ui.center_tb.clicked.connect(self.handle_center_jog)
self.ui.xMinusButton.clicked.connect(self.handle_x_minus)
self.ui.xPlusButton.clicked.connect(self.handle_x_plus)
self.ui.yMinusButton.clicked.connect(self.handle_y_minus)
self.ui.yPlusButton.clicked.connect(self.handle_y_plus)
self.ui.xYPlusButton.clicked.connect(self.handle_xy_plus)
self.ui.xYPlusMinuButton.clicked.connect(self.handle_x_plus_y_minus)
self.ui.xYMinusButton.clicked.connect(self.handle_xy_minus)
self.ui.xYMinusPlusButton.clicked.connect(self.handle_x_minus_y_plus)
self.ui.x_minus_pb.clicked.connect(self.handle_x_minus)
self.ui.x_plus_pb.clicked.connect(self.handle_x_plus)
self.ui.y_minus_pb.clicked.connect(self.handle_y_minus)
self.ui.y_plus_pb.clicked.connect(self.handle_y_plus)
self.ui.x_plus_y_plus_pb.clicked.connect(self.handle_xy_plus)
self.ui.x_plus_y_minus_pb.clicked.connect(self.handle_x_plus_y_minus)
self.ui.x_minus_y_minus_pb.clicked.connect(self.handle_xy_minus)
self.ui.x_minus_y_plus_pb.clicked.connect(self.handle_x_minus_y_plus)
self.ui.z_minus_pb.clicked.connect(self.handle_z_minus)
self.ui.z_plus_pb.clicked.connect(self.handle_z_plus)

self.ui.center_tb_2.clicked.connect(self.handle_center_jog)
self.ui.xMinusButton_2.clicked.connect(self.handle_x_minus)
self.ui.xPlusButton_2.clicked.connect(self.handle_x_plus)
self.ui.yMinusButton_2.clicked.connect(self.handle_y_minus)
self.ui.yPlusButton_2.clicked.connect(self.handle_y_plus)
self.ui.xYPlusButton_2.clicked.connect(self.handle_xy_plus)
self.ui.xYPlusMinuButton_2.clicked.connect(self.handle_x_plus_y_minus)
self.ui.xYMinusButton_2.clicked.connect(self.handle_xy_minus)
self.ui.xYMinusPlusButton_2.clicked.connect(self.handle_x_minus_y_plus)
self.ui.x_minus_pb_2.clicked.connect(self.handle_x_minus)
self.ui.x_plus_pb_2.clicked.connect(self.handle_x_plus)
self.ui.y_minus_pb_2.clicked.connect(self.handle_y_minus)
self.ui.y_plus_pb_2.clicked.connect(self.handle_y_plus)
self.ui.x_plus_y_plus_pb_2.clicked.connect(self.handle_xy_plus)
self.ui.x_plus_y_minus_pb_2.clicked.connect(self.handle_x_plus_y_minus)
self.ui.x_minus_y_minus_pb_2.clicked.connect(self.handle_xy_minus)
self.ui.x_minus_y_plus_pb_2.clicked.connect(self.handle_x_minus_y_plus)
self.ui.z_minus_pb_2.clicked.connect(self.handle_z_minus)
self.ui.z_plus_pb_2.clicked.connect(self.handle_z_plus)

Expand All @@ -154,6 +155,7 @@ def __init__(self, ui, control_worker, serial_worker, ctrl_layer, settings):
self.ui.y_max_dsb.valueChanged.connect(self.update_bbox_y_steps)
self.ui.y_num_step_sb.valueChanged.connect(self.update_bbox_y_num_steps)

self.enable_control_jog_elements(False)
self.ui.soft_reset_tb.setEnabled(False)
self.ui.unlock_tb.setEnabled(False)
self.ui.homing_tb.setEnabled(False)
Expand Down Expand Up @@ -206,6 +208,31 @@ def __init__(self, ui, control_worker, serial_worker, ctrl_layer, settings):
self.ui.z_min_dsb.valueChanged.connect(self.handle_z_min_changed)
self.ui.z_max_dsb.valueChanged.connect(self.handle_z_max_changed)

def enable_control_jog_elements(self, enable_flag=True):
"""
Enable or disable ui elements of the control jog and related.
Parameters
----------
enable_flag enable ui elements if true
"""
self.ui.x_minus_y_plus_pb.setEnabled(enable_flag)
self.ui.x_plus_y_minus_pb.setEnabled(enable_flag)
self.ui.x_minus_y_minus_pb.setEnabled(enable_flag)
self.ui.x_plus_y_plus_pb.setEnabled(enable_flag)
self.ui.x_minus_pb.setEnabled(enable_flag)
self.ui.x_plus_pb.setEnabled(enable_flag)
self.ui.y_minus_pb.setEnabled(enable_flag)
self.ui.y_plus_pb.setEnabled(enable_flag)
self.ui.center_tb.setEnabled(enable_flag)
self.ui.z_plus_pb.setEnabled(enable_flag)
self.ui.z_minus_pb.setEnabled(enable_flag)
self.ui.probe_pb.setEnabled(enable_flag)
self.ui.zero_x_pb.setEnabled(enable_flag)
self.ui.zero_y_pb.setEnabled(enable_flag)
self.ui.zero_z_pb.setEnabled(enable_flag)
self.ui.zero_xy_pb.setEnabled(enable_flag)

def deselect_all_gcode_row(self, index):
self.ui.gcode_tw.setSelectionMode(QAbstractItemView.MultiSelection)
self.ui.gcode_tw.setSelectionBehavior(QAbstractItemView.SelectRows)
Expand Down Expand Up @@ -535,9 +562,13 @@ def is_gcode_rb_selected(self):
return True
return False

@Slot()
def touched_probe(self):
self.ui.probe_pb.setStyleSheet(StyleManager.set_button_color(bg_color="green", color="black"))

@Slot(list)
def update_probe(self, probe_l):
pass
self.ui.probe_pb.setStyleSheet(StyleManager.set_button_color(bg_color="dark_grey", color="white"))

@Slot(str)
def update_console_text(self, new_text):
Expand Down Expand Up @@ -626,6 +657,7 @@ def act_on_connection(self, connection_status):
self.ui.tool_change_tb.setEnabled(True)
if self.is_gcode_rb_selected():
self.ui.play_tb.setEnabled(True)
self.enable_control_jog_elements(True)
self.controller_connected_s.emit(True)
self.ctrl_layer.create_pointer(coords=(0, 0, 0))

Expand All @@ -650,6 +682,7 @@ def act_on_disconnection(self):
self.ui.stop_tb.setEnabled(False)
self.ui.pause_resume_tb.setEnabled(False)
self.ui.tool_change_tb.setEnabled(False)
self.enable_control_jog_elements(False)
self.controller_connected_s.emit(False)
self.ctrl_layer.remove_pointer()

Expand Down Expand Up @@ -818,7 +851,7 @@ def handle_z_max_changed(self):

def handle_probe_cmd(self):
logger.debug("Probe Command")
# todo: fake parameters just to test probe
self.ui.probe_pb.setStyleSheet(StyleManager.set_button_color("yellow", "black"))
probe_z_min = self.ui.z_min_dsb.value()
self.controlWo.cmd_probe(probe_z_min)

Expand Down
Loading

0 comments on commit 6173016

Please sign in to comment.