@@ -21,6 +21,14 @@ class SensorTofMatrix{
21
21
uint32_t _wire_base_clock;
22
22
23
23
public:
24
+ int top;
25
+ int bottom;
26
+ int left;
27
+ int right;
28
+ int center_left;
29
+ int center_right;
30
+ int center;
31
+
24
32
SensorTofMatrix (TwoWire * wire, const uint8_t lpn_pin, const uint8_t i2c_rst_pin, const int size=4 , const int ranging_freq=-1 , const bool wire_boost = true , const uint32_t wire_base_clock=WIRE_BASE_CLOCK){
25
33
_wire=wire;
26
34
_sensor = new VL53L7CX (_wire,lpn_pin,i2c_rst_pin);
@@ -109,8 +117,19 @@ class SensorTofMatrix{
109
117
return return_value;
110
118
}
111
119
120
+ bool update_rois () {
121
+ bool out = update ();
122
+ top = get_avg_range_top_mm ();
123
+ bottom = get_max_range_bottom_mm ();
124
+ left = get_avg_range_left_mm ();
125
+ right = get_avg_range_right_mm ();
126
+ center_left = get_avg_range_center_left_mm ();
127
+ center_right = get_avg_range_center_right_mm ();
128
+ center = get_avg_range_center_mm ();
129
+ return out;
130
+ }
131
+
112
132
int get_min_range_top_mm () {
113
- update ();
114
133
115
134
int16_t top_min = results.distance_mm [0 ];
116
135
@@ -121,8 +140,20 @@ class SensorTofMatrix{
121
140
return top_min;
122
141
}
123
142
143
+ int get_avg_range_top_mm () {
144
+
145
+ int16_t _avg = 0 ;
146
+ uint8_t n = 0 ;
147
+
148
+ for (int i=0 ; i < (_size==4 ?4 :16 ) ;i++) {
149
+ _avg += results.distance_mm [i];
150
+ n++;
151
+ }
152
+
153
+ return _avg/n;
154
+ }
155
+
124
156
int get_max_range_bottom_mm () {
125
- update ();
126
157
127
158
int16_t bottom_max = results.distance_mm [0 ];
128
159
@@ -134,7 +165,6 @@ class SensorTofMatrix{
134
165
}
135
166
136
167
int get_min_range_left_mm () {
137
- update ();
138
168
139
169
int16_t _min = results.distance_mm [0 ];
140
170
@@ -149,7 +179,6 @@ class SensorTofMatrix{
149
179
}
150
180
151
181
int get_min_range_right_mm () {
152
- update ();
153
182
154
183
int16_t _min = results.distance_mm [0 ];
155
184
@@ -164,7 +193,6 @@ class SensorTofMatrix{
164
193
}
165
194
166
195
int get_min_range_center_left_mm () {
167
- update ();
168
196
169
197
int16_t _min = results.distance_mm [0 ];
170
198
@@ -179,7 +207,6 @@ class SensorTofMatrix{
179
207
}
180
208
181
209
int get_min_range_center_right_mm () {
182
- update ();
183
210
184
211
int16_t _min = results.distance_mm [0 ];
185
212
@@ -194,7 +221,6 @@ class SensorTofMatrix{
194
221
}
195
222
196
223
int get_min_range_center_mm () {
197
- update ();
198
224
199
225
int16_t _min = results.distance_mm [0 ];
200
226
@@ -209,7 +235,6 @@ class SensorTofMatrix{
209
235
// avgs
210
236
211
237
int get_avg_range_left_mm () {
212
- update ();
213
238
214
239
int16_t _avg = 0 ;
215
240
uint8_t n = 0 ;
@@ -227,7 +252,6 @@ class SensorTofMatrix{
227
252
}
228
253
229
254
int get_avg_range_right_mm () {
230
- update ();
231
255
232
256
int16_t _avg = 0 ;
233
257
uint8_t n = 0 ;
@@ -245,7 +269,6 @@ class SensorTofMatrix{
245
269
}
246
270
247
271
int get_avg_range_center_left_mm () {
248
- update ();
249
272
250
273
int16_t _avg = 0 ;
251
274
uint8_t n = 0 ;
@@ -263,7 +286,6 @@ class SensorTofMatrix{
263
286
}
264
287
265
288
int get_avg_range_center_right_mm () {
266
- update ();
267
289
268
290
int16_t _avg = 0 ;
269
291
uint8_t n = 0 ;
@@ -281,7 +303,6 @@ class SensorTofMatrix{
281
303
}
282
304
283
305
int get_avg_range_center_mm () {
284
- update ();
285
306
286
307
int16_t _avg = 0 ;
287
308
uint8_t n = 0 ;
0 commit comments