Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions adafruit_drv2605.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,19 +191,18 @@ def library(self, val: int) -> None:
@property
def sequence(self) -> "_DRV2605_Sequence":
"""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 :class:`~Effect`
or :class:`~Pause` class. See the datasheet for a complete table of effect ID
values and the associated waveform / effect.

E.g.:

.. code-block:: python

# Getting the effect stored in a slot
slot_0_effect = drv.sequence[0]

.. code-block:: python

# Setting an Effect in the first sequence slot
drv.sequence[0] = Effect(88)
"""
Expand Down Expand Up @@ -317,16 +316,16 @@ def __init__(self, DRV2605_instance: DRV2605) -> None:
def __setitem__(self, slot: int, effect: Union[Effect, Pause]) -> None:
"""Write an Effect or Pause to a slot."""
if not 0 <= slot <= 7:
raise IndexError("Slot must be a value within 0-6!")
raise IndexError("Slot must be a value within 0-7!")
if not isinstance(effect, (Effect, Pause)):
raise TypeError("Effect must be either an Effect() or Pause()!")
raise TypeError("Effect must be either an Effect or Pause!")
# pylint: disable=protected-access
self._drv2605._write_u8(_DRV2605_REG_WAVESEQ1 + slot, effect.raw_value)

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