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
12 changes: 8 additions & 4 deletions adafruit_drv2605.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def mode(self):

@mode.setter
def mode(self, val):
assert 0 <= val <= 7
if not 0 <= val <= 7:
raise ValueError('Mode must be a value within 0-7!')
self._write_u8(_DRV2605_REG_MODE, val)

@property
Expand All @@ -191,7 +192,8 @@ def library(self):

@library.setter
def library(self, val):
assert 0 <= val <= 6
if not 0 <= val <= 6:
raise ValueError('Library must be a value within 0-6!')
self._write_u8(_DRV2605_REG_LIBRARY, val)

def set_waveform(self, effect_id, slot=0):
Expand All @@ -200,8 +202,10 @@ def set_waveform(self, effect_id, slot=0):
datasheet for a complete table of effect ID values and the associated
waveform / effect.
"""
assert 0 <= effect_id <= 123
assert 0 <= slot <= 6
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!')
self._write_u8(_DRV2605_REG_WAVESEQ1 + slot, effect_id)

# pylint: disable=invalid-name
Expand Down