Giter VIP home page Giter VIP logo

adafruit_circuitpython_ws2801's Introduction

Introduction

Documentation Status Discord Build Status Code Style: Black

Higher level WS2801 driver that presents the LED string as a sequence. It is the same api as the NeoPixel library.

Colors are stored as tuples by default. However, you can also use int hex syntax to set values similar to colors on the web. For example, 0x800000 (#800000 on the web) is equivalent to (0x80, 0, 0).

Dependencies

This driver depends on:

Please ensure all dependencies are available on the CircuitPython filesystem. This is easily achieved by downloading the Adafruit library and driver bundle.

Installing from PyPI

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally from PyPI. To install for current user:

pip3 install adafruit-circuitpython-ws2801

To install system-wide (this may be required in some cases):

sudo pip3 install adafruit-circuitpython-ws2801

To install in a virtual environment in your current project:

mkdir project-name && cd project-name
python3 -m venv .venv
source .venv/bin/activate
pip3 install adafruit-circuitpython-ws2801

Usage Example

This example demonstrates the library driving a strand of 25 RGB leds by a Gemma M0 using the hardware SPI capable outputs.

import board
import adafruit_ws2801

leds = adafruit_ws2801.WS2801(board.D2, board.D0, 25)
leds.fill((0x80, 0, 0))

Documentation

API documentation for this library can be found on Read the Docs.

For information on building library documentation, please check out this guide.

Contributing

Contributions are welcome! Please read our Code of Conduct before contributing to help this project stay welcoming.

adafruit_circuitpython_ws2801's People

Contributors

brennen avatar dhalbert avatar evaherrada avatar foamyguy avatar kattni avatar ladyada avatar makermelissa avatar rhooper avatar schelmo avatar sgzmd avatar siddacious avatar sommersoft avatar tannewt avatar tekktrik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adafruit_circuitpython_ws2801's Issues

Missing Type Annotations

There are missing type annotations for some functions in this library.

The typing module does not exist on CircuitPython devices so the import needs to be wrapped in try/except to catch the error for missing import. There is an example of how that is done here:

try:
    from typing import List, Tuple
except ImportError:
    pass

Once imported the typing annotations for the argument type(s), and return type(s) can be added to the function signature. Here is an example of a function that has had this done already:

def wrap_text_to_pixels(
    string: str, max_width: int, font=None, indent0: str = "", indent1: str = ""
) -> List[str]:

If you are new to Git or Github we have a guide about contributing to our projects here: https://learn.adafruit.com/contribute-to-circuitpython-with-git-and-github

There is also a guide that covers our CI utilities and how to run them locally to ensure they will pass in Github Actions here: https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/check-your-code In particular the pages: Sharing docs on ReadTheDocs and Check your code with pre-commit contain the tools to install and commands to run locally to run the checks.

If you are attempting to resolve this issue and need help, you can post a comment on this issue and tag both @FoamyGuy and @kattni or reach out to us on Discord: https://adafru.it/discord in the #circuitpython-dev channel.

The following locations are reported by mypy to be missing type annotations:

  • adafruit_ws2801.py:52
  • adafruit_ws2801.py:90
  • adafruit_ws2801.py:96
  • adafruit_ws2801.py:109
  • adafruit_ws2801.py:125
  • adafruit_ws2801.py:147
  • adafruit_ws2801.py:152
  • adafruit_ws2801.py:162

Lib doesn't work with Raspberry Pi 4B

I can operate a ws2801 led strip with the old/deprecated python2 adafruit_ws2801 lib.
my pin assignment:

5V  => 04 (+5)
CK  => 23 (SCLK)
SI  => 19 (MOSI)
GND => 06 (GND)

a pprint(board) shows me the following dict:

'pin': <module 'adafruit_blinka.microcontroller.bcm283x.pin' from '/usr/local/lib/python3.7/dist-packages/adafruit_blinka/microcontroller/bcm283x/pin.py'>, 'D0': 0, 'D1': 1, 'D2': 2, 'SDA': 2, 'D3': 3, 'SCL': 3, 'D4': 4, 'D5': 5, 'D6': 6, 'D7': 7, 'CE1': 7, 'D8': 8, 'CE0': 8, 'D9': 9, 'MISO': 9, 'D10': 10, 'MOSI': 10, 'D11': 11, 'SCLK': 11, 'SCK': 11, 'D12': 12, 'D13': 13, 'D14': 14, 'TXD': 14, 'D15': 15, 'RXD': 15, 'TX': 14, 'RX': 15, 'D16': 16, 'D17': 17, 'D18': 18, 'D19': 19, 'MISO_1': 19, 'D20': 20, 'MOSI_1': 20, 'D21': 21, 'SCLK_1': 21, 'SCK_1': 21, 'D22': 22, 'D23': 23, 'D24': 24, 'D25': 25, 'D26': 26, 'D27': 27, 'I2C': <function I2C at 0xb667f738>, 'SPI': <function SPI at 0xb65fc030>}

which doesn't match the pin layout of the 4B model at all.
For instance, on the 4B
MOSI is 19 and SCLK is 23

see https://pinout.xyz/

Is there any way to configure/setup the lib by using the constructor differently?

Trouble migrating from Adafruit_WS2801.WS2801Pixels

I'm trying to migrate from the deprecated WS2801 library to the new one, but am having trouble.

When I use the old library, the LED in position 0 lights up red:

In [6]: from Adafruit_WS2801 import WS2801Pixels
In [7]: pixels = WS2801Pixels(150, 11, 10)
In [8]: pixels.set_pixel_rgb(0, 255, 0, 0)
In [9]: pixels.show()      # this works and I see the pixel light up

However, using this library, the pixel does not light

In [1]: from adafruit_ws2801 import WS2801
In [2]: import board
In [3]: pixels = WS2801(board.D11, board.D10, 150);
In [4]: pixels[0] = (255, 0, 0)
In [5]: pixels.show()   # the pixel doesn't light up 

I'm using a Raspberry Pi 3B+

In [6]: board.board_id
Out[6]: 'RASPBERRY_PI_3B_PLUS'

Appreciate any help!

Value returned is backwards of what it was set to

When getting a value from an LED, the value returned is in reverse of what it was set to. For example in this code snippet we initialize the LEDs and set leds[0] to (255, 0, 0):

import board
import adafruit_ws2801

odata = board.D5
oclock = board.D6
numleds = 25
bright = 1.0
leds = adafruit_ws2801.WS2801(oclock, odata, numleds, brightness=bright, auto_write=True)
leds[0] = (255, 0, 0)

Now if we try and retrieve it, we get (0, 0, 255)

print(leds[0]) # Returns (0, 0, 255)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.