1
1
# SPDX-FileCopyrightText: 2017 Tony DiCola for Adafruit Industries
2
+ # SPDX-FileCopyrightText: 2018 Stefan Krüger s-light.eu
2
3
#
3
4
# SPDX-License-Identifier: MIT
4
5
9
10
10
11
CircuitPython module for the
11
12
TLC59711 or TLC5971 16-bit 12 channel LED PWM driver.
12
- See examples/simpletest_multi .py for a demo of the usage.
13
+ See examples/tlc59711_simpletest .py for a demo of the usage.
13
14
14
15
* Author(s): Tony DiCola, Stefan Kruger
15
16
@@ -183,9 +184,21 @@ class TLC59711:
183
184
_BC_BIT_COUNT = const (3 * 7 )
184
185
# this holds the chip offset and
185
186
_BC_FIELDS = {
186
- "BCR" : {"offset" : 0 , "length" : 7 , "mask" : 0b01111111 ,},
187
- "BCG" : {"offset" : 7 , "length" : 7 , "mask" : 0b01111111 ,},
188
- "BCB" : {"offset" : 14 , "length" : 7 , "mask" : 0b01111111 ,},
187
+ "BCR" : {
188
+ "offset" : 0 ,
189
+ "length" : 7 ,
190
+ "mask" : 0b01111111 ,
191
+ },
192
+ "BCG" : {
193
+ "offset" : 7 ,
194
+ "length" : 7 ,
195
+ "mask" : 0b01111111 ,
196
+ },
197
+ "BCB" : {
198
+ "offset" : 14 ,
199
+ "length" : 7 ,
200
+ "mask" : 0b01111111 ,
201
+ },
189
202
}
190
203
191
204
##########################################
@@ -218,11 +231,31 @@ class TLC59711:
218
231
_FC_CHIP_BUFFER_BIT_OFFSET = const (_BC_BIT_COUNT )
219
232
_FC_BIT_COUNT = const (5 )
220
233
_FC_FIELDS = {
221
- "BLANK" : {"offset" : 0 , "length" : 1 , "mask" : 0b1 ,},
222
- "DSPRPT" : {"offset" : 1 , "length" : 1 , "mask" : 0b1 ,},
223
- "TMGRST" : {"offset" : 2 , "length" : 1 , "mask" : 0b1 ,},
224
- "EXTGCK" : {"offset" : 3 , "length" : 1 , "mask" : 0b1 ,},
225
- "OUTTMG" : {"offset" : 4 , "length" : 1 , "mask" : 0b1 ,},
234
+ "BLANK" : {
235
+ "offset" : 0 ,
236
+ "length" : 1 ,
237
+ "mask" : 0b1 ,
238
+ },
239
+ "DSPRPT" : {
240
+ "offset" : 1 ,
241
+ "length" : 1 ,
242
+ "mask" : 0b1 ,
243
+ },
244
+ "TMGRST" : {
245
+ "offset" : 2 ,
246
+ "length" : 1 ,
247
+ "mask" : 0b1 ,
248
+ },
249
+ "EXTGCK" : {
250
+ "offset" : 3 ,
251
+ "length" : 1 ,
252
+ "mask" : 0b1 ,
253
+ },
254
+ "OUTTMG" : {
255
+ "offset" : 4 ,
256
+ "length" : 1 ,
257
+ "mask" : 0b1 ,
258
+ },
226
259
}
227
260
228
261
##########################################
@@ -232,7 +265,11 @@ class TLC59711:
232
265
_WC_CHIP_BUFFER_BIT_OFFSET = const (_FC_BIT_COUNT + _BC_BIT_COUNT )
233
266
_WC_BIT_COUNT = const (6 )
234
267
_WC_FIELDS = {
235
- "WRITE_COMMAND" : {"offset" : 0 , "length" : 6 , "mask" : 0b111111 ,},
268
+ "WRITE_COMMAND" : {
269
+ "offset" : 0 ,
270
+ "length" : 6 ,
271
+ "mask" : 0b111111 ,
272
+ },
236
273
}
237
274
WRITE_COMMAND = const (0b100101 )
238
275
##########################################
@@ -433,7 +470,6 @@ def _write(self):
433
470
self ._spi .unlock ()
434
471
435
472
def show (self ):
436
-
437
473
"""Write out the current LED PWM state to the chip."""
438
474
self ._write ()
439
475
@@ -839,57 +875,12 @@ def set_channel(self, channel_index, value):
839
875
)
840
876
841
877
# Define index and length properties to set and get each pixel as
842
- == == == =
843
- """Write out the current LED PWM state to the chip. This is only necessary if
844
- auto_show was set to false in the initializer.
845
- """
846
- self ._write ()
847
-
848
- # Define properties for global brightness control channels.
849
- @property
850
- def red_brightness (self ):
851
- """The red brightness for all channels (i.e. R0, R1, R2, and R3). This is a 7-bit
852
- value from 0-127.
853
- """
854
- return self ._bcr
855
-
856
- @red_brightness .setter
857
- def red_brightness (self , val ):
858
- assert 0 <= val <= 127
859
- self ._bcr = val
860
- if self .auto_show :
861
- self ._write ()
862
-
863
- @property
864
- def green_brightness (self ):
865
- """The green brightness for all channels (i.e. G0, G1, G2, and G3). This is a
866
- 7-bit value from 0-127.
867
- """
868
- return self ._bcg
869
-
870
- @green_brightness .setter
871
- def green_brightness (self , val ):
872
- assert 0 <= val <= 127
873
- self ._bcg = val
874
- if self .auto_show :
875
- self ._write ()
876
-
877
- @property
878
- def blue_brightness (self ):
879
- """The blue brightness for all channels (i.e. B0, B1, B2, and B3). This is a 7-bit
880
- value from 0-127.
881
- """
882
- return self ._bcb
883
-
884
- @blue_brightness .setter
885
- def blue_brightness (self , val ):
886
- assert 0 <= val <= 127
887
- self ._bcb = val
888
- if self .auto_show :
889
- self ._write ()
890
-
891
- # Define index and length properties to set and get each channel as
878
+ # atomic RGB tuples. This provides a similar feel as using neopixels.
879
+ def __len__ (self ):
880
+ """Retrieve TLC5975 the total number of Pixels available."""
881
+ return self .pixel_count
892
882
883
+ def __getitem__ (self , key ):
893
884
"""
894
885
Retrieve the R, G, B values for the provided channel as a 3-tuple.
895
886
0 commit comments