From: Lukáš Jiřiště Date: Mon, 25 Nov 2024 10:54:18 +0000 (+0100) Subject: Add close_open_clean method to Valve X-Git-Url: https://git.ljiriste.work/?a=commitdiff_plain;h=c8c6f0145b333c1f57f555e50bacab1e7d874325;p=Servomatic.git Add close_open_clean method to Valve This function repeatedly closes and opens the valve. This is meant to ensure the volumes of the valve to properly equilibrate. --- diff --git a/Valve.h b/Valve.h index be9dab2..07051f1 100644 --- 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 diff --git a/Valve.ino b/Valve.ino index ba64d27..35e729d 100644 --- 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; + } +}