Skip to content

Commit f1e1cdb

Browse files
committed
TOF ROIs
1 parent d0ec83b commit f1e1cdb

File tree

3 files changed

+155
-10
lines changed

3 files changed

+155
-10
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/**
2+
******************************************************************************
3+
* @file platform_config_default.h
4+
* @author STMicroelectronics
5+
* @version V1.0.0
6+
* @date 11 November 2021
7+
* @brief Header file with the default platform settings.
8+
******************************************************************************
9+
* @attention
10+
*
11+
* <h2><center>&copy; COPYRIGHT(c) 2021 STMicroelectronics</center></h2>
12+
*
13+
* Redistribution and use in source and binary forms, with or without modification,
14+
* are permitted provided that the following conditions are met:
15+
* 1. Redistributions of source code must retain the above copyright notice,
16+
* this list of conditions and the following disclaimer.
17+
* 2. Redistributions in binary form must reproduce the above copyright notice,
18+
* this list of conditions and the following disclaimer in the documentation
19+
* and/or other materials provided with the distribution.
20+
* 3. Neither the name of STMicroelectronics nor the names of its contributors
21+
* may be used to endorse or promote products derived from this software
22+
* without specific prior written permission.
23+
*
24+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30+
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31+
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32+
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34+
*
35+
******************************************************************************
36+
*/
37+
38+
#ifndef _PLATFORM_CONFIG_DEFAULT_H_
39+
#define _PLATFORM_CONFIG_DEFAULT_H_
40+
41+
/*
42+
* @brief If you want to customize these defines you can add in the application
43+
* code the file platform_config_custom.h file where you can override some of
44+
* these defines.
45+
*/
46+
47+
/*
48+
* @brief The macro below is used to define the number of target per zone sent
49+
* through I2C. This value can be changed by user, in order to tune I2C
50+
* transaction, and also the total memory size (a lower number of target per
51+
* zone means a lower RAM). The value must be between 1 and 4.
52+
*/
53+
54+
#ifndef VL53L7CX_NB_TARGET_PER_ZONE
55+
#define VL53L7CX_NB_TARGET_PER_ZONE 1U
56+
#endif
57+
58+
/*
59+
* @brief The macro below can be used to avoid data conversion into the driver.
60+
* By default there is a conversion between firmware and user data. Using this macro
61+
* allows to use the firmware format instead of user format. The firmware format allows
62+
* an increased precision.
63+
*/
64+
65+
// #define VL53L7CX_USE_RAW_FORMAT
66+
67+
/*
68+
* @brief All macro below are used to configure the sensor output. User can
69+
* define some macros if he wants to disable selected output, in order to reduce
70+
* I2C access.
71+
*/
72+
73+
#define VL53L7CX_DISABLE_AMBIENT_PER_SPAD
74+
#define VL53L7CX_DISABLE_NB_SPADS_ENABLED
75+
#define VL53L7CX_DISABLE_NB_TARGET_DETECTED
76+
#define VL53L7CX_DISABLE_SIGNAL_PER_SPAD
77+
#define VL53L7CX_DISABLE_RANGE_SIGMA_MM
78+
// #define VL53L7CX_DISABLE_DISTANCE_MM
79+
#define VL53L7CX_DISABLE_REFLECTANCE_PERCENT
80+
#define VL53L7CX_DISABLE_TARGET_STATUS
81+
#define VL53L7CX_DISABLE_MOTION_INDICATOR
82+
83+
#endif // _PLATFORM_CONFIG_DEFAULT_H_

examples/sensor_tof/sensor_tof.ino

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,25 @@ void setup() {
2424

2525
void loop() {
2626
bool updated = false;
27-
T1 = micros();
2827
updated = tof.update();
29-
T2 = micros();
30-
31-
Serial.print(T2-T1);
32-
Serial.print(", ");
33-
28+
3429
if (updated) {
3530
Serial.println(" ");
3631
Serial.print("TOP=");
3732
Serial.println(tof.get_min_range_top_mm());
33+
Serial.print("BOT=");
34+
Serial.println(tof.get_max_range_bottom_mm());
35+
Serial.print("LEFT=");
36+
Serial.println(tof.get_min_range_left_mm());
37+
Serial.print("RIGHT=");
38+
Serial.println(tof.get_min_range_right_mm());
39+
Serial.print("CLEFT=");
40+
Serial.println(tof.get_min_range_center_left_mm());
41+
Serial.print("CRIGHT=");
42+
Serial.println(tof.get_min_range_center_right_mm());
43+
Serial.print("CENTER=");
44+
Serial.println(tof.get_min_range_center_mm());
3845
}
3946

40-
delay(100);
47+
//delay(1000);
4148
}

src/sensor_tof_matrix.h

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,64 @@ class SensorTofMatrix{
145145
return top_min;
146146
}
147147

148-
/*void setResolution(){
149-
_sensor->setRes
150-
}*/
148+
int get_min_range_left_mm() {
149+
update();
150+
151+
int16_t top_min = results.distance_mm[0];
152+
153+
for (int i=(_size==4?3:6); i < (_size==4?16:64) ;i+=_size) {
154+
top_min = min(top_min, results.distance_mm[i]);
155+
if (_size==8) {
156+
top_min = min(top_min, results.distance_mm[i+1]);
157+
}
158+
}
159+
160+
return top_min;
161+
}
162+
163+
int get_min_range_center_right_mm() {
164+
update();
165+
166+
int16_t top_min = results.distance_mm[0];
167+
168+
for (int i=(_size==4?5:18); i < (_size==4?13:50) ;i+=_size) {
169+
top_min = min(top_min, results.distance_mm[i]);
170+
if (_size==8) {
171+
top_min = min(top_min, results.distance_mm[i+1]);
172+
}
173+
}
174+
175+
return top_min;
176+
}
177+
178+
int get_min_range_center_left_mm() {
179+
update();
180+
181+
int16_t top_min = results.distance_mm[0];
182+
183+
for (int i=(_size==4?6:20); i < (_size==4?14:52) ;i+=_size) {
184+
top_min = min(top_min, results.distance_mm[i]);
185+
if (_size==8) {
186+
top_min = min(top_min, results.distance_mm[i+1]);
187+
}
188+
}
189+
190+
return top_min;
191+
}
192+
193+
int get_min_range_center_mm() {
194+
update();
195+
196+
int16_t top_min = results.distance_mm[0];
197+
198+
for (int i=(_size==5?6:19); i < (_size==4?13:51) ;i+=_size) {
199+
top_min = min(top_min, results.distance_mm[i]);
200+
top_min = min(top_min, results.distance_mm[i+1]);
201+
}
202+
203+
return top_min;
204+
}
205+
151206
};
152207

153208
#endif

0 commit comments

Comments
 (0)