From 3e38277556d9a8dfd62dd1129cc7f127a51564e5 Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Mon, 7 Jul 2025 15:00:32 +0100 Subject: [PATCH 1/6] Fix workflows with new versions --- .github/workflows/build.yml | 6 +++--- .github/workflows/qa.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ddee38e..29c9c52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -19,10 +19,10 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} @@ -35,7 +35,7 @@ jobs: make dist - name: Upload Packages - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ env.RELEASE_FILE }} path: dist/ diff --git a/.github/workflows/qa.yml b/.github/workflows/qa.yml index 4f85883..3c94ef8 100644 --- a/.github/workflows/qa.yml +++ b/.github/workflows/qa.yml @@ -16,10 +16,10 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Set up Python '3,11' - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: '3.11' diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 016a678..095ca2a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,10 +16,10 @@ jobs: steps: - name: Checkout Code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} From a2605ae931187ee5ee75bb7d532796d6161d0b59 Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Mon, 7 Jul 2025 15:33:04 +0100 Subject: [PATCH 2/6] Organise imports --- firmware/firmware_update.py | 3 --- firmware/set_i2c_address.py | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/firmware/firmware_update.py b/firmware/firmware_update.py index 90fd589..4f810da 100644 --- a/firmware/firmware_update.py +++ b/firmware/firmware_update.py @@ -5,14 +5,11 @@ # Usage: python firmware_update.py filename.hex import binascii - import sys import time - from smbus2 import SMBus, i2c_msg - # Small nuvoton: bootloader_id = 0xB001 bootloader_version = 172 diff --git a/firmware/set_i2c_address.py b/firmware/set_i2c_address.py index d99ec36..4a6f922 100644 --- a/firmware/set_i2c_address.py +++ b/firmware/set_i2c_address.py @@ -42,13 +42,13 @@ # 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- # 70: -- -- -- -- -- -- -- -- -import time import os import sys +import time +import RPi.GPIO as GPIO from smbus2 import SMBus, i2c_msg -import RPi.GPIO as GPIO GPIO.setmode(GPIO.BCM) CHIP_ID = 0xBA11 From 708574a5f769a75340823edd66b638f861f6acf6 Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Mon, 7 Jul 2025 15:40:56 +0100 Subject: [PATCH 3/6] fix the ruff checks - functiionally the same --- firmware/firmware_update.py | 4 ++-- firmware/set_i2c_address.py | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/firmware/firmware_update.py b/firmware/firmware_update.py index 4f810da..f8c06b6 100644 --- a/firmware/firmware_update.py +++ b/firmware/firmware_update.py @@ -105,7 +105,7 @@ def write_page_to_aprom(): try: i2c_read8(bootloader_i2c_addr, 0x00) break - except: + except Exception: print("waiting for page write to finish...") def read_page_from_aprom(): @@ -184,7 +184,7 @@ def firmware_update(bin_data, i2c_address, chip_id): if __name__ == "__main__": - filename = sys.argv[1]; + filename = sys.argv[1] # if bin_filename.endswith(".bin"): # bin_data = open(bin_filename, "rb").read() # bin_data = [ord(x) for x in bin_data] diff --git a/firmware/set_i2c_address.py b/firmware/set_i2c_address.py index 4a6f922..bb8665b 100644 --- a/firmware/set_i2c_address.py +++ b/firmware/set_i2c_address.py @@ -42,7 +42,6 @@ # 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- # 70: -- -- -- -- -- -- -- -- -import os import sys import time From 296eb23a16c27aec9606bb3a30c04f1aa79b191b Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Mon, 7 Jul 2025 15:44:27 +0100 Subject: [PATCH 4/6] Further ruff issue --- firmware/firmware_update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/firmware_update.py b/firmware/firmware_update.py index f8c06b6..669e17d 100644 --- a/firmware/firmware_update.py +++ b/firmware/firmware_update.py @@ -123,7 +123,7 @@ def firmware_update(bin_data, i2c_address, chip_id): try: i2c_read8(bootloader_i2c_addr, 0x00) - except: + except Exception: # We're not in bootloader yet, let's enter first confirm_id(i2c_address, chip_id) enter_bootloader(i2c_address) From 19dde0da66471880c87a6da4e5380836555b00ce Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Mon, 7 Jul 2025 15:50:15 +0100 Subject: [PATCH 5/6] Fix trailing whitespace --- firmware/set_i2c_address.py | 38 ++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/firmware/set_i2c_address.py b/firmware/set_i2c_address.py index bb8665b..98f045e 100644 --- a/firmware/set_i2c_address.py +++ b/firmware/set_i2c_address.py @@ -9,18 +9,18 @@ # flash write ongoing # flash write ongoing # flash write finished -# pi@raspberrypi:~ $ -# pi@raspberrypi:~ $ +# pi@raspberrypi:~ $ +# pi@raspberrypi:~ $ # pi@raspberrypi:~ $ i2cdetect -y 1 # 0 1 2 3 4 5 6 7 8 9 a b c d e f -# 00: -- -- -- -- -- -- -- -- -- -- -- -- -- -# 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -# 20: -- -- 22 -- -- -- -- -- -- -- -- -- -- -- -- -- -# 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -# 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -# 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -# 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -# 70: -- -- -- -- -- -- -- -- +# 00: -- -- -- -- -- -- -- -- -- -- -- -- -- +# 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# 20: -- -- 22 -- -- -- -- -- -- -- -- -- -- -- -- -- +# 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# 70: -- -- -- -- -- -- -- -- # pi@raspberrypi:~ $ python set_i2c_address.py 0x22 0x23 # Waiting for flash writing to start.. # flash write ongoing @@ -33,14 +33,14 @@ # flash write finished # pi@raspberrypi:~ $ i2cdetect -y 1 # 0 1 2 3 4 5 6 7 8 9 a b c d e f -# 00: -- -- -- -- -- -- -- -- -- -- -- -- -- -# 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -# 20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- -- -# 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -# 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -# 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -# 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -# 70: -- -- -- -- -- -- -- -- +# 00: -- -- -- -- -- -- -- -- -- -- -- -- -- +# 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# 20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- -- +# 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- +# 70: -- -- -- -- -- -- -- -- import sys import time @@ -51,7 +51,7 @@ GPIO.setmode(GPIO.BCM) CHIP_ID = 0xBA11 -VERSION = 1 +VERSION = 1 # Registers specific to the trackball From dcfc5bc12baef55a7f8da3c4edf5969004cb2044 Mon Sep 17 00:00:00 2001 From: Danny Staple Date: Mon, 7 Jul 2025 15:50:49 +0100 Subject: [PATCH 6/6] Exclude a venv dir during checks --- check.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check.sh b/check.sh index 38dfc3a..e0e0189 100755 --- a/check.sh +++ b/check.sh @@ -40,7 +40,7 @@ done inform "Checking $LIBRARY_NAME $LIBRARY_VERSION\n" inform "Checking for trailing whitespace..." -if grep -IUrn --color "[[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=PKG-INFO; then +if grep -IUrn --color "[[:blank:]]$" --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.venv --exclude-dir=.git --exclude=PKG-INFO; then warning "Trailing whitespace found!" exit 1 else @@ -49,7 +49,7 @@ fi printf "\n" inform "Checking for DOS line-endings..." -if grep -lIUrn --color $'\r' --exclude-dir=dist --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile; then +if grep -lIUrn --color $'\r' --exclude-dir=dist --exclude-dir=.venv --exclude-dir=.tox --exclude-dir=.git --exclude=Makefile; then warning "DOS line-endings found!" exit 1 else