@@ -115,9 +115,7 @@ def __init__(self, i2c, address=_DRV2605_ADDR):
115
115
self ._write_u8 (_DRV2605_REG_BREAK , 0 )
116
116
self ._write_u8 (_DRV2605_REG_AUDIOMAX , 0x64 )
117
117
# Set ERM open-loop mode.
118
- # turn off N_ERM_LRA
119
- feedback = self ._read_u8 (_DRV2605_REG_FEEDBACK )
120
- self ._write_u8 (_DRV2605_REG_FEEDBACK , feedback & 0x7F )
118
+ self .use_ERM ()
121
119
# turn on ERM_OPEN_LOOP
122
120
control3 = self ._read_u8 (_DRV2605_REG_CONTROL3 )
123
121
self ._write_u8 (_DRV2605_REG_CONTROL3 , control3 | 0x20 )
@@ -140,8 +138,8 @@ def _write_u8(self, address, val):
140
138
self ._BUFFER [1 ] = val & 0xFF
141
139
i2c .write (self ._BUFFER , end = 2 )
142
140
143
- def start (self ):
144
- """Start vibrating the motor."""
141
+ def play (self ):
142
+ """Play back the select effect(s) on the motor."""
145
143
self ._write_u8 (_DRV2605_REG_GO , 1 )
146
144
147
145
def stop (self ):
@@ -152,7 +150,7 @@ def stop(self):
152
150
def mode (self ):
153
151
"""Get and set the mode of the chip. Should be a value of:
154
152
- MODE_INTTRIG: Internal triggering, vibrates as soon as you call
155
- start() and stops after calling stop (). Default mode.
153
+ play (). Default mode.
156
154
- MODE_EXTTRIGEDGE: External triggering, edge mode.
157
155
- MODE_EXTTRIGLVL: External triggering, level mode.
158
156
- MODE_PWMANALOG: PWM/analog input mode.
@@ -199,3 +197,13 @@ def set_waveform(self, effect_id, slot=0):
199
197
assert 0 <= effect_id <= 123
200
198
assert 0 <= slot <= 6
201
199
self ._write_u8 (_DRV2605_REG_WAVESEQ1 + slot , effect_id )
200
+
201
+ def use_ERM (self ):
202
+ """Use an eccentric rotating mass motor (the default)."""
203
+ feedback = self ._read_u8 (_DRV2605_REG_FEEDBACK )
204
+ self ._write_u8 (_DRV2605_REG_FEEDBACK , feedback & 0x7F )
205
+
206
+ def use_LRM (self ):
207
+ """Use a linear resonance actuator motor."""
208
+ feedback = self ._read_u8 (_DRV2605_REG_FEEDBACK )
209
+ self ._write_u8 (_DRV2605_REG_FEEDBACK , feedback | 0x80 )
0 commit comments