Add close_open_clean method to Valve
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Mon, 25 Nov 2024 10:54:18 +0000 (11:54 +0100)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Mon, 25 Nov 2024 10:54:18 +0000 (11:54 +0100)
This function repeatedly closes and opens the valve. This is meant to
ensure the volumes of the valve to properly equilibrate.

Valve.h
Valve.ino

diff --git a/Valve.h b/Valve.h
index be9dab229b0569da9a2548338f68e46b9fedb13d..07051f19eedc5f316dcd9d2c0baf7b76c1792d71 100644 (file)
--- a/Valve.h
+++ b/Valve.h
@@ -28,5 +28,6 @@ class Valve
 
                void    open(float seconds = 5);
                void    close(float seconds = 5);
+               void    close_open_clean(unsigned int count = 3);
 };
 #endif // VALVE_H
index ba64d2720d67f6f55a3a82e8891d51987b32be06..35e729dc8dd7595291ed02d130ab25671a91f197 100644 (file)
--- a/Valve.ino
+++ b/Valve.ino
@@ -60,3 +60,15 @@ void Valve::update_pos()
 {
        m_servo.writeMicroseconds(m_usec_current);
 }
+
+void   Valve::close_open_clean(unsigned int count)
+{
+       while (count > 0)
+       {
+               close(3);
+               delay(500);
+               open(3);
+               delay(500);
+               --count;
+       }
+}