Skip to content

Commit 95a43d6

Browse files
authored
Merge pull request #92 from rpi-ws281x/patch-v5.0.0
Prep for v5.0.0
2 parents 7404caa + ca5645f commit 95a43d6

File tree

9 files changed

+1203
-1204
lines changed

9 files changed

+1203
-1204
lines changed

library/CHANGELOG.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1+
5.0.0
2+
-----
3+
4+
* Bumped to rpi_ws281x v1.0.0 (15330cb)
5+
* Full rpi_ws281x changes: https://github.com/jgarff/rpi_ws281x/compare/9be313f...15330cb
6+
* New: Added support for Revisions 0xa03141, 0xb03141, 0xc04141, 0xd03141 (CM4)
7+
* New: Added support for Revision 0xa32082 (Pi 3 B)
8+
* New: Added support for slices on PixelStrip
9+
* New: Regenerated SWIG bindings with v4.0.2
10+
* New: RGBW class for interfacing with pixel values
11+
112
4.3.4
13+
-----
214

315
* New: Added support for Revision 0xa03115 (Pi 4, 1GB v1.5)
416

library/lib

library/rpi_ws281x.py

Lines changed: 160 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,75 @@
11
# This file was automatically generated by SWIG (http://www.swig.org).
2-
# Version 2.0.12
2+
# Version 4.0.2
33
#
44
# Do not make changes to this file unless you know what you are doing--modify
55
# the SWIG interface file instead.
66

7+
from sys import version_info as _swig_python_version_info
78

9+
if _swig_python_version_info < (2, 7, 0):
10+
raise RuntimeError("Python 2.7 or later required")
811

9-
10-
11-
from sys import version_info
12-
if version_info >= (2,6,0):
13-
def swig_import_helper():
14-
from os.path import dirname
15-
import imp
16-
fp = None
17-
try:
18-
fp, pathname, description = imp.find_module('_rpi_ws281x', [dirname(__file__)])
19-
except ImportError:
20-
import _rpi_ws281x
21-
return _rpi_ws281x
22-
if fp is not None:
23-
try:
24-
_mod = imp.load_module('_rpi_ws281x', fp, pathname, description)
25-
finally:
26-
fp.close()
27-
return _mod
28-
_rpi_ws281x = swig_import_helper()
29-
del swig_import_helper
12+
# Import the low-level C/C++ module
13+
if __package__ or "." in __name__:
14+
from . import _rpi_ws281x
3015
else:
3116
import _rpi_ws281x
32-
del version_info
17+
3318
try:
34-
_swig_property = property
35-
except NameError:
36-
pass # Python < 2.2 doesn't have 'property'.
37-
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
38-
if (name == "thisown"): return self.this.own(value)
39-
if (name == "this"):
40-
if type(value).__name__ == 'SwigPyObject':
41-
self.__dict__[name] = value
42-
return
43-
method = class_type.__swig_setmethods__.get(name,None)
44-
if method: return method(self,value)
45-
if (not static):
46-
self.__dict__[name] = value
47-
else:
48-
raise AttributeError("You cannot add attributes to %s" % self)
49-
50-
def _swig_setattr(self,class_type,name,value):
51-
return _swig_setattr_nondynamic(self,class_type,name,value,0)
52-
53-
def _swig_getattr(self,class_type,name):
54-
if (name == "thisown"): return self.this.own()
55-
method = class_type.__swig_getmethods__.get(name,None)
56-
if method: return method(self)
57-
raise AttributeError(name)
19+
import builtins as __builtin__
20+
except ImportError:
21+
import __builtin__
22+
5823

5924
def _swig_repr(self):
60-
try: strthis = "proxy of " + self.this.__repr__()
61-
except: strthis = ""
62-
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
25+
try:
26+
strthis = "proxy of " + self.this.__repr__()
27+
except __builtin__.Exception:
28+
strthis = ""
29+
return "<%s.%s; %s >" % (
30+
self.__class__.__module__,
31+
self.__class__.__name__,
32+
strthis,
33+
)
6334

