-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhello_tofcal.cpp
54 lines (43 loc) · 921 Bytes
/
hello_tofcal.cpp
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
// Calibration of ToF sensor
// 2024-04-17
#include "tof.h"
#include "rodos.h"
int16_t calibration_distance_mm = 162;
int16_t calibration_samples = 20;
class tof_calthread : public StaticThread<>
{
private:
int period = 5000; // millis
public:
tof_calthread(const char* thread_name) : StaticThread(thread_name){}
void init();
void run();
};
void tof_calthread::init()
{
if(tof::init(TOF_IDX_ALL) == TOF_STATUS_OK)
{
PRINTF("VL53L4CD initialized!\n");
}
else
{
PRINTF("VL53L4CD error :(\n");
}
tof::enable_median_filter();
}
void tof_calthread::run()
{
while(1)
{
if(tof::calibrate(calibration_distance_mm, calibration_samples) == TOF_STATUS_OK)
{
PRINTF("Calibration successful!\n\n");
}
else
{
PRINTF("Calibration error!\n");
}
suspendCallerUntil(NOW() + period * MILLISECONDS);
}
}
tof_calthread test_tof_calthread("lidar_thread");