Skip to content

Commit

Permalink
Merge pull request #28 from tekktrik/feature/add-eight-slot
Browse files Browse the repository at this point in the history
Allow access to eighth sequence slot
  • Loading branch information
caternuson authored Jan 11, 2022
2 parents b0786b5 + e4c38d8 commit 32ae578
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions adafruit_drv2605.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def library(self, val):
@property
def sequence(self):
"""List-like sequence of waveform effects.
Get or set an effect waveform for slot 0-6 by indexing the sequence
Get or set an effect waveform for slot 0-7 by indexing the sequence
property with the slot number. A slot must be set to either an Effect()
or Pause() class. See the datasheet for a complete table of effect ID
values and the associated waveform / effect.
Expand All @@ -192,14 +192,14 @@ def sequence(self):

def set_waveform(self, effect_id, slot=0):
"""Select an effect waveform for the specified slot (default is slot 0,
but up to 7 effects can be combined with slot values 0 to 6). See the
but up to 8 effects can be combined with slot values 0 to 7). See the
datasheet for a complete table of effect ID values and the associated
waveform / effect.
"""
if not 0 <= effect_id <= 123:
raise ValueError("Effect ID must be a value within 0-123!")
if not 0 <= slot <= 6:
raise ValueError("Slot must be a value within 0-6!")
if not 0 <= slot <= 7:
raise ValueError("Slot must be a value within 0-7!")
self._write_u8(_DRV2605_REG_WAVESEQ1 + slot, effect_id)

# pylint: disable=invalid-name
Expand Down Expand Up @@ -285,7 +285,7 @@ def __init__(self, DRV2605_instance):

def __setitem__(self, slot, effect):
"""Write an Effect or Pause to a slot."""
if not 0 <= slot <= 6:
if not 0 <= slot <= 7:
raise IndexError("Slot must be a value within 0-6!")
if not isinstance(effect, (Effect, Pause)):
raise TypeError("Effect must be either an Effect() or Pause()!")
Expand All @@ -294,7 +294,7 @@ def __setitem__(self, slot, effect):

def __getitem__(self, slot):
"""Read an effect ID from a slot. Returns either a Pause or Effect class."""
if not 0 <= slot <= 6:
if not 0 <= slot <= 7:
raise IndexError("Slot must be a value within 0-6!")
# pylint: disable=protected-access
slot_contents = self._drv2605._read_u8(_DRV2605_REG_WAVESEQ1 + slot)
Expand All @@ -304,7 +304,7 @@ def __getitem__(self, slot):

def __iter__(self):
"""Returns an iterator over the waveform sequence slots."""
for slot in range(0, 7):
for slot in range(0, 8):
yield self[slot]

def __repr__(self):
Expand Down

0 comments on commit 32ae578

Please sign in to comment.