|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
AW86224/86225 Haptic Driver Class. More...
#include <HapticDriver_AW86224.hpp>
Public Types | |
| enum class | PlayMode : uint8_t { STANDBY = 0 , RAM = 1 , RAM_LOOP = 2 , CONT = 3 , RTP = 4 } |
| Playback mode enumeration. More... | |
| enum class | SramSize : uint8_t { SRAM_1K = 0 , SRAM_2K = 1 , SRAM_3K = 2 } |
| SRAM size selection. More... | |
| enum class | ChipID : uint8_t { AW86223 = 1 , AW86224 = 2 , AW86225 = 3 , AW86214 = 4 } |
| Chip ID enumeration. More... | |
| enum class | PwmMode : uint8_t { PWM_48K = 0 , PWM_24K = 1 , PWM_12K = 2 } |
| PWM mode selection. More... | |
Public Member Functions | |
| HapticDriver_AW86224 () | |
| Default constructor. | |
| void | setPins (uint8_t resetPin, uint8_t intPin) |
| setPins | |
| void | end () override |
| Deinitialize the haptic driver and release resources. | |
| bool | isReady () const override |
| Check if the driver is initialized and ready. | |
| const char * | getChipName () const override |
| Get the chip name. | |
| bool | run () override |
| Start haptic playback. | |
| bool | stop () override |
| Stop haptic playback immediately. | |
| bool | isPlaying () const override |
| Check if haptic is currently playing. | |
| HapticStatus | getStatus () const override |
| Get current playback status. | |
| bool | setGain (uint8_t gain) override |
| Set the gain/amplitude (0x00 to 0xFF). | |
| uint8_t | getGain () const override |
| Get the current gain value. | |
| bool | playEffect (HapticEffectId effect) override |
| Play a haptic effect. | |
| bool | playEffectAsync (HapticEffectId effect) override |
| Play a haptic effect (non-blocking). | |
| void | continuousVibration (uint32_t duration_ms, bool blocking=true) override |
| Play a continuous vibration for specified duration. | |
| void | vibrationUpdate () override |
| Update vibration state (for non-blocking mode). | |
| bool | setSequence (uint8_t slot, HapticEffectId effect) override |
| Set a waveform in the sequence. | |
| bool | clearSequence () override |
| Clear the waveform sequence. | |
| bool | playSequence () override |
| Play the waveform sequence. | |
| uint8_t | getChipID () const override |
| Get the chip ID. | |
| HapticCapabilities | getCapabilities () const override |
| Get device capabilities. | |
| bool | calibrate () override |
| Perform auto-calibration. | |
| bool | needsCalibration () const override |
| Check if calibration is needed. | |
| uint32_t | getF0 () const override |
| Get the measured resonant frequency (F0). | |
| uint32_t | getVbat () override |
| Get the battery voltage. | |
| bool | setMode (HapticMode mode) override |
| Set the operating mode. | |
| HapticMode | getMode () const override |
| Get the current operating mode. | |
| HapticActuatorType | getActuatorType () const override |
| Get the actuator type. | |
| bool | setActuatorType (HapticActuatorType type) override |
| Set the actuator type. | |
| bool | setRealtimeValue (uint8_t value) override |
| Set RTP (real-time playback) value. | |
| void | softReset () |
| Perform soft reset. | |
| void | shortVibration (uint8_t index, uint8_t gain=0x80, uint8_t loop=1) |
| Play a short vibration effect. | |
| void | longVibration (uint8_t index, uint8_t gain=0x80, uint32_t duration_ms=1000, bool blocking=true) |
| Play a long continuous vibration effect. | |
| void | stopVibration () |
| Stop any ongoing vibration. | |
| void | setWaveSeq (uint8_t wav, uint8_t seq) |
| Update vibration state (for non-blocking mode) | |
| void | setWaveLoop (uint8_t wav, uint8_t loop) |
| Set waveform loop count. | |
| void | setPlayMode (PlayMode mode) |
| Set playback mode. | |
| void | setTrimLRA (uint8_t val) |
| Set LRA frequency trim value. | |
| void | setRtpData (uint8_t *data, uint32_t len) |
| Set RTP waveform data. | |
| bool | playRtp (const uint8_t *data, uint32_t len, uint8_t gain=0x80) |
| Play RTP (Real-Time Playback) waveform. | |
| bool | loadRamData (const uint8_t *data, uint32_t len) |
| Load RAM waveform data. | |
| uint8_t | getRamNum () const |
| Get number of loaded waveforms. | |
| bool | isRamInit () const |
| Check if RAM is initialized. | |
| uint32_t | getVbatValue () const |
| Get current voltage reading. | |
| PlayMode | getPlayMode () const |
| Get current play mode. | |
| int8_t | getF0CaliData () const |
| Get F0 calibration data. | |
| uint32_t | getLraValue () const |
| Get LRA resistance. | |
| void | setF0Pre (uint32_t val) |
| Set expected F0 (resonant frequency) | |
| uint32_t | getF0Pre () const |
| void | setLraVrms (uint32_t val) |
| Set LRA rated voltage. | |
| uint32_t | getLraVrms () const |
| void | setContBrkTime (uint8_t val) |
| Set continuous mode break time. | |
| uint8_t | getContBrkTime () const |
| void | setContBrkGain (uint8_t val) |
| Set continuous mode break gain. | |
| uint8_t | getContBrkGain () const |
| void | setContDrv1Lvl (uint8_t val) |
| Set continuous mode drive level 1. | |
| uint8_t | getContDrv1Lvl () const |
| void | setContDrv1Time (uint8_t val) |
| Set continuous mode drive time 1. | |
| uint8_t | getContDrv1Time () const |
| void | setContDrv2Time (uint8_t val) |
| Set continuous mode drive time 2. | |
| uint8_t | getContDrv2Time () const |
| void | setContTrackMargin (uint8_t val) |
| Set continuous mode track margin. | |
| uint8_t | getContTrackMargin () const |
| void | setD2sGain (uint8_t val) |
| Set D2S gain (digital to simulation gain) | |
| uint8_t | getD2sGain () const |
| void | setPwmcfg4Prtime (uint8_t val) |
| Set protection time. | |
| uint8_t | getPwmcfg4Prtime () const |
| void | setPwmcfg3Prlvl (uint8_t val) |
| Set protection level. | |
| uint8_t | getPwmcfg3Prlvl () const |
| void | setAutoBrkEnabled (bool val) |
| Enable/disable auto break. | |
| bool | getAutoBrkEnabled () const |
| void | setF0CaliPercent (uint8_t val) |
| Set F0 calibration tolerance percentage. | |
| uint8_t | getF0CaliPercent () const |
| bool | isVibrating () const |
| Check if vibration is currently active (alias for isPlaying) | |
Public Member Functions inherited from HapticBase | |
| virtual | ~HapticBase ()=default |
| virtual void | emergencyStop () |
| Emergency stop - stops all vibration immediately. | |
Public Member Functions inherited from I2CDeviceWithHal | |
| bool | begin (SensorCommCustom::CustomCallback cb, SensorCommCustomHal::CustomHalCallback hal_cb, uint8_t addr) |
| Initialize the sensor using custom callback interface. | |
Public Member Functions inherited from DeviceBeginCommon | |
| virtual | ~DeviceBeginCommon () |
| uint8_t | getAddress () const |
| uint8_t | getInterface () const |
Public Member Functions inherited from SensorCommWrapper | |
| SensorCommWrapper ()=default | |
| int | readReg (uint8_t reg) const |
| int | readRegBuff (uint8_t reg, uint8_t *buf, size_t len) const |
| int | readBuff (uint8_t *buf, size_t len) const |
| int | writeReg (uint8_t reg, uint8_t val) |
| int | writeRegBuff (uint8_t reg, uint8_t *buf, size_t len) |
| int | writeBuff (uint8_t *buf, size_t len) |
| int | writeThenRead (const uint8_t *write_buffer, size_t write_len, uint8_t *read_buffer, size_t read_len) |
| bool | setRegBit (uint8_t reg, uint8_t bit) |
| bool | clrRegBit (uint8_t reg, uint8_t bit) |
| bool | getRegBit (uint8_t reg, uint8_t bit) |
| int | updateBits (uint8_t reg, uint8_t mask, uint8_t value_shifted) |
| void | setAddress (uint8_t address) |
| void | setAck (bool enable) |
Public Member Functions inherited from SensorCommInterface | |
| virtual | ~SensorCommInterface ()=default |
Additional Inherited Members | |
Protected Member Functions inherited from HapticBase | |
| HapticBase (const char *name) | |
| Constructor for derived classes. | |
| void | setReady (bool ready) |
| Set ready state. | |
Protected Member Functions inherited from I2CDeviceWithHal | |
| bool | ensureValid () const override |
| Ensure the communication interface is valid. | |
Protected Member Functions inherited from DeviceBeginCommon | |
| DeviceBeginCommon ()=default | |
| virtual SensorCommBase * | getComm () const override |
| virtual void | beforeBegin () |
| virtual void | afterCommReady () |
| virtual void | onBeginFail () |
| bool | fail () |
| void | clearCommState () |
| template<typename CreateComm > | |
| bool | beginLifecycle (uint8_t addr, uint8_t iface, uint8_t initParam, CreateComm createComm) |
Protected Attributes inherited from HapticBase | |
| const char * | _chipName |
| bool | _isReady |
Protected Attributes inherited from DeviceBeginCommon | |
| std::unique_ptr< SensorCommBase > | comm |
| std::unique_ptr< SensorHal > | hal |
| std::unique_ptr< SensorCommStatic > | staticComm |
| uint8_t | _addr = 0 |
| uint8_t | _iface = COMM_CUSTOM |
AW86224/86225 Haptic Driver Class.
This class provides a complete interface for controlling the AW86224/86225 haptic motor driver. It inherits from HapticBase and I2CDeviceWithHal to provide standardized haptic control and I2C communication.
Definition at line 69 of file HapticDriver_AW86224.hpp.
|
strong |
Chip ID enumeration.
Identifies the connected AWinic haptic chip model.
| Enumerator | |
|---|---|
| AW86223 | AW86223 chip. |
| AW86224 | AW86224 chip. |
| AW86225 | AW86225 chip. |
| AW86214 | AW86214 chip. |
Definition at line 102 of file HapticDriver_AW86224.hpp.
|
strong |
Playback mode enumeration.
Defines the operating mode of the haptic driver.
Definition at line 78 of file HapticDriver_AW86224.hpp.
|
strong |
PWM mode selection.
Defines the PWM sampling rate for waveform playback.
| Enumerator | |
|---|---|
| PWM_48K | 48kHz PWM rate |
| PWM_24K | 24kHz PWM rate |
| PWM_12K | 12kHz PWM rate (default) |
Definition at line 114 of file HapticDriver_AW86224.hpp.
|
strong |
SRAM size selection.
Configures the internal SRAM size for waveform storage.
| Enumerator | |
|---|---|
| SRAM_1K | 1KB SRAM |
| SRAM_2K | 2KB SRAM |
| SRAM_3K | 3KB SRAM |
Definition at line 91 of file HapticDriver_AW86224.hpp.
| HapticDriver_AW86224::HapticDriver_AW86224 | ( | ) |
Default constructor.
Initializes the driver with default parameters. Call begin() before use.
Definition at line 40 of file HapticDriver_AW86224.cpp.
|
overridevirtual |
Perform auto-calibration.
Reimplemented from HapticBase.
Definition at line 204 of file HapticDriver_AW86224.cpp.
References HapticBase::_isReady.
|
overridevirtual |
Clear the waveform sequence.
Reimplemented from HapticBase.
Definition at line 189 of file HapticDriver_AW86224.cpp.
References i, and setWaveSeq().
Referenced by testSetSequence().
|
overridevirtual |
Play a continuous vibration for specified duration.
Default implementation uses playEffect() in a loop. Subclasses should override for optimized continuous mode.
| duration_ms | Duration in milliseconds. |
| blocking | If true, blocks until vibration completes. |
Reimplemented from HapticBase.
Definition at line 164 of file HapticDriver_AW86224.cpp.
References longVibration().
Referenced by testAutoDemo(), testContinuousVibration(), and testStop().
|
overridevirtual |
Deinitialize the haptic driver and release resources.
Reimplemented from HapticBase.
Definition at line 71 of file HapticDriver_AW86224.cpp.
References HapticBase::setReady(), and stop().
|
overridevirtual |
Get the actuator type.
Implements HapticBase.
Definition at line 860 of file HapticDriver_AW86224.cpp.
References LRA.
Referenced by testInit().
|
inline |
Definition at line 644 of file HapticDriver_AW86224.hpp.
|
overridevirtual |
Get device capabilities.
Implements HapticBase.
Definition at line 99 of file HapticDriver_AW86224.cpp.
References HapticCapabilities::hasAutoCalibration, HapticCapabilities::hasBreakEffect, HapticCapabilities::hasContinuousMode, HapticCapabilities::hasF0Calibration, HapticCapabilities::hasOverdrive, HapticCapabilities::hasRTP, HapticCapabilities::hasSequence, HapticCapabilities::hasVbatCompensation, HapticCapabilities::maxDurationMs, HapticCapabilities::maxEffectCount, and HapticCapabilities::maxSequenceLength.
Referenced by testCapabilities().
|
overridevirtual |
Get the chip ID.
Implements HapticBase.
Definition at line 924 of file HapticDriver_AW86224.cpp.
Referenced by testInit().
|
overridevirtual |
Get the chip name.
Implements HapticBase.
Definition at line 82 of file HapticDriver_AW86224.cpp.
References AW86214, AW86223, and AW86224.
Referenced by testInit().
|
inline |
Definition at line 540 of file HapticDriver_AW86224.hpp.
|
inline |
Definition at line 527 of file HapticDriver_AW86224.hpp.
|
inline |
Definition at line 553 of file HapticDriver_AW86224.hpp.
|
inline |
Definition at line 566 of file HapticDriver_AW86224.hpp.
|
inline |
Definition at line 579 of file HapticDriver_AW86224.hpp.
|
inline |
Definition at line 592 of file HapticDriver_AW86224.hpp.
|
inline |
Definition at line 605 of file HapticDriver_AW86224.hpp.
|
overridevirtual |
Get the measured resonant frequency (F0).
Reimplemented from HapticBase.
Definition at line 913 of file HapticDriver_AW86224.cpp.
Referenced by loop(), and testInit().
|
inline |
Get F0 calibration data.
Definition at line 475 of file HapticDriver_AW86224.hpp.
Referenced by testInit().
|
inline |
Definition at line 657 of file HapticDriver_AW86224.hpp.
|
inline |
Definition at line 501 of file HapticDriver_AW86224.hpp.
|
overridevirtual |
Get the current gain value.
Implements HapticBase.
Definition at line 131 of file HapticDriver_AW86224.cpp.
|
inline |
|
inline |
Definition at line 514 of file HapticDriver_AW86224.hpp.
|
overridevirtual |
Get the current operating mode.
Reimplemented from HapticBase.
Definition at line 883 of file HapticDriver_AW86224.cpp.
References AUTO_CALIBRATE, CONT, INTERNAL_TRIGGER, REAL_TIME_PLAYBACK, RTP, STANDBY, and STANDBY.
|
inline |
Get current play mode.
Definition at line 466 of file HapticDriver_AW86224.hpp.
|
inline |
Definition at line 631 of file HapticDriver_AW86224.hpp.
|
inline |
Definition at line 618 of file HapticDriver_AW86224.hpp.
|
inline |
Get number of loaded waveforms.
Definition at line 439 of file HapticDriver_AW86224.hpp.
Referenced by loop(), testAutoDemo(), testInit(), testPlayEffectAll(), and testWaveformSwitching().
|
overridevirtual |
Get current playback status.
Implements HapticBase.
Definition at line 116 of file HapticDriver_AW86224.cpp.
References HapticBase::_isReady, ERROR, IDLE, isPlaying(), PLAYING, STANDBY, and STANDBY.
Referenced by testStatus().
|
overridevirtual |
Get the battery voltage.
Reimplemented from HapticBase.
Definition at line 907 of file HapticDriver_AW86224.cpp.
Referenced by loop(), and testInit().
|
inline |
Get current voltage reading.
Definition at line 457 of file HapticDriver_AW86224.hpp.
|
overridevirtual |
Check if haptic is currently playing.
Implements HapticBase.
Definition at line 124 of file HapticDriver_AW86224.cpp.
References STANDBY.
Referenced by getStatus(), isVibrating(), longVibration(), loop(), playEffectAsync(), shortVibration(), testAutoDemo(), testStop(), testWaveformSwitching(), and vibrationUpdate().
|
inline |
Check if RAM is initialized.
Definition at line 448 of file HapticDriver_AW86224.hpp.
|
overridevirtual |
Check if the driver is initialized and ready.
Implements HapticBase.
Definition at line 77 of file HapticDriver_AW86224.cpp.
References HapticBase::_isReady.
|
inline |
Check if vibration is currently active (alias for isPlaying)
Definition at line 666 of file HapticDriver_AW86224.hpp.
References isPlaying().
| bool HapticDriver_AW86224::loadRamData | ( | const uint8_t * | data, |
| uint32_t | len | ||
| ) |
Load RAM waveform data.
Loads pre-compiled waveform data into the haptic chip's RAM.
| [in] | data | Pointer to RAM data array |
| [in] | len | Length of RAM data |
Definition at line 767 of file HapticDriver_AW86224.cpp.
References DeviceBeginCommon::hal, i, and SensorCommWrapper::writeRegBuff().
| void HapticDriver_AW86224::longVibration | ( | uint8_t | index, |
| uint8_t | gain = 0x80, |
||
| uint32_t | duration_ms = 1000, |
||
| bool | blocking = true |
||
| ) |
Play a long continuous vibration effect.
Plays a continuous vibration effect for the specified duration. Supports both blocking and non-blocking modes.
| [in] | index | Waveform index (1-4) |
| [in] | gain | Vibration intensity (0x00-0xFF) |
| [in] | duration_ms | Duration in milliseconds |
| [in] | blocking | true = wait for completion (blocking), false = return immediately (non-blocking) |
Definition at line 570 of file HapticDriver_AW86224.cpp.
References DeviceBeginCommon::hal, isPlaying(), RAM_LOOP, run(), setGain(), setTrimLRA(), softReset(), and stop().
Referenced by continuousVibration(), loop(), testAutoDemo(), testLongVibrationBlocking(), testLongVibrationNonBlocking(), and testWaveformSwitching().
|
overridevirtual |
Check if calibration is needed.
Reimplemented from HapticBase.
Definition at line 212 of file HapticDriver_AW86224.cpp.
|
overridevirtual |
Play a haptic effect.
This is a blocking call - it returns only after the effect completes. For chips that don't support blocking, use playEffectAsync() instead.
| effect | Effect ID to play (chip-specific mapping). |
Implements HapticBase.
Definition at line 136 of file HapticDriver_AW86224.cpp.
References shortVibration().
Referenced by testAutoDemo(), testPlayEffect(), and testPlayEffectAll().
|
overridevirtual |
Play a haptic effect (non-blocking).
Returns immediately; use isPlaying() or vibrationUpdate() to check status.
| effect | Effect ID to play. |
Reimplemented from HapticBase.
Definition at line 143 of file HapticDriver_AW86224.cpp.
References DeviceBeginCommon::hal, isPlaying(), RAM, run(), setGain(), setTrimLRA(), setWaveLoop(), setWaveSeq(), softReset(), and stop().
| bool HapticDriver_AW86224::playRtp | ( | const uint8_t * | data, |
| uint32_t | len, | ||
| uint8_t | gain = 0x80 |
||
| ) |
Play RTP (Real-Time Playback) waveform.
Plays a custom waveform in RTP mode.
| [in] | data | Waveform data buffer |
| [in] | len | Data length in bytes |
| [in] | gain | Playback gain (0x00-0xFF) |
Definition at line 653 of file HapticDriver_AW86224.cpp.
References DeviceBeginCommon::hal, PWM_24K, RTP, run(), setGain(), setTrimLRA(), SensorCommWrapper::updateBits(), SensorCommWrapper::writeReg(), and SensorCommWrapper::writeRegBuff().
|
overridevirtual |
Play the waveform sequence.
Reimplemented from HapticBase.
Definition at line 197 of file HapticDriver_AW86224.cpp.
Referenced by testSetSequence().
|
overridevirtual |
Start haptic playback.
Implements HapticBase.
Definition at line 527 of file HapticDriver_AW86224.cpp.
References DeviceBeginCommon::hal, and SensorCommWrapper::writeReg().
Referenced by longVibration(), playEffectAsync(), playRtp(), playSequence(), shortVibration(), and vibrationUpdate().
|
overridevirtual |
Set the actuator type.
| type | Actuator type to set (ERM or LRA). |
Implements HapticBase.
Definition at line 854 of file HapticDriver_AW86224.cpp.
|
inline |
Enable/disable auto break.
| [in] | val | true = enabled, false = disabled |
Definition at line 640 of file HapticDriver_AW86224.hpp.
|
inline |
Set continuous mode break gain.
| [in] | val | Break gain value (0x00-0xFF) |
Definition at line 536 of file HapticDriver_AW86224.hpp.
|
inline |
Set continuous mode break time.
| [in] | val | Break time value (0x00-0xFF) |
Definition at line 523 of file HapticDriver_AW86224.hpp.
|
inline |
Set continuous mode drive level 1.
| [in] | val | Drive level (0x00-0x7F) |
Definition at line 549 of file HapticDriver_AW86224.hpp.
|
inline |
Set continuous mode drive time 1.
| [in] | val | Drive time value (0x00-0xFF) |
Definition at line 562 of file HapticDriver_AW86224.hpp.
|
inline |
Set continuous mode drive time 2.
| [in] | val | Drive time value (0x00-0xFF) |
Definition at line 575 of file HapticDriver_AW86224.hpp.
|
inline |
Set continuous mode track margin.
| [in] | val | Margin value (0x00-0xFF) |
Definition at line 588 of file HapticDriver_AW86224.hpp.
|
inline |
Set D2S gain (digital to simulation gain)
| [in] | val | Gain value (0x00-0x07) |
Definition at line 601 of file HapticDriver_AW86224.hpp.
|
inline |
Set F0 calibration tolerance percentage.
| [in] | val | Percentage (default: 7) |
Definition at line 653 of file HapticDriver_AW86224.hpp.
|
inline |
Set expected F0 (resonant frequency)
| [in] | val | F0 in Hz (default: 1700) |
Definition at line 497 of file HapticDriver_AW86224.hpp.
|
overridevirtual |
Set the gain/amplitude (0x00 to 0xFF).
| gain | Gain value. |
Implements HapticBase.
Definition at line 520 of file HapticDriver_AW86224.cpp.
References SensorCommWrapper::writeReg().
Referenced by longVibration(), playEffectAsync(), playRtp(), setRealtimeValue(), shortVibration(), and testContinuousVibration().
|
inline |
Set LRA rated voltage.
| [in] | val | Voltage in mV (default: 1000) |
Definition at line 510 of file HapticDriver_AW86224.hpp.
|
overridevirtual |
Set the operating mode.
| mode | Mode to set. |
Reimplemented from HapticBase.
Definition at line 865 of file HapticDriver_AW86224.cpp.
References INTERNAL_TRIGGER, RAM, REAL_TIME_PLAYBACK, RTP, and STANDBY.
| void HapticDriver_AW86224::setPins | ( | uint8_t | resetPin, |
| uint8_t | intPin | ||
| ) |
setPins
| [in] | resetPin | The GPIO pin number for the reset pin. |
| [in] | intPin | The GPIO pin number for the interrupt pin. |
| None |
Definition at line 65 of file HapticDriver_AW86224.cpp.
| void HapticDriver_AW86224::setPlayMode | ( | PlayMode | mode | ) |
Set playback mode.
| [in] | mode | Playback mode (see PlayMode enum) |
Definition at line 515 of file HapticDriver_AW86224.cpp.
|
inline |
Set protection level.
| [in] | val | Level value |
Definition at line 627 of file HapticDriver_AW86224.hpp.
|
inline |
Set protection time.
| [in] | val | Time value |
Definition at line 614 of file HapticDriver_AW86224.hpp.
|
overridevirtual |
Set RTP (real-time playback) value.
Only meaningful when in REAL_TIME_PLAYBACK mode.
| value | RTP drive value (0x00 to 0xFF). |
Reimplemented from HapticBase.
Definition at line 898 of file HapticDriver_AW86224.cpp.
| void HapticDriver_AW86224::setRtpData | ( | uint8_t * | data, |
| uint32_t | len | ||
| ) |
Set RTP waveform data.
Loads waveform data for RTP mode playback.
| [in] | data | Pointer to waveform data buffer |
| [in] | len | Length of data in bytes |
Definition at line 648 of file HapticDriver_AW86224.cpp.
References SensorCommWrapper::writeRegBuff().
|
overridevirtual |
Set a waveform in the sequence.
| slot | Sequence slot index (0 to maxSequenceLength-1). |
| effect | Effect ID to play at this slot. |
Reimplemented from HapticBase.
Definition at line 182 of file HapticDriver_AW86224.cpp.
References setWaveSeq().
Referenced by testSetSequence().
| void HapticDriver_AW86224::setTrimLRA | ( | uint8_t | val | ) |
Set LRA frequency trim value.
Used after F0 calibration to optimize vibration.
| [in] | val | Trim value from calibration (typically 0x00-0x3F) |
Definition at line 417 of file HapticDriver_AW86224.cpp.
References SensorCommWrapper::updateBits().
Referenced by longVibration(), playEffectAsync(), playRtp(), and shortVibration().
| void HapticDriver_AW86224::setWaveLoop | ( | uint8_t | wav, |
| uint8_t | loop | ||
| ) |
Set waveform loop count.
Configures how many times a waveform repeats before advancing.
| [in] | wav | Wave slot (0-7) |
| [in] | loop | Loop count (0-15, where 15 = infinite) |
Definition at line 614 of file HapticDriver_AW86224.cpp.
References loop(), and SensorCommWrapper::updateBits().
Referenced by playEffectAsync(), and shortVibration().
| void HapticDriver_AW86224::setWaveSeq | ( | uint8_t | wav, |
| uint8_t | seq | ||
| ) |
Update vibration state (for non-blocking mode)
Must be called regularly when using non-blocking vibration modes. This function:
Set waveform sequence
Configures which waveform is played for each sequencer slot.
| [in] | wav | Wave slot (0-7) |
| [in] | seq | Waveform index to play (0-15) |
Definition at line 609 of file HapticDriver_AW86224.cpp.
References SensorCommWrapper::writeReg().
Referenced by clearSequence(), playEffectAsync(), setSequence(), and shortVibration().
| void HapticDriver_AW86224::shortVibration | ( | uint8_t | index, |
| uint8_t | gain = 0x80, |
||
| uint8_t | loop = 1 |
||
| ) |
Play a short vibration effect.
Plays a short haptic effect using a RAM waveform with specified loop count. This is a blocking call that waits for the effect to complete.
| [in] | index | Waveform index (1-4, based on loaded RAM data) |
| [in] | gain | Vibration intensity (0x00-0xFF, default 0x80) |
| [in] | loop | Number of repetitions (1-16, default 1) |
Definition at line 544 of file HapticDriver_AW86224.cpp.
References DeviceBeginCommon::hal, isPlaying(), loop(), RAM, run(), setGain(), setTrimLRA(), setWaveLoop(), setWaveSeq(), softReset(), and stop().
Referenced by playEffect(), testAutoDemo(), testIntensitySweep(), testShortVibration(), testShortVibrationGain(), and testShortVibrationLoop().
| void HapticDriver_AW86224::softReset | ( | ) |
Perform soft reset.
Resets the chip to default state via software command. This clears any residual configuration from previous operations.
Definition at line 918 of file HapticDriver_AW86224.cpp.
References DeviceBeginCommon::hal, and SensorCommWrapper::writeReg().
Referenced by longVibration(), playEffectAsync(), and shortVibration().
|
overridevirtual |
Stop haptic playback immediately.
Implements HapticBase.
Definition at line 537 of file HapticDriver_AW86224.cpp.
Referenced by end(), longVibration(), playEffectAsync(), shortVibration(), stopVibration(), testAutoDemo(), testStop(), testWaveformSwitching(), and vibrationUpdate().
| void HapticDriver_AW86224::stopVibration | ( | ) |
Stop any ongoing vibration.
Immediately stops vibration and enters standby mode. Works for both blocking and non-blocking modes.
Definition at line 604 of file HapticDriver_AW86224.cpp.
References stop().
|
overridevirtual |
Update vibration state (for non-blocking mode).
Call this periodically in your main loop when using non-blocking vibration functions. Default implementation does nothing.
Reimplemented from HapticBase.
Definition at line 170 of file HapticDriver_AW86224.cpp.
References DeviceBeginCommon::hal, isPlaying(), run(), and stop().
Referenced by loop().