Skip to content

Commit

Permalink
Fix shift logic, set function control bits to same as Arduino library…
Browse files Browse the repository at this point in the history
…, integrate doc pull.
  • Loading branch information
tdicola committed Jan 31, 2018
1 parent f6cc040 commit c7ed579
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions adafruit_tlc59711.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def _shift_in(target_byte, val):
target_byte <<= 1
if val:
target_byte |= 0x01
return target_byte


class TLC59711:
Expand Down Expand Up @@ -147,10 +148,11 @@ def __init__(self, spi, *, auto_show=True):
# the auto_show property and instead you must manually call show
# after changing them (reduces the need to make frivolous
# memory-hogging properties).
self.outtmg = False
# Set OUTTMG, TMGRST, and DSPRPT to on like the Arduino library.
self.outtmg = True
self.extgclk = False
self.tmgrst = False
self.dsprpt = False
self.tmgrst = True
self.dsprpt = True
self.blank = False

def _write(self):
Expand All @@ -166,14 +168,14 @@ def _write(self):
self._shift_reg[0] = 0x25 # 0x25 in top 6 bits initiates write.
# Lower two bits control OUTTMG and EXTGCLK bits, set them
# as appropriate.
_shift_in(self._shift_reg[0], self.outtmg)
_shift_in(self._shift_reg[0], self.extgclk)
self._shift_reg[0] = _shift_in(self._shift_reg[0], self.outtmg)
self._shift_reg[0] = _shift_in(self._shift_reg[0], self.extgclk)
# Next byte contains remaining function control state and start of
# brightness control bits.
self._shift_reg[1] = 0x00
_shift_in(self._shift_reg[1], self.tmgrst)
_shift_in(self._shift_reg[1], self.dsprpt)
_shift_in(self._shift_reg[1], self.blank)
self._shift_reg[1] = _shift_in(self._shift_reg[1], self.tmgrst)
self._shift_reg[1] = _shift_in(self._shift_reg[1], self.dsprpt)
self._shift_reg[1] = _shift_in(self._shift_reg[1], self.blank)
# Top 5 bits from BC blue channel.
self._shift_reg[1] <<= 5
self._shift_reg[1] |= (self._bcb >> 2) & 0b11111
Expand Down

0 comments on commit c7ed579

Please sign in to comment.