Skip to content

Commit c7ed579

Browse files
committed
Fix shift logic, set function control bits to same as Arduino library, integrate doc pull.
1 parent f6cc040 commit c7ed579

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

adafruit_tlc59711.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def _shift_in(target_byte, val):
5959
target_byte <<= 1
6060
if val:
6161
target_byte |= 0x01
62+
return target_byte
6263

6364

6465
class TLC59711:
@@ -147,10 +148,11 @@ def __init__(self, spi, *, auto_show=True):
147148
# the auto_show property and instead you must manually call show
148149
# after changing them (reduces the need to make frivolous
149150
# memory-hogging properties).
150-
self.outtmg = False
151+
# Set OUTTMG, TMGRST, and DSPRPT to on like the Arduino library.
152+
self.outtmg = True
151153
self.extgclk = False
152-
self.tmgrst = False
153-
self.dsprpt = False
154+
self.tmgrst = True
155+
self.dsprpt = True
154156
self.blank = False
155157

156158
def _write(self):
@@ -166,14 +168,14 @@ def _write(self):
166168
self._shift_reg[0] = 0x25 # 0x25 in top 6 bits initiates write.
167169
# Lower two bits control OUTTMG and EXTGCLK bits, set them
168170
# as appropriate.
169-
_shift_in(self._shift_reg[0], self.outtmg)
170-
_shift_in(self._shift_reg[0], self.extgclk)
171+
self._shift_reg[0] = _shift_in(self._shift_reg[0], self.outtmg)
172+
self._shift_reg[0] = _shift_in(self._shift_reg[0], self.extgclk)
171173
# Next byte contains remaining function control state and start of
172174
# brightness control bits.
173175
self._shift_reg[1] = 0x00
174-
_shift_in(self._shift_reg[1], self.tmgrst)
175-
_shift_in(self._shift_reg[1], self.dsprpt)
176-
_shift_in(self._shift_reg[1], self.blank)
176+
self._shift_reg[1] = _shift_in(self._shift_reg[1], self.tmgrst)
177+
self._shift_reg[1] = _shift_in(self._shift_reg[1], self.dsprpt)
178+
self._shift_reg[1] = _shift_in(self._shift_reg[1], self.blank)
177179
# Top 5 bits from BC blue channel.
178180
self._shift_reg[1] <<= 5
179181
self._shift_reg[1] |= (self._bcb >> 2) & 0b11111

0 commit comments

Comments
 (0)