@@ -174,12 +174,6 @@ namespace esphome
174
174
}
175
175
}
176
176
177
- if (CurrentZoneStatus == NOBODY && LeftPreviousStatus == NOBODY && RightPreviousStatus == NOBODY)
178
- {
179
- // nobody is in the sensing area
180
- presence_sensor->publish_state (false );
181
- }
182
-
183
177
// if an event has occured
184
178
if (AnEventHasOccured)
185
179
{
@@ -243,6 +237,11 @@ namespace esphome
243
237
PathTrack[PathTrackFillingSize - 1 ] = AllZonesCurrentStatus;
244
238
}
245
239
}
240
+ if (CurrentZoneStatus == NOBODY && LeftPreviousStatus == NOBODY && RightPreviousStatus == NOBODY)
241
+ {
242
+ // nobody is in the sensing area
243
+ presence_sensor->publish_state (false );
244
+ }
246
245
}
247
246
248
247
void Roode::sendCounter (uint16_t counter)
@@ -265,13 +264,9 @@ namespace esphome
265
264
{
266
265
// the value of the average distance is used for computing the optimal size of the ROI and consequently also the center of the two zones
267
266
int function_of_the_distance = 16 * (1 - (0.15 * 2 ) / (0.34 * (min (optimized_zone_0, optimized_zone_1) / 1000 )));
268
- delay (1000 );
269
267
int ROI_size = min (8 , max (4 , function_of_the_distance));
270
268
Roode::roi_width_ = ROI_size;
271
269
Roode::roi_height_ = ROI_size * 2 ;
272
-
273
- delay (250 );
274
-
275
270
// now we set the position of the center of the two zones
276
271
if (advised_sensor_orientation_)
277
272
{
@@ -326,7 +321,6 @@ namespace esphome
326
321
break ;
327
322
}
328
323
}
329
- delay (2000 );
330
324
// we will now repeat the calculations necessary to define the thresholds with the updated zones
331
325
zone = 0 ;
332
326
int *values_zone_0 = new int [number_attempts];
@@ -354,7 +348,7 @@ namespace esphome
354
348
values_zone_1[i] = distance;
355
349
zone++;
356
350
zone = zone % 2 ;
357
- yield ();
351
+ App. feed_wdt ();
358
352
}
359
353
optimized_zone_0 = getOptimizedValues (values_zone_0, getSum (values_zone_0, number_attempts), number_attempts);
360
354
optimized_zone_1 = getOptimizedValues (values_zone_1, getSum (values_zone_1, number_attempts), number_attempts);
@@ -541,7 +535,6 @@ namespace esphome
541
535
if (roi_calibration_)
542
536
{
543
537
roi_calibration (distanceSensor, optimized_zone_0, optimized_zone_1);
544
- yield ();
545
538
}
546
539
547
540
DIST_THRESHOLD_MAX[0 ] = optimized_zone_0 * max_threshold_percentage_ / 100 ; // they can be int values, as we are not interested in the decimal part when defining the threshold
0 commit comments