Skip to content

Commit 29725fa

Browse files
committed
Fixes for #3 and #4
1 parent 3ea789d commit 29725fa

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

library/CHANGELOG.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
3.1.0
2+
-----
3+
4+
* New: Exposed all contents of ws for easy access to strip_type constants
5+
* Fix: Matched functionality of upstream legacy library by supporting strip_type
6+
7+
3.0.7
8+
-----
9+
10+
* New: Added support for Pi 3B+

library/neopixel/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# Included for backwards-compatibility with old import name
2-
from rpi_ws281x import __version__, PixelStrip, Adafruit_NeoPixel, Color
2+
from rpi_ws281x import __version__, PixelStrip, Adafruit_NeoPixel, Color, ws
3+
from _rpi_ws281x import *

library/rpi_ws281x/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# New canonical package, to support `import rpi_ws281x`
2-
from .rpi_ws281x import PixelStrip, Adafruit_NeoPixel, Color
2+
from .rpi_ws281x import PixelStrip, Adafruit_NeoPixel, Color, ws
3+
from _rpi_ws281x import *
34

45
__version__ = '3.0.6'

library/rpi_ws281x/rpi_ws281x.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def __setitem__(self, pos, value):
4949

5050

5151
class PixelStrip(object):
52-
def __init__(self, num, pin, freq_hz=800000, dma=10, invert=False, brightness=128, channel=0, gamma=None):
52+
def __init__(self, num, pin, freq_hz=800000, dma=10, invert=False,
53+
brightness=255, channel=0, strip_type=ws.WS2811_STRIP_RGB, gamma=None):
5354
"""Class to represent a SK6812/WS281x LED display. Num should be the
5455
number of pixels in the display, and pin should be the GPIO pin connected
5556
to the display signal line (must be a PWM pin like 18!). Optional
@@ -60,7 +61,12 @@ def __init__(self, num, pin, freq_hz=800000, dma=10, invert=False, brightness=12
6061
"""
6162

6263
if gamma is None:
63-
gamma = list(range(256))
64+
# Support gamma in place of strip_type for back-compat with
65+
# previous version of forked library
66+
if type(strip_type) is list and len(strip_type) == 255:
67+
gamma = strip_type
68+
else:
69+
gamma = list(range(256))
6470

6571
self._gamma = gamma
6672

@@ -82,7 +88,7 @@ def __init__(self, num, pin, freq_hz=800000, dma=10, invert=False, brightness=12
8288
ws.ws2811_channel_t_gpionum_set(self._channel, pin)
8389
ws.ws2811_channel_t_invert_set(self._channel, 0 if not invert else 1)
8490
ws.ws2811_channel_t_brightness_set(self._channel, brightness)
85-
ws.ws2811_channel_t_strip_type_set(self._channel, ws.WS2811_STRIP_GRB)
91+
ws.ws2811_channel_t_strip_type_set(self._channel, strip_type)
8692

8793
# Initialize the controller
8894
ws.ws2811_t_freq_set(self._leds, freq_hz)

library/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def run(self):
1717
build_py.run(self)
1818

1919
setup(name = 'rpi_ws281x',
20-
version = '3.0.7',
20+
version = '3.1.0',
2121
author = 'Jeremy Garff <[email protected]>, Phil Howard <[email protected]>',
2222
author_email = '[email protected]',
2323
description = 'Userspace Raspberry Pi PWM/PCM/SPI library for SK6812 and WS281X LEDs.',

0 commit comments

Comments
 (0)