Selaa lähdekoodia

Changed HCSR04 as submodule

xnecas 1 viikko sitten
vanhempi
sitoutus
5ebe7b2b61
5 muutettua tiedostoa jossa 9 lisäystä ja 1 poistoa
  1. 3 0
      .gitmodules
  2. 1 0
      lib/HCSR04
  3. 1 0
      main/lib/HCSR04/LICENSE
  4. 2 1
      main/lib/HCSR04/src/HCSR04.cpp
  5. 2 0
      main/lib/HCSR04/src/HCSR04.h

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "lib/HCSR04"]
+	path = lib/HCSR04
+	url = rcvyskum01@repo.vyskumnecentrum.sk:esp32-drivers/HC-SR04.git

+ 1 - 0
lib/HCSR04

@@ -0,0 +1 @@
+Subproject commit 7c2a4e4b022e88c3f7eeb46eab10c4299b646ea7

+ 1 - 0
main/lib/HCSR04/LICENSE

@@ -1,5 +1,6 @@
 The MIT License (MIT)
 
+Copyright (c) 2026 Matúš Nečas
 Copyright (c) 2016 Martin Šošić
 
 Permission is hereby granted, free of charge, to any person obtaining a copy

+ 2 - 1
main/lib/HCSR04/src/HCSR04.cpp

@@ -48,7 +48,8 @@ float UltraSonicDistanceSensor::measureDistanceCm(float temperature, float humid
     // Measure the length of echo signal, which is equal to the time needed for sound to go there and back.
     unsigned long durationMicroSec = pulseIn(echoPin, HIGH, maxDistanceDurationMicroSec); // can't measure beyond max distance
 
-    time_t t_diff = 60 - (millis() - t0);
+    // Wait at least 60 ms (datasheet value)
+    time_t t_diff = HCSR04_MEASURE_DELAY - (millis() - t0);
     
     if (t_diff > 0)
     {   

+ 2 - 0
main/lib/HCSR04/src/HCSR04.h

@@ -9,6 +9,8 @@
 
 #include "Arduino.h"
 
+#define HCSR04_MEASURE_DELAY 60  ///< delay between measures
+
 class UltraSonicDistanceSensor {
  public:
     /**