Skip to content

Commit c51d0c8

Browse files
authored
Merge pull request #12 from adafruit/jepler-examples-improvements
Fix the neopixel example
2 parents 94dccca + 937357e commit c51d0c8

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

.github/workflows/build.yml

-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ jobs:
5050
- name: Pre-commit hooks
5151
run: |
5252
pre-commit run --all-files
53-
- name: PyLint
54-
run: |
55-
pylint $( find . -path './adafruit*.py' )
56-
([[ ! -d "examples" ]] || pylint --disable=missing-docstring,invalid-name,bad-whitespace $( find . -path "./examples/*.py" ))
5753
- name: Build assets
5854
run: circuitpython-build-bundles --filename_prefix ${{ steps.repo-name.outputs.repo-name }} --library_location .
5955
- name: Archive bundles

.pre-commit-config.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,18 @@ repos:
1717
- id: check-yaml
1818
- id: end-of-file-fixer
1919
- id: trailing-whitespace
20+
- repo: https://github.com/pycqa/pylint
21+
rev: pylint-2.7.1
22+
hooks:
23+
- id: pylint
24+
name: pylint (library code)
25+
types: [python]
26+
exclude: "^(docs/|examples/|setup.py$)"
27+
- repo: local
28+
hooks:
29+
- id: pylint_examples
30+
name: pylint (examples code)
31+
description: Run pylint rules on "examples/*.py" files
32+
entry: /usr/bin/env bash -c
33+
args: ['([[ ! -d "examples" ]] || for example in $(find . -path "./examples/*.py"); do pylint --disable=missing-docstring,invalid-name $example; done)']
34+
language: system

examples/pioasm_neopixel.py

+15-4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import time
66
import rp2pio
77
import board
8+
import microcontroller
89
import adafruit_pioasm
910

1011
# NeoPixels are 800khz bit streams. Zeroes are 1/3 duty cycle (~416ns) and ones
@@ -25,21 +26,31 @@
2526

2627
assembled = adafruit_pioasm.assemble(program)
2728

29+
# If the board has a designated neopixel, then use it. Otherwise use
30+
# GPIO16 as an arbitrary choice.
31+
if hasattr(board, "NEOPIXEL"):
32+
NEOPIXEL = board.NEOPIXEL
33+
else:
34+
NEOPIXEL = microcontroller.pin.GPIO16
35+
2836
sm = rp2pio.StateMachine(
2937
assembled,
3038
frequency=800000 * 6, # 800khz * 6 clocks per bit
31-
init=adafruit_pioasm.assemble("set pindirs 1"),
32-
first_set_pin=board.D12,
33-
first_sideset_pin=board.D12,
39+
first_set_pin=NEOPIXEL,
40+
first_sideset_pin=NEOPIXEL,
3441
auto_pull=True,
3542
out_shift_right=False,
3643
pull_threshold=8,
3744
)
3845
print("real frequency", sm.frequency)
3946

40-
for i in range(100):
47+
for i in range(30):
4148
sm.write(b"\x0a\x00\x00")
4249
time.sleep(0.1)
50+
sm.write(b"\x00\x0a\x00")
51+
time.sleep(0.1)
52+
sm.write(b"\x00\x00\x0a")
53+
time.sleep(0.1)
4354
print("writes done")
4455

4556
time.sleep(2)

0 commit comments

Comments
 (0)