-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboop.cpp
More file actions
46 lines (38 loc) · 1.12 KB
/
boop.cpp
File metadata and controls
46 lines (38 loc) · 1.12 KB
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
#include "boop.h"
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
static uint8_t boopPin = 4;
static uint16_t boopThreshold = 50;
static bool boopActive = false;
unsigned long boopInterval;
unsigned long lastBoopCheck;
void initBoop() {
Wire.begin();
sensor.init();
sensor.setTimeout(500);
sensor.startContinuous();
boopInterval = 100; // Check every 100ms
lastBoopCheck = 0;
}
void updateBoop() {
uint16_t distance = sensor.readRangeContinuousMillimeters();
if (distance < boopThreshold && !boopActive) {
boopActive = true;
// Trigger animation
} else if (distance >= boopThreshold) {
boopActive = false;
}
}
void setBoopSettings(uint16_t threshold) {
boopThreshold = threshold;
}
void handleBoop(unsigned long currentMillis) {
if (currentMillis - lastBoopCheck >= boopInterval) {
lastBoopCheck = currentMillis;
uint16_t distance = sensor.readRangeContinuousMillimeters();
if (distance < 100) { // distance threshold
Serial.println("Boop detected!");
}
}
}