🐛 Fixes API routes
All checks were successful
Gitea Build Action / build (push) Successful in 25s

This commit is contained in:
Daniel Svitan
2025-06-01 12:40:13 +02:00
parent 2f3ccf14db
commit 100bab01e4
2 changed files with 10 additions and 7 deletions

View File

@@ -7,7 +7,7 @@ from machine import Pin
THRESHOLD_DISTANCE = 15 # cm
SOUND_SPEED = 340 * 100 # m/s * centi = cm/s
MAX_CONNECTION_RETRIES = 50
ULTRA_OPENED_THRESHOLD = 3
ULTRA_OPENED_THRESHOLD = 2
class App:
@@ -148,14 +148,18 @@ class App:
self.led.low()
self.ultra_opened_counter = 0
# was it just closed?
if self.previously_opened:
self.update_server()
self.previously_opened = False
else:
self.led.high()
self.ultra_opened_counter += 1
if self.ultra_opened_counter >= ULTRA_OPENED_THRESHOLD:
# was it just opened? +wait delay
if self.ultra_opened_counter >= ULTRA_OPENED_THRESHOLD and not self.previously_opened:
self.update_server()
self.previously_opened = True
if i >= 20:
self.led.toggle()
@@ -169,9 +173,8 @@ class App:
utime.sleep_ms(500)
except Exception as e:
print(f"Fatal exception occurred: {e}")
print(f"Fatal error occurred: {e}")
self.previously_opened = self.opened
i += 1
if __name__ == "__main__":