@@ -214,29 +214,36 @@ def realtime_value(self) -> int:
214
214
switched to ``MODE_REALTIME``, the motor is driven continuously with an
215
215
amplitude/direction determined by this value.
216
216
217
- By default, the device interprets it as SIGNED (2s complement), and its exact
218
- effect depends on other operating parameters.
217
+ By default, the device expects a SIGNED 8-bit integer, and its exact
218
+ effect depends on both the type of motor (ERM/LRA) and whether the device
219
+ is operating in open- or closed-loop (unidirectional/bidirectional) mode.
219
220
220
221
See the datasheet for more information!
221
222
222
223
E.g.:
223
224
224
225
.. code-block:: python
225
226
226
- # Configure the output amplitude to 50%
227
+ # Start real-time playback
228
+ drv.realtime_value = 0
229
+ drv.mode = adafruit_drv2605.MODE_REALTIME
230
+
231
+ # Buzz the motor briefly at 50% and 100% amplitude
227
232
drv.realtime_value = 64
233
+ time.sleep(0.5)
234
+ drv.realtime_value = 127
235
+ time.sleep(0.5)
228
236
229
- # Buzz the motor briefly
230
- drv.mode = adafruit_drv2605.MODE_REALTIME
231
- time.sleep(0.25)
237
+ # Stop real-time playback
238
+ drv.realtime_value = 0
232
239
drv.mode = adafruit_drv2605.MODE_INTTRIG
233
240
"""
234
241
return self ._read_u8 (_DRV2605_REG_RTPIN )
235
242
236
243
@realtime_value .setter
237
244
def realtime_value (self , val : int ) -> None :
238
- if not 0 <= val <= 255 :
239
- raise ValueError ("Real-Time Playback value must be a value within 0- 255!" )
245
+ if not - 127 <= val <= 255 :
246
+ raise ValueError ("Real-Time Playback value must be a value between -127 and 255!" )
240
247
self ._write_u8 (_DRV2605_REG_RTPIN , val )
241
248
242
249
def set_waveform (self , effect_id : int , slot : int = 0 ) -> None :
0 commit comments