64-
try:
65-
_object = object
66-
_newclass = 1
67-
except AttributeError:
68-
class _object : pass
69-
_newclass = 0
35+
36+
def _swig_setattr_nondynamic_instance_variable(set):
37+
def set_instance_attr(self, name, value):
38+
if name == "thisown":
39+
self.this.own(value)
40+
elif name == "this":
41+
set(self, name, value)
42+
elif hasattr(self, name) and isinstance(getattr(type(self), name), property):
43+
set(self, name, value)
44+
else:
45+
raise AttributeError("You cannot add instance attributes to %s" % self)
46+
47+
return set_instance_attr
48+
49+
50+
def _swig_setattr_nondynamic_class_variable(set):
51+
def set_class_attr(cls, name, value):
52+
if hasattr(cls, name) and not isinstance(getattr(cls, name), property):
53+
set(cls, name, value)
54+
else:
55+
raise AttributeError("You cannot add class attributes to %s" % cls)
56+
57+
return set_class_attr
58+
59+
60+
def _swig_add_metaclass(metaclass):
61+
"""Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass"""
62+
63+
def wrapper(cls):
64+
return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy())
65+
66+
return wrapper
67+
68+
69+
class _SwigNonDynamicMeta(type):
70+
"""Meta class to enforce nondynamic attributes (no new attributes) for a class"""
71+
72+
__setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__)
7073

7174

