projects
/
manu
/
arduino-maison.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
d42844b
)
Add software debouncing
author
Emmanuel Lacour
<elacour@easter-eggs.com>
Mon, 4 Jul 2022 20:24:16 +0000
(22:24 +0200)
committer
Emmanuel Lacour
<elacour@easter-eggs.com>
Mon, 4 Jul 2022 20:24:16 +0000
(22:24 +0200)
station-meteo/station-meteo.ino
patch
|
blob
|
history
diff --git
a/station-meteo/station-meteo.ino
b/station-meteo/station-meteo.ino
index
5a96ba8
..
dc4cc21
100644
(file)
--- a/
station-meteo/station-meteo.ino
+++ b/
station-meteo/station-meteo.ino
@@
-29,10
+29,8
@@
String location = LOCATION;
int rainfall_sensor_pin = 2;
float rain_incr = 0.2794; // this is mm/m2 for each sensor tick
int rainfall_ticks = 0;
-
-// Timing
-unsigned long previousMillis= 0;
-unsigned long previousMillis2= 0;
+long debouncing_time = 30;
+volatile unsigned long last_micros;
// Initiate udp client
WiFiUDP udp;
@@
-178,5
+176,8
@@
void printWifiStatus() {
void getRain ()
{
- rainfall_ticks ++ ;
+ if((long)(micros() - last_micros) >= debouncing_time * 1000) {
+ rainfall_ticks ++ ;
+ last_micros = micros();
+ }
}