@@ -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);
@@ -106,8 +114,19 @@ class SensorTofMatrix{
106
114
return return_value;
107
115
}
108
116
117
+ bool update_rois () {
118
+ bool out = update ();
119
+ top = get_avg_range_top_mm ();
120
+ bottom = get_max_range_bottom_mm ();
121
+ left = get_avg_range_left_mm ();
122
+ right = get_avg_range_right_mm ();
123
+ center_left = get_avg_range_center_left_mm ();
124
+ center_right = get_avg_range_center_right_mm ();
125
+ center = get_avg_range_center_mm ();
126
+ return out;
127
+ }
128
+
109
129
int get_min_range_top_mm () {
110
- update ();
111
130
112
131
int16_t top_min = results.distance_mm [0 ];
113
132
@@ -118,8 +137,20 @@ class SensorTofMatrix{
118
137
return top_min;
119
138
}
120
139
140
+ int get_avg_range_top_mm () {
141
+
142
+ int16_t _avg = 0 ;
143
+ uint8_t n = 0 ;
144
+
145
+ for (int i=0 ; i < (_size==4 ?4 :16 ) ;i++) {
146
+ _avg += results.distance_mm [i];
147
+ n++;
148
+ }
149
+
150
+ return _avg/n;
151
+ }
152
+
121
153
int get_max_range_bottom_mm () {
122
- update ();
123
154
124
155
int16_t bottom_max = results.distance_mm [0 ];
125
156
@@ -130,8 +161,20 @@ class SensorTofMatrix{
130
161
return bottom_max;
131
162
}
132
163
164
+ int get_avg_range_bottom_mm () {
165
+
166
+ int16_t _avg = 0 ;
167
+ uint8_t n = 0 ;
168
+
169
+ for (int i=(_size==4 ?12 :48 ); i < (_size==4 ?15 :63 ) ;i++) {
170
+ _avg += results.distance_mm [i];
171
+ n++;
172
+ }
173
+
174
+ return _avg/n;
175
+ }
176
+
133
177
int get_min_range_left_mm () {
134
- update ();
135
178
136
179
int16_t _min = results.distance_mm [0 ];
137
180
@@ -146,7 +189,6 @@ class SensorTofMatrix{
146
189
}
147
190
148
191
int get_min_range_right_mm () {
149
- update ();
150
192
151
193
int16_t _min = results.distance_mm [0 ];
152
194
@@ -161,7 +203,6 @@ class SensorTofMatrix{
161
203
}
162
204
163
205
int get_min_range_center_left_mm () {
164
- update ();
165
206
166
207
int16_t _min = results.distance_mm [0 ];
167
208
@@ -176,7 +217,6 @@ class SensorTofMatrix{
176
217
}
177
218
178
219
int get_min_range_center_right_mm () {
179
- update ();
180
220
181
221
int16_t _min = results.distance_mm [0 ];
182
222
@@ -191,7 +231,6 @@ class SensorTofMatrix{
191
231
}
192
232
193
233
int get_min_range_center_mm () {
194
- update ();
195
234
196
235
int16_t _min = results.distance_mm [0 ];
197
236
@@ -206,7 +245,6 @@ class SensorTofMatrix{
206
245
// avgs
207
246
208
247
int get_avg_range_left_mm () {
209
- update ();
210
248
211
249
int16_t _avg = 0 ;
212
250
uint8_t n = 0 ;
@@ -224,7 +262,6 @@ class SensorTofMatrix{
224
262
}
225
263
226
264
int get_avg_range_right_mm () {
227
- update ();
228
265
229
266
int16_t _avg = 0 ;
230
267
uint8_t n = 0 ;
@@ -242,7 +279,6 @@ class SensorTofMatrix{
242
279
}
243
280
244
281
int get_avg_range_center_left_mm () {
245
- update ();
246
282
247
283
int16_t _avg = 0 ;
248
284
uint8_t n = 0 ;
@@ -260,7 +296,6 @@ class SensorTofMatrix{
260
296
}
261
297
262
298
int get_avg_range_center_right_mm () {
263
- update ();
264
299
265
300
int16_t _avg = 0 ;
266
301
uint8_t n = 0 ;
@@ -278,7 +313,6 @@ class SensorTofMatrix{
278
313
}
279
314
280
315
int get_avg_range_center_mm () {
281
- update ();
282
316
283
317
int16_t _avg = 0 ;
284
318
uint8_t n = 0 ;
0 commit comments