7275
WS2811_TARGET_FREQ = _rpi_ws281x.WS2811_TARGET_FREQ
@@ -86,86 +89,85 @@ class _object : pass
8689
WS2812_STRIP = _rpi_ws281x.WS2812_STRIP
8790
SK6812_STRIP = _rpi_ws281x.SK6812_STRIP
8891
SK6812W_STRIP = _rpi_ws281x.SK6812W_STRIP
89-
class ws2811_channel_t(_object):
90-
__swig_setmethods__ = {}
91-
__setattr__ = lambda self, name, value: _swig_setattr(self, ws2811_channel_t, name, value)
92-
__swig_getmethods__ = {}
93-
__getattr__ = lambda self, name: _swig_getattr(self, ws2811_channel_t, name)
92+
93+
94+
class ws2811_channel_t(object):
95+
thisown = property(
96+
lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag"
97+
)
9498
__repr__ = _swig_repr
95-
__swig_setmethods__["gpionum"] = _rpi_ws281x.ws2811_channel_t_gpionum_set
96-
__swig_getmethods__["gpionum"] = _rpi_ws281x.ws2811_channel_t_gpionum_get
97-
if _newclass:gpionum = _swig_property(_rpi_ws281x.ws2811_channel_t_gpionum_get, _rpi_ws281x.ws2811_channel_t_gpionum_set)
98-
__swig_setmethods__["invert"] = _rpi_ws281x.ws2811_channel_t_invert_set
99-
__swig_getmethods__["invert"] = _rpi_ws281x.ws2811_channel_t_invert_get
100-
if _newclass:invert = _swig_property(_rpi_ws281x.ws2811_channel_t_invert_get, _rpi_ws281x.ws2811_channel_t_invert_set)
101-
__swig_setmethods__["count"] = _rpi_ws281x.ws2811_channel_t_count_set
102-
__swig_getmethods__["count"] = _rpi_ws281x.ws2811_channel_t_count_get
103-
if _newclass:count = _swig_property(_rpi_ws281x.ws2811_channel_t_count_get, _rpi_ws281x.ws2811_channel_t_count_set)
104-
__swig_setmethods__["strip_type"] = _rpi_ws281x.ws2811_channel_t_strip_type_set
105-
__swig_getmethods__["strip_type"] = _rpi_ws281x.ws2811_channel_t_strip_type_get
106-
if _newclass:strip_type = _swig_property(_rpi_ws281x.ws2811_channel_t_strip_type_get, _rpi_ws281x.ws2811_channel_t_strip_type_set)
107-
__swig_setmethods__["leds"] = _rpi_ws281x.ws2811_channel_t_leds_set
108-
__swig_getmethods__["leds"] = _rpi_ws281x.ws2811_channel_t_leds_get
109-
if _newclass:leds = _swig_property(_rpi_ws281x.ws2811_channel_t_leds_get, _rpi_ws281x.ws2811_channel_t_leds_set)
110-
__swig_setmethods__["brightness"] = _rpi_ws281x.ws2811_channel_t_brightness_set
111-
__swig_getmethods__["brightness"] = _rpi_ws281x.ws2811_channel_t_brightness_get
112-
if _newclass:brightness = _swig_property(_rpi_ws281x.ws2811_channel_t_brightness_get, _rpi_ws281x.ws2811_channel_t_brightness_set)
113-
__swig_setmethods__["wshift"] = _rpi_ws281x.ws2811_channel_t_wshift_set
114-
__swig_getmethods__["wshift"] = _rpi_ws281x.ws2811_channel_t_wshift_get
115-
if _newclass:wshift = _swig_property(_rpi_ws281x.ws2811_channel_t_wshift_get, _rpi_ws281x.ws2811_channel_t_wshift_set)
116-
__swig_setmethods__["rshift"] = _rpi_ws281x.ws2811_channel_t_rshift_set
117-
__swig_getmethods__["rshift"] = _rpi_ws281x.ws2811_channel_t_rshift_get
118-
if _newclass:rshift = _swig_property(_rpi_ws281x.ws2811_channel_t_rshift_get, _rpi_ws281x.ws2811_channel_t_rshift_set)
119-
__swig_setmethods__["gshift"] = _rpi_ws281x.ws2811_channel_t_gshift_set
120-
__swig_getmethods__["gshift"] = _rpi_ws281x.ws2811_channel_t_gshift_get
121-
if _newclass:gshift = _swig_property(_rpi_ws281x.ws2811_channel_t_gshift_get, _rpi_ws281x.ws2811_channel_t_gshift_set)
122-
__swig_setmethods__["bshift"] = _rpi_ws281x.ws2811_channel_t_bshift_set
123-
__swig_getmethods__["bshift"] = _rpi_ws281x.ws2811_channel_t_bshift_get
124-
if _newclass:bshift = _swig_property(_rpi_ws281x.ws2811_channel_t_bshift_get, _rpi_ws281x.ws2811_channel_t_bshift_set)
125-
__swig_setmethods__["gamma"] = _rpi_ws281x.ws2811_channel_t_gamma_set
126-
__swig_getmethods__["gamma"] = _rpi_ws281x.ws2811_channel_t_gamma_get
127-
if _newclass:gamma = _swig_property(_rpi_ws281x.ws2811_channel_t_gamma_get, _rpi_ws281x.ws2811_channel_t_gamma_set)
128-
def __init__(self):
129-
this = _rpi_ws281x.new_ws2811_channel_t()
130-
try: self.this.append(this)
131-
except: self.this = this
99+
gpionum = property(
100+
_rpi_ws281x.ws2811_channel_t_gpionum_get,
101+
_rpi_ws281x.ws2811_channel_t_gpionum_set,
102+
)
103+
invert = property(
104+
_rpi_ws281x.ws2811_channel_t_invert_get, _rpi_ws281x.ws2811_channel_t_invert_set
105+
)
106+
count = property(
107+
_rpi_ws281x.ws2811_channel_t_count_get, _rpi_ws281x.ws2811_channel_t_count_set
108+
)
109+
strip_type = property(
110+
_rpi_ws281x.ws2811_channel_t_strip_type_get,
111+
_rpi_ws281x.ws2811_channel_t_strip_type_set,
112+
)
113+
leds = property(
114+
_rpi_ws281x.ws2811_channel_t_leds_get, _rpi_ws281x.ws2811_channel_t_leds_set
115+
)
116+
brightness = property(
117+
_rpi_ws281x.ws2811_channel_t_brightness_get,
118+
_rpi_ws281x.ws2811_channel_t_brightness_set,
119+
)
120+
wshift = property(
121+
_rpi_ws281x.ws2811_channel_t_wshift_get, _rpi_ws281x.ws2811_channel_t_wshift_set
122+
)
123+
rshift = property(
124+
_rpi_ws281x.ws2811_channel_t_rshift_get, _rpi_ws281x.ws2811_channel_t_rshift_set
125+
)
126+
gshift = property(
127+
_rpi_ws281x.ws2811_channel_t_gshift_get, _rpi_ws281x.ws2811_channel_t_gshift_set
128+
)
129+
bshift = property(
130+
_rpi_ws281x.ws2811_channel_t_bshift_get, _rpi_ws281x.ws2811_channel_t_bshift_set
131+
)
132+
gamma = property(
133+
_rpi_ws281x.ws2811_channel_t_gamma_get, _rpi_ws281x.ws2811_channel_t_gamma_set
134+
)
135+
136+
def __init__(self):
137+
_rpi_ws281x.ws2811_channel_t_swiginit(self, _rpi_ws281x.new_ws2811_channel_t())
138+
132139
__swig_destroy__ = _rpi_ws281x.delete_ws2811_channel_t
133-
__del__ = lambda self : None;
134-
ws2811_channel_t_swigregister = _rpi_ws281x.ws2811_channel_t_swigregister
135-
ws2811_channel_t_swigregister(ws2811_channel_t)
136-
137-
class ws2811_t(_object):
138-
__swig_setmethods__ = {}
139-
__setattr__ = lambda self, name, value: _swig_setattr(self, ws2811_t, name, value)
140-
__swig_getmethods__ = {}
141-
__getattr__ = lambda self, name: _swig_getattr(self, ws2811_t, name)
140+
141+
142+
# Register ws2811_channel_t in _rpi_ws281x:
143+
_rpi_ws281x.ws2811_channel_t_swigregister(ws2811_channel_t)
144+
145+
146+
class ws2811_t(object):
147+
thisown = property(
148+
lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag"
149+
)
142150
__repr__ = _swig_repr
143-
__swig_setmethods__["render_wait_time"] = _rpi_ws281x.ws2811_t_render_wait_time_set
144-
__swig_getmethods__["render_wait_time"] = _rpi_ws281x.ws2811_t_render_wait_time_get
145-
if _newclass:render_wait_time = _swig_property(_rpi_ws281x.ws2811_t_render_wait_time_get, _rpi_ws281x.ws2811_t_render_wait_time_set)
146-
__swig_setmethods__["device"] = _rpi_ws281x.ws2811_t_device_set
147-
__swig_getmethods__["device"] = _rpi_ws281x.ws2811_t_device_get
148-
if _newclass:device = _swig_property(_rpi_ws281x.ws2811_t_device_get, _rpi_ws281x.ws2811_t_device_set)
149-
__swig_setmethods__["rpi_hw"] = _rpi_ws281x.ws2811_t_rpi_hw_set
150-
__swig_getmethods__["rpi_hw"] = _rpi_ws281x.ws2811_t_rpi_hw_get
151-
if _newclass:rpi_hw = _swig_property(_rpi_ws281x.ws2811_t_rpi_hw_get, _rpi_ws281x.ws2811_t_rpi_hw_set)
152-
__swig_setmethods__["freq"] = _rpi_ws281x.ws2811_t_freq_set
153-
__swig_getmethods__["freq"] = _rpi_ws281x.ws2811_t_freq_get
154-
if _newclass:freq = _swig_property(_rpi_ws281x.ws2811_t_freq_get, _rpi_ws281x.ws2811_t_freq_set)
155-
__swig_setmethods__["dmanum"] = _rpi_ws281x.ws2811_t_dmanum_set
156-
__swig_getmethods__["dmanum"] = _rpi_ws281x.ws2811_t_dmanum_get
157-
if _newclass:dmanum = _swig_property(_rpi_ws281x.ws2811_t_dmanum_get, _rpi_ws281x.ws2811_t_dmanum_set)
158-
__swig_setmethods__["channel"] = _rpi_ws281x.ws2811_t_channel_set
159-
__swig_getmethods__["channel"] = _rpi_ws281x.ws2811_t_channel_get
160-
if _newclass:channel = _swig_property(_rpi_ws281x.ws2811_t_channel_get, _rpi_ws281x.ws2811_t_channel_set)
161-
def __init__(self):
162-
this = _rpi_ws281x.new_ws2811_t()
163-
try: self.this.append(this)
164-
except: self.this = this
151+
render_wait_time = property(
152+
_rpi_ws281x.ws2811_t_render_wait_time_get,
153+
_rpi_ws281x.ws2811_t_render_wait_time_set,
154+
)
155+
device = property(_rpi_ws281x.ws2811_t_device_get, _rpi_ws281x.ws2811_t_device_set)
156+
rpi_hw = property(_rpi_ws281x.ws2811_t_rpi_hw_get, _rpi_ws281x.ws2811_t_rpi_hw_set)
157+
freq = property(_rpi_ws281x.ws2811_t_freq_get, _rpi_ws281x.ws2811_t_freq_set)
158+
dmanum = property(_rpi_ws281x.ws2811_t_dmanum_get, _rpi_ws281x.ws2811_t_dmanum_set)
159+
channel = property(
160+
_rpi_ws281x.ws2811_t_channel_get, _rpi_ws281x.ws2811_t_channel_set
161+
)
162+
163+
def __init__(self):
164+
_rpi_ws281x.ws2811_t_swiginit(self, _rpi_ws281x.new_ws2811_t())
165+
165166
__swig_destroy__ = _rpi_ws281x.delete_ws2811_t
166-
__del__ = lambda self : None;
167-
ws2811_t_swigregister = _rpi_ws281x.ws2811_t_swigregister
168-
ws2811_t_swigregister(ws2811_t)
167+
168+
169+
# Register ws2811_t in _rpi_ws281x:
170+
_rpi_ws281x.ws2811_t_swigregister(ws2811_t)
169171

