@@ -50,7 +50,7 @@ def __setitem__(self, pos, value):
50
50
51
51
class PixelStrip (object ):
52
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 ):
53
+ brightness = 255 , channel = 0 , strip_type = None , gamma = None ):
54
54
"""Class to represent a SK6812/WS281x LED display. Num should be the
55
55
number of pixels in the display, and pin should be the GPIO pin connected
56
56
to the display signal line (must be a PWM pin like 18!). Optional
@@ -63,12 +63,14 @@ def __init__(self, num, pin, freq_hz=800000, dma=10, invert=False,
63
63
if gamma is None :
64
64
# Support gamma in place of strip_type for back-compat with
65
65
# previous version of forked library
66
- if type (strip_type ) is list and len (strip_type ) == 255 :
66
+ if type (strip_type ) is list and len (strip_type ) == 256 :
67
67
gamma = strip_type
68
+ strip_type = None
68
69
else :
69
70
gamma = list (range (256 ))
70
71
71
- self ._gamma = gamma
72
+ if strip_type is None :
73
+ strip_type = ws .WS2811_STRIP_GRB
72
74
73
75
# Create ws2811_t structure and fill in parameters.
74
76
self ._leds = ws .new_ws2811_t ()
@@ -83,7 +85,7 @@ def __init__(self, num, pin, freq_hz=800000, dma=10, invert=False,
83
85
84
86
# Initialize the channel in use
85
87
self ._channel = ws .ws2811_channel_get (self ._leds , channel )
86
- ws .ws2811_channel_t_gamma_set (self ._channel , self . _gamma )
88
+ ws .ws2811_channel_t_gamma_set (self ._channel , gamma )
87
89
ws .ws2811_channel_t_count_set (self ._channel , num )
88
90
ws .ws2811_channel_t_gpionum_set (self ._channel , pin )
89
91
ws .ws2811_channel_t_invert_set (self ._channel , 0 if not invert else 1 )
@@ -109,8 +111,7 @@ def _cleanup(self):
109
111
110
112
def setGamma (self , gamma ):
111
113
if type (gamma ) is list and len (gamma ) == 256 :
112
- self ._gamma = gamma
113
- ws .ws2811_channel_t_gamma_set (self ._channel , self ._gamma )
114
+ ws .ws2811_channel_t_gamma_set (self ._channel , gamma )
114
115
115
116
def begin (self ):
116
117
"""Initialize library, must be called once before other functions are
0 commit comments