diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 59baa53..3baf502 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,10 +50,6 @@ jobs: - name: Pre-commit hooks run: | pre-commit run --all-files - - name: PyLint - run: | - pylint $( find . -path './adafruit*.py' ) - ([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" )) - name: Build assets run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location . - name: Archive bundles diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 07f886c..354c761 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,3 +17,18 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace +- repo: https://github.com/pycqa/pylint + rev: pylint-2.7.1 + hooks: + - id: pylint + name: pylint (library code) + types: [python] + exclude: "^(docs/|examples/|setup.py$)" +- repo: local + hooks: + - id: pylint_examples + name: pylint (examples code) + description: Run pylint rules on "examples/*.py" files + entry: /usr/bin/env bash -c + args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)'] + language: system diff --git a/examples/pioasm_neopixel.py b/examples/pioasm_neopixel.py index a682d94..cf72847 100644 --- a/examples/pioasm_neopixel.py +++ b/examples/pioasm_neopixel.py @@ -5,6 +5,7 @@ import time import rp2pio import board +import microcontroller import adafruit_pioasm # NeoPixels are 800khz bit streams. Zeroes are 1/3 duty cycle (~416ns) and ones @@ -25,21 +26,31 @@ assembled = adafruit_pioasm.assemble(program) +# If the board has a designated neopixel, then use it. Otherwise use +# GPIO16 as an arbitrary choice. +if hasattr(board, "NEOPIXEL"): + NEOPIXEL = board.NEOPIXEL +else: + NEOPIXEL = microcontroller.pin.GPIO16 + sm = rp2pio.StateMachine( assembled, frequency=800000 * 6, # 800khz * 6 clocks per bit - init=adafruit_pioasm.assemble("set pindirs 1"), - first_set_pin=board.D12, - first_sideset_pin=board.D12, + first_set_pin=NEOPIXEL, + first_sideset_pin=NEOPIXEL, auto_pull=True, out_shift_right=False, pull_threshold=8, ) print("real frequency", sm.frequency) -for i in range(100): +for i in range(30): sm.write(b"\x0a\x00\x00") time.sleep(0.1) + sm.write(b"\x00\x0a\x00") + time.sleep(0.1) + sm.write(b"\x00\x00\x0a") + time.sleep(0.1) print("writes done") time.sleep(2)