170172
WS2811_SUCCESS = _rpi_ws281x.WS2811_SUCCESS
171173
WS2811_ERROR_GENERIC = _rpi_ws281x.WS2811_ERROR_GENERIC
@@ -184,37 +186,38 @@ def __init__(self):
184186
WS2811_ERROR_SPI_TRANSFER = _rpi_ws281x.WS2811_ERROR_SPI_TRANSFER
185187
WS2811_RETURN_STATE_COUNT = _rpi_ws281x.WS2811_RETURN_STATE_COUNT
186188

187-
def ws2811_init(*args):
188-
return _rpi_ws281x.ws2811_init(*args)
189-
ws2811_init = _rpi_ws281x.ws2811_init
190189

191-
def ws2811_fini(*args):
192-
return _rpi_ws281x.ws2811_fini(*args)
193-
ws2811_fini = _rpi_ws281x.ws2811_fini
190+
def ws2811_init(ws2811):
191+
return _rpi_ws281x.ws2811_init(ws2811)
192+
193+
194+
def ws2811_fini(ws2811):
195+
return _rpi_ws281x.ws2811_fini(ws2811)
196+
197+
198+
def ws2811_render(ws2811):
199+
return _rpi_ws281x.ws2811_render(ws2811)
200+
201+
202+
def ws2811_wait(ws2811):
203+
return _rpi_ws281x.ws2811_wait(ws2811)
204+
205+
206+
def ws2811_get_return_t_str(state):
207+
return _rpi_ws281x.ws2811_get_return_t_str(state)
194208

