embassy-drv2605l
Driver for the DRV2605L haptic motor controller with both blocking and async I2C support.
Features
- Dual mode: Both blocking and async I2C implementations
- Motor support: ERM and LRA haptic motors
- 123 built-in effects: From clicks to buzzes to complex transitions
- Custom patterns: Real-time playback mode for precise control
- Waveform sequencing: Chain up to 8 effects
no_stdcompatible: For embedded systems- Optional
defmt: Debug support when needed
Installation
[]
# For async (default)
= "0.1.0"
# For blocking only
= { = "0.1.0", = false, = ["blocking"] }
# For both blocking and async
= { = "0.1.0", = ["blocking", "async"] }
Quick Start
Async Mode
use ;
let mut haptic = new;
haptic.init.await?;
// Play a click
haptic.play_waveform.await?;
Blocking Mode
use ;
let mut haptic = new;
haptic.init?;
// Play a click
haptic.play_waveform?;
Common Usage Patterns
Motor Configuration
use ;
let mut haptic = new;
haptic.set_motor_type.await?; // Default is LRA
haptic.init.await?;
Waveform Sequences
// Chain multiple effects
haptic.clear_waveform_sequence.await?;
haptic.set_waveform.await?;
haptic.set_waveform.await?; // 10ms pause
haptic.set_waveform.await?;
haptic.set_waveform.await?; // End marker
haptic.go.await?;
Real-Time Playback
// Custom intensity control
haptic.set_mode.await?;
haptic.set_rtp_input.await?; // 50% intensity
haptic.set_rtp_input.await?; // Full intensity
haptic.set_rtp_input.await?; // Stop
Popular Effects
- Clicks:
StrongClick100,SharpClick60,SoftBump100 - Alerts:
DoubleClick100,TripleClick100,Alert750ms - Transitions:
TransitionRampUpShortSmooth1_100 - Buzzes:
StrongBuzz100,SmoothHum1_50
123 effects total - see Effect enum for complete list.
Timing in Sequences
Insert delays between effects: 0x80 | (delay_ms / 10)
haptic.set_waveform.await?; // 10ms
haptic.set_waveform.await?; // 100ms
haptic.set_waveform.await?; // 1270ms (max)
Hardware
I2C Connection (Address: 0x5A)
- VIN → 3.3V
- GND → Ground
- SDA → I2C Data
- SCL → I2C Clock
- EN → High (or leave - has pullup)
Motor Types
- LRA: Precise feedback, low power, best for subtle patterns
- ERM: Strong vibration, simple on/off control
License
MIT OR Apache-2.0