-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Haptics.ino
58 lines (52 loc) · 1.09 KB
/
A_Haptics.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <Wire.h>
#include "Adafruit_DRV2605.h"
Adafruit_DRV2605 drv;
uint8_t effect;
unsigned long last_reading_hap = 0;
void hapOff() {
drv.setWaveform(0,0);
drv.go();
return;
}
void hapMedium() {
drv.setWaveform(0,119);
drv.go();
return;
}
void hapHigh() {
drv.setWaveform(0,118);
drv.go();
return;
}
void hapticSetup() {
// Serial.begin(9600);
// Serial.println("Adafruit DRV2605 Basic test");
if (! drv.begin()) {
Serial.println("Could not find DRV2605");
// while (1) delay(10);
}
drv.selectLibrary(1);
// I2C trigger by sending 'go' command
// default, internal trigger when sending GO command
drv.setMode(DRV2605_MODE_INTTRIG);
return;
}
void hapticLoop() {
int curr = millis();
if (curr - last_reading_hap >= HAPTIC_RATE_MS - UPDATE_RATE_CORRECTION) {
drv.go();
last_reading_hap = curr;
}
//// Serial.print("Effect #"); Serial.println(effect);
//
// // set the effect to play
// // play effect
// drv.setWaveform(1, 0); // end waveform
//
// // play the effect!
// drv.go();
//
// // wait a bit
// delay(500);
return;
}