195-
def ws2811_render(*args):
196-
return _rpi_ws281x.ws2811_render(*args)
197-
ws2811_render = _rpi_ws281x.ws2811_render
198209

199-
def ws2811_wait(*args):
200-
return _rpi_ws281x.ws2811_wait(*args)
201-
ws2811_wait = _rpi_ws281x.ws2811_wait
210+
def ws2811_set_custom_gamma_factor(ws2811, gamma_factor):
211+
return _rpi_ws281x.ws2811_set_custom_gamma_factor(ws2811, gamma_factor)
202212

203-
def ws2811_get_return_t_str(*args):
204-
return _rpi_ws281x.ws2811_get_return_t_str(*args)
205-
ws2811_get_return_t_str = _rpi_ws281x.ws2811_get_return_t_str
206213

207-
def ws2811_led_get(*args):
208-
return _rpi_ws281x.ws2811_led_get(*args)
209-
ws2811_led_get = _rpi_ws281x.ws2811_led_get
214+
def ws2811_led_get(channel, lednum):
215+
return _rpi_ws281x.ws2811_led_get(channel, lednum)
210216

211-
def ws2811_led_set(*args):
212-
return _rpi_ws281x.ws2811_led_set(*args)
213-
ws2811_led_set = _rpi_ws281x.ws2811_led_set
214217

215-
def ws2811_channel_get(*args):
216-
return _rpi_ws281x.ws2811_channel_get(*args)
217-
ws2811_channel_get = _rpi_ws281x.ws2811_channel_get
218-
# This file is compatible with both classic and new-style classes.
218+
def ws2811_led_set(channel, lednum, color):
219+
return _rpi_ws281x.ws2811_led_set(channel, lednum, color)
219220

220221

222+
def ws2811_channel_get(ws, channelnum):
223+
return _rpi_ws281x.ws2811_channel_get(ws, channelnum)

library/rpi_ws281x/__init__.py

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

5-
__version__ = '4.3.4'
5+
__version__ = '5.0.0'

0 commit comments

Comments
 (0)