From df1111e41be019ee30978d7a612348888db35a3b Mon Sep 17 00:00:00 2001 From: t0mpr1c3 Date: Tue, 17 Oct 2023 09:10:29 -0400 Subject: [PATCH 1/5] remove pass column of knit progress in Single Bed mode --- src/main/python/ayab/knitprogress.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/python/ayab/knitprogress.py b/src/main/python/ayab/knitprogress.py index de4eee66..aefdcce3 100644 --- a/src/main/python/ayab/knitprogress.py +++ b/src/main/python/ayab/knitprogress.py @@ -18,7 +18,7 @@ # https://github.com/AllYarnsAreBeautiful/ayab-desktop from PyQt5.QtCore import Qt, QCoreApplication, QRect, QSize -from PyQt5.QtWidgets import QTableWidget, QTableWidgetItem, QLabel, QSizePolicy, QAbstractItemView, QWidget, QHBoxLayout +from PyQt5.QtWidgets import QTableWidget, QTableWidgetItem, QLabel, QSizePolicy, QAbstractItemView, QWidget, QHBoxLayout, QHeaderView from bitarray import bitarray from . import utils @@ -39,10 +39,9 @@ def __init__(self, parent): super().__init__(parent.ui.graphics_splitter) self.clear() self.setRowCount(0) - self.setStyleSheet("border-width: 0;") self.setGeometry(QRect(0, 0, 700, 220)) self.setContentsMargins(1, 1, 1, 1) - self.verticalHeader().setDefaultSectionSize(16) + self.verticalHeader().setSectionResizeMode(QHeaderView.ResizeToContents) self.verticalHeader().setVisible(False) self.blank = QTableWidgetItem() self.blank.setSizeHint(QSize(0, 0)) @@ -115,7 +114,7 @@ def update(self, status, row_multiplier, midline, auto_mirror): status.bits.reverse() midline = len(status.bits) - midline - table_text = " ".format( + table_text = "
".format( self.orange) for c in range(0, midline): table_text += self.__stitch(status.color, status.bits[c], @@ -123,7 +122,7 @@ def update(self, status, row_multiplier, midline, auto_mirror): table_text += "
" left_side = QLabel(table_text) - table_text = " ".format( + table_text = "
".format( self.green) for c in range(midline, len(status.bits)): table_text += self.__stitch(status.color, status.bits[c], @@ -137,8 +136,10 @@ def update(self, status, row_multiplier, midline, auto_mirror): n_cols = len(columns) self.setCellWidget(0, n_cols, left_side) self.setCellWidget(0, n_cols + 1, right_side) + if row_multiplier == 1: + self.hideColumn(1) if n_cols < 4: - self.horizontalHeader().hideSection(5) + self.hideColumn(5) self.resizeColumnsToContents() self.previousStatus = status @@ -147,20 +148,18 @@ def update(self, status, row_multiplier, midline, auto_mirror): self.scene.row_progress = status.current_row def __item(self, text): - table = "
" + text + "
" item = QTableWidgetItem(text) return item def __stitch(self, color, bit, alt_color=None): # FIXME: borders are not visible - text = "" - return text + text += "dotted;" + return text + "'/>" From c31efa542d82a1c32ccc53c882b2d153c5b4bb8b Mon Sep 17 00:00:00 2001 From: Tom Price Date: Tue, 17 Oct 2023 15:30:29 -0400 Subject: [PATCH 2/5] configurable hardware beep (#576) * configurable hardware beep * fix engine_fsm.py * fix control.py --- src/main/python/ayab/engine/communication.py | 6 ++++-- src/main/python/ayab/engine/communication_mock.py | 2 +- src/main/python/ayab/engine/control.py | 1 + src/main/python/ayab/engine/engine_fsm.py | 3 ++- src/main/python/ayab/preferences.py | 1 + src/main/python/ayab/tests/test_communication.py | 13 +++++++++---- .../python/ayab/tests/test_communication_mock.py | 10 ++++++---- 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/main/python/ayab/engine/communication.py b/src/main/python/ayab/engine/communication.py index 7634c9c7..47c7e425 100644 --- a/src/main/python/ayab/engine/communication.py +++ b/src/main/python/ayab/engine/communication.py @@ -118,13 +118,15 @@ def req_test_API6(self): self.__ser.write(data) def req_start_API6(self, start_needle, stop_needle, - continuous_reporting): + continuous_reporting, disable_hardware_beep): """Send a start message to the device.""" data = bytearray() data.append(Token.reqStart.value) data.append(start_needle) data.append(stop_needle) - data.append(continuous_reporting) + data.append( + 1 * continuous_reporting + + 2 * (not disable_hardware_beep)) hash = 0 hash = add_crc(hash, data) data.append(hash) diff --git a/src/main/python/ayab/engine/communication_mock.py b/src/main/python/ayab/engine/communication_mock.py index 10fdd61b..c5961c01 100644 --- a/src/main/python/ayab/engine/communication_mock.py +++ b/src/main/python/ayab/engine/communication_mock.py @@ -84,7 +84,7 @@ def req_test_API6(self) -> None: self.rx_msg_list.append(cnfTest) def req_start_API6(self, start_needle, stop_needle, - continuous_reporting) -> None: + continuous_reporting, disable_hardware_beep) -> None: """Send a request to start knitting.""" self.__is_started = True cnfStart = bytes([Token.cnfStart.value, 0]) diff --git a/src/main/python/ayab/engine/control.py b/src/main/python/ayab/engine/control.py index 4ab61ceb..aa5a470b 100644 --- a/src/main/python/ayab/engine/control.py +++ b/src/main/python/ayab/engine/control.py @@ -63,6 +63,7 @@ def start(self, pattern, options, operation): self.mode = options.mode self.inf_repeat = options.inf_repeat self.continuous_reporting = options.continuous_reporting + self.prefs = options.prefs self.len_pat_expanded = self.pat_height * self.num_colors self.passes_per_row = self.mode.row_multiplier(self.num_colors) self.start_needle = max(0, self.pattern.pat_start_needle) diff --git a/src/main/python/ayab/engine/engine_fsm.py b/src/main/python/ayab/engine/engine_fsm.py index 36f3c257..06691b9c 100644 --- a/src/main/python/ayab/engine/engine_fsm.py +++ b/src/main/python/ayab/engine/engine_fsm.py @@ -139,7 +139,8 @@ def _API6_request_start(control, operation): # request start control.com.req_start_API6(control.pattern.knit_start_needle, control.pattern.knit_end_needle - 1, - control.continuous_reporting) + control.continuous_reporting, + control.prefs.value("disable_hardware_beep")) control.state = State.CONFIRM_START control.logger.debug("State CONFIRM_START") else: diff --git a/src/main/python/ayab/preferences.py b/src/main/python/ayab/preferences.py index e71aa16b..69e47a2d 100644 --- a/src/main/python/ayab/preferences.py +++ b/src/main/python/ayab/preferences.py @@ -64,6 +64,7 @@ class Preferences(SignalSender): 'default_knit_side_image': bool, # 'default_continuous_reporting': bool, 'quiet_mode': bool, + 'disable_hardware_beep': bool, 'language': Language, } diff --git a/src/main/python/ayab/tests/test_communication.py b/src/main/python/ayab/tests/test_communication.py index 12b848a2..ae4c8ceb 100644 --- a/src/main/python/ayab/tests/test_communication.py +++ b/src/main/python/ayab/tests/test_communication.py @@ -68,12 +68,17 @@ def test_update_API6(self): assert result == expected_result def test_req_start_API6(self): - start_val, end_val, continuous_reporting, crc8 = 0, 10, True, 0x36 + start_val, end_val, continuous_reporting, disable_hardware_beep, crc8 = 0, 10, True, False, 0x8A self.comm_dummy.req_start_API6(start_val, end_val, - continuous_reporting) + continuous_reporting, + disable_hardware_beep) byte_array = bytearray([ - Token.slipFrameEnd.value, Token.reqStart.value, - start_val, end_val, continuous_reporting, crc8, + Token.slipFrameEnd.value, + Token.reqStart.value, + start_val, + end_val, + 1 * continuous_reporting + 2 * (not disable_hardware_beep), + crc8, Token.slipFrameEnd.value ]) bytes_read = self.dummy_serial.read(len(byte_array)) diff --git a/src/main/python/ayab/tests/test_communication_mock.py b/src/main/python/ayab/tests/test_communication_mock.py index 03ede7e5..bfe72bf6 100644 --- a/src/main/python/ayab/tests/test_communication_mock.py +++ b/src/main/python/ayab/tests/test_communication_mock.py @@ -42,10 +42,11 @@ def test_update_API6(self): assert self.comm_dummy.update_API6() == (None, Token.none, 0) def test_req_start_API6(self): - start_val, end_val, continuous_reporting, crc8 = 0, 10, True, 0xb9 + start_val, end_val, continuous_reporting, disable_hardware_beep = 0, 10, True, False expected_result = (bytes([Token.cnfStart.value, 0]), Token.cnfStart, 0) self.comm_dummy.req_start_API6(start_val, end_val, - continuous_reporting) + continuous_reporting, + disable_hardware_beep) bytes_read = self.comm_dummy.update_API6() assert bytes_read == expected_result @@ -86,9 +87,10 @@ def test_cnf_line_API6(self): def test_req_line_API6(self): self.comm_dummy.open_serial() - start_val, end_val, continuous_reporting = 0, 10, True + start_val, end_val, continuous_reporting, disable_hardware_beep = 0, 10, True, False self.comm_dummy.req_start_API6(start_val, end_val, - continuous_reporting) + continuous_reporting, + disable_hardware_beep) self.comm_dummy.update_API6() # cnfStart for i in range(0, 256): From 46fe4b2058bef540627f5949ef2c8583decc0ee6 Mon Sep 17 00:00:00 2001 From: Tom Price Date: Tue, 17 Oct 2023 02:43:53 -0400 Subject: [PATCH 3/5] Fix AppImage version in build-multi-os.yml --- .github/workflows/build-multi-os.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-multi-os.yml b/.github/workflows/build-multi-os.yml index d3e5be58..039ac3c0 100644 --- a/.github/workflows/build-multi-os.yml +++ b/.github/workflows/build-multi-os.yml @@ -440,7 +440,7 @@ jobs: echo "tag=$(git describe --tags)" >> $GITHUB_OUTPUT echo "python=python${{matrix.python-version}}" >> $GITHUB_OUTPUT echo "manifest=$(cat src/main/resources/base/ayab/firmware/manifest.txt)" >> $GITHUB_OUTPUT - echo "python-appimage=python${{matrix.python-version}}.17-cp38-cp38-manylinux2014_x86_64.AppImage" >> $GITHUB_OUTPUT + echo "python-appimage=python${{matrix.python-version}}.18-cp38-cp38-manylinux2014_x86_64.AppImage" >> $GITHUB_OUTPUT - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v4 with: From 9f111f85fec6a1c9c877b10e8e3c240a7f99c50b Mon Sep 17 00:00:00 2001 From: t0mpr1c3 Date: Mon, 16 Oct 2023 18:02:36 -0400 Subject: [PATCH 4/5] change Firmware Flash dialog --- src/main/python/ayab/firmware_flash.py | 14 ++++++++++++-- src/main/python/ayab/firmware_flash_gui.ui | 12 ++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/main/python/ayab/firmware_flash.py b/src/main/python/ayab/firmware_flash.py index f3bd91c9..320fc198 100644 --- a/src/main/python/ayab/firmware_flash.py +++ b/src/main/python/ayab/firmware_flash.py @@ -19,7 +19,7 @@ from PyQt5 import QtGui, QtWidgets from PyQt5.QtCore import QSettings, QCoreApplication -from PyQt5.QtWidgets import QFrame, QListWidgetItem +from PyQt5.QtWidgets import QDialog, QListWidgetItem import serial import json @@ -33,8 +33,10 @@ from .firmware_flash_gui import Ui_Firmware from . import utils +# press Esc to Quit dialog +# press Return to Flash firmware -class FirmwareFlash(QFrame): +class FirmwareFlash(QDialog): # Arduino devices and their `avrdude` names device_dict = { "uno": "atmega328p", @@ -53,6 +55,7 @@ def __init__(self, parent): self.ui = Ui_Firmware() self.ui.setupUi(self) self.ui.flash_firmware.setEnabled(False) + self.ui.flash_firmware.setDefault(True) self.load_json() self.ui.port_combo_box.currentIndexChanged.connect(self.port_selected) @@ -67,6 +70,12 @@ def open(self): self.port_selected() self.show() + def close(self): + """Close dialog and clean firmware list.""" + #self.clean_controller_list() + self.clean_firmware_list() + self.accept() + def load_json(self): self.json_object = self.parse_json("") self.add_items_from_json_object() @@ -158,6 +167,7 @@ def execute_flash_command(self): self.__logger.info("Flashing done!") utils.display_blocking_popup( tr_("Firmware", "Flashing done!")) + self.close() return True def generate_command(self, base_dir, os_name, controller_name, diff --git a/src/main/python/ayab/firmware_flash_gui.ui b/src/main/python/ayab/firmware_flash_gui.ui index 6cfce734..2034ee37 100644 --- a/src/main/python/ayab/firmware_flash_gui.ui +++ b/src/main/python/ayab/firmware_flash_gui.ui @@ -1,7 +1,7 @@ Firmware - + 0 @@ -13,11 +13,8 @@ Firmware Flashing Utility - - QFrame::StyledPanel - - - QFrame::Raised + + True @@ -78,6 +75,9 @@ p, li { white-space: pre-wrap; } Flash + + False + From 66f34113bf409930be2874fc58eb5d61f96d1daa Mon Sep 17 00:00:00 2001 From: t0mpr1c3 Date: Tue, 17 Oct 2023 02:24:32 -0400 Subject: [PATCH 5/5] add debug message when quitting --- src/main/python/ayab/ayab.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main/python/ayab/ayab.py b/src/main/python/ayab/ayab.py index e70eb5b0..8d05703e 100644 --- a/src/main/python/ayab/ayab.py +++ b/src/main/python/ayab/ayab.py @@ -108,8 +108,7 @@ def __activate_ui(self): def __activate_menu(self): self.menu.ui.action_open_image_file.triggered.connect( self.scene.ayabimage.select_file) - self.menu.ui.action_quit.triggered.connect( - QCoreApplication.instance().quit) + self.menu.ui.action_quit.triggered.connect(self.__quit) self.menu.ui.action_load_AYAB_firmware.triggered.connect( self.flash.open) self.menu.ui.action_cancel.triggered.connect(self.engine.cancel) @@ -123,6 +122,11 @@ def __activate_menu(self): slot = getattr(self.scene.ayabimage, t) action.triggered.connect(slot) + def __quit(self): + logging.debug("Quitting") + QCoreApplication.instance().quit() + sys.exit() + def start_knitting(self): """Start the knitting process.""" self.start_operation()