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 }} 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 diff --git a/firmware/firmware_update.py b/firmware/firmware_update.py index 90fd589..669e17d 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 @@ -108,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(): @@ -126,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) @@ -187,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 d99ec36..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,26 +33,25 @@ # 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 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 -VERSION = 1 +VERSION = 1 # Registers specific to the trackball