Adafruit DRV2605 Library
Adafruit_DRV2605.h
Go to the documentation of this file.
1 
20 /**************************************************************************/
21 
22 #ifndef _ADAFRUIT_DRV2605_H
23 #define _ADAFRUIT_DRV2605_H
24 
25 #if ARDUINO >= 100
26 #include "Arduino.h"
27 #else
28 #include "WProgram.h"
29 #endif
30 
31 #include <Adafruit_I2CDevice.h>
32 
33 #define DRV2605_ADDR 0x5A
34 
35 #define DRV2605_REG_STATUS 0x00
36 #define DRV2605_REG_MODE 0x01
37 #define DRV2605_MODE_INTTRIG 0x00
38 #define DRV2605_MODE_EXTTRIGEDGE 0x01
39 #define DRV2605_MODE_EXTTRIGLVL 0x02
40 #define DRV2605_MODE_PWMANALOG 0x03
41 #define DRV2605_MODE_AUDIOVIBE 0x04
42 #define DRV2605_MODE_REALTIME 0x05
43 #define DRV2605_MODE_DIAGNOS 0x06
44 #define DRV2605_MODE_AUTOCAL 0x07
45 
46 #define DRV2605_REG_RTPIN 0x02
47 #define DRV2605_REG_LIBRARY 0x03
48 #define DRV2605_REG_WAVESEQ1 0x04
49 #define DRV2605_REG_WAVESEQ2 0x05
50 #define DRV2605_REG_WAVESEQ3 0x06
51 #define DRV2605_REG_WAVESEQ4 0x07
52 #define DRV2605_REG_WAVESEQ5 0x08
53 #define DRV2605_REG_WAVESEQ6 0x09
54 #define DRV2605_REG_WAVESEQ7 0x0A
55 #define DRV2605_REG_WAVESEQ8 0x0B
56 
57 #define DRV2605_REG_GO 0x0C
58 #define DRV2605_REG_OVERDRIVE 0x0D
59 #define DRV2605_REG_SUSTAINPOS 0x0E
60 #define DRV2605_REG_SUSTAINNEG 0x0F
61 #define DRV2605_REG_BREAK 0x10
62 #define DRV2605_REG_AUDIOCTRL 0x11
63 #define DRV2605_REG_AUDIOLVL \
64  0x12
65 #define DRV2605_REG_AUDIOMAX \
66  0x13
67 #define DRV2605_REG_AUDIOOUTMIN \
68  0x14
69 #define DRV2605_REG_AUDIOOUTMAX \
70  0x15
71 #define DRV2605_REG_RATEDV 0x16
72 #define DRV2605_REG_CLAMPV 0x17
73 #define DRV2605_REG_AUTOCALCOMP \
74  0x18
75 #define DRV2605_REG_AUTOCALEMP \
76  0x19
77 #define DRV2605_REG_FEEDBACK 0x1A
78 #define DRV2605_REG_CONTROL1 0x1B
79 #define DRV2605_REG_CONTROL2 0x1C
80 #define DRV2605_REG_CONTROL3 0x1D
81 #define DRV2605_REG_CONTROL4 0x1E
82 #define DRV2605_REG_VBAT 0x21
83 #define DRV2605_REG_LRARESON 0x22
84 
85 /**************************************************************************/
89 /**************************************************************************/
91 public:
92  Adafruit_DRV2605(void);
93  bool begin(TwoWire *theWire = &Wire);
94 
95  bool init();
96  void writeRegister8(uint8_t reg, uint8_t val);
97  uint8_t readRegister8(uint8_t reg);
98  void setWaveform(uint8_t slot, uint8_t w);
99  void selectLibrary(uint8_t lib);
100  void go(void);
101  void stop(void);
102  void setMode(uint8_t mode);
103  void setRealtimeValue(uint8_t rtp);
104  // Select ERM (Eccentric Rotating Mass) or LRA (Linear Resonant Actuator)
105  // vibration motor The default is ERM, which is more common
106  void useERM();
107  void useLRA();
108 
109 private:
110  Adafruit_I2CDevice *i2c_dev = NULL;
111 };
112 
113 #endif
void selectLibrary(uint8_t lib)
Select the waveform library to use.
Definition: Adafruit_DRV2605.cpp:129
bool init()
Setup the HW.
Definition: Adafruit_DRV2605.cpp:73
void writeRegister8(uint8_t reg, uint8_t val)
Write an 8-bit register.
Definition: Adafruit_DRV2605.cpp:198
void setMode(uint8_t mode)
Set the device mode.
Definition: Adafruit_DRV2605.cpp:163
void setWaveform(uint8_t slot, uint8_t w)
Select the haptic waveform to use.
Definition: Adafruit_DRV2605.cpp:116
void useERM()
Use ERM (Eccentric Rotating Mass) mode.
Definition: Adafruit_DRV2605.cpp:208
void go(void)
Start playback of the waveforms (start moving!).
Definition: Adafruit_DRV2605.cpp:138
Adafruit_DRV2605(void)
Instantiates a new DRV2605 class. I2C, no address adjustments or pins.
Definition: Adafruit_DRV2605.cpp:47
uint8_t readRegister8(uint8_t reg)
Read an 8-bit register.
Definition: Adafruit_DRV2605.cpp:185
void useLRA()
Use LRA (Linear Resonance Actuator) mode.
Definition: Adafruit_DRV2605.cpp:218
bool begin(TwoWire *theWire=&Wire)
Setup HW using a specified Wire.
Definition: Adafruit_DRV2605.cpp:60
void stop(void)
Stop playback.
Definition: Adafruit_DRV2605.cpp:145
void setRealtimeValue(uint8_t rtp)
Set the realtime value when in RTP mode, used to directly drive the haptic motor. ...
Definition: Adafruit_DRV2605.cpp:174
The DRV2605 driver class.
Definition: Adafruit_DRV2605.h:90