Skip to content

Fix the neopixel example #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 15 additions & 4 deletions examples/pioasm_neopixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for set anymore either.

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)