An async and no_std rust library for the wide-bandwidth haptic driver IC DA7280/DA7281/DA7282 from Renesas.
- DA7280
- DA7281
- DA7282
- CHIP_REV verification
- Configuration with validation
- Setting (resonant) frequency
- Enable / disable playback
- Reading and clearing system events and diagnostics
- Driving an LRA in frequency track, wideband or custom waveform mode
- DRO mode
- Testing of PWM_MODE
- Uploading into the waveform memory and RTWM_MODE
- GPI configuration and ETWM_MODE
- Uploading a script (list of registers and values as exported by GUI)
debug- Enable debug logging with thedefmtcrate
use da728x::{DA728x, Variant};
use da728x::config::{ActuatorConfig, ActuatorType, DeviceConfig, OperationMode, DrivingMode};
// Setup I2C
// let i2c = ...
// let address = ...
let mut haptics = DA728x::new(i2c, address, Variant::DA7280)
.await
.unwrap();
// Values for the G1040003D LRA on the SparkFun board
let actuator_config = ActuatorConfig {
actuator_type: ActuatorType::LRA,
nominal_max_mV: 2_106,
absolute_max_mV: 2_260,
max_current_mA: 165,
impedance_mOhm: 13_800,
frequency_Hz: 170,
};
// DRO Mode, which means we can set the amplitude via set_override_value()
let device_config = DeviceConfig {
operation_mode: OperationMode::DRO_MODE,
driving_mode: DrivingMode::FREQUENCY_TRACK,
acceleration: false,
rapid_stop: false,
};
// Sets all registers as needed depending on the actuator type, operation mode and driving mode
haptics.configure(actuator_config, device_config).await.unwrap();
// Enables the Operation Mode (default is INACTIVE after configuration)
haptics.enable().await.unwrap();
loop {
info!("100%");
haptics.set_override_value(127).await.unwrap();
Timer::after_millis(800).await;
info!("33%");
haptics.set_override_value(42).await.unwrap();
Timer::after_millis(800).await;
info!("0%");
haptics.set_override_value(0).await.unwrap();
Timer::after_millis(800).await;
let status = haptics.get_status().await.unwrap();
info!("Haptics Status: {:?}", status);
}