Skip to content

Commit ab70daa

Browse files
authored
Make "realtime_value" a property, improve docstring
1 parent 684ef87 commit ab70daa

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

adafruit_drv2605.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,33 @@ def sequence(self) -> "_DRV2605_Sequence":
208208
"""
209209
return self._sequence
210210

211-
def set_realtime_value(self, val: int) -> None:
212-
"""Set the output value used for Real-Time Playback. By default, the device
213-
interprets the value as SIGNED (2s complement), and its effect depends on
214-
other operating parameters. Consult the datasheet for more information!
211+
@property
212+
def realtime_value(self) -> int:
213+
"""The output value used in Real-Time Playback mode. When the device is
214+
switched to ``MODE_REALTIME``, the motor is driven continuously with an
215+
amplitude/direction determined by this value.
216+
217+
By default, the device interprets it as SIGNED (2s complement), and its exact
218+
effect depends on other operating parameters.
219+
220+
See the datasheet for more information!
221+
222+
E.g.:
223+
224+
.. code-block:: python
225+
226+
# Configure the output amplitude to 50%
227+
drv.realtime_value = 64
228+
229+
# Buzz the motor briefly
230+
drv.mode = adafruit_drv2605.MODE_REALTIME
231+
time.sleep(0.25)
232+
drv.mode = adafruit_drv2605.MODE_INTTRIG
215233
"""
234+
return self._read_u8(_DRV2605_REG_RTPIN)
235+
236+
@realtime_value.setter
237+
def realtime_value(self, val: int) -> None:
216238
if not 0 <= val <= 255:
217239
raise ValueError("Real-Time Playback value must be a value within 0-255!")
218240
self._write_u8(_DRV2605_REG_RTPIN, val)

0 commit comments

Comments
 (0)