Change pwm_pin to control_pin
authorLukáš Jiřiště <jiriste@icpf.cas.cz>
Mon, 18 Nov 2024 10:03:13 +0000 (11:03 +0100)
committerLukáš Jiřiště <jiriste@icpf.cas.cz>
Mon, 18 Nov 2024 10:03:13 +0000 (11:03 +0100)
This is done because the Servo library does not use the PWM
functionality of the digital pins for the servo control. I thought it
does but it uses an inner timer for timing the pulses.

CellValve.h
CellValve.ino
Valve.h
Valve.ino

index ada5a2ec398dd19681d13dad0dfeafbab52741b5..0e71379b6e8b276fc24e36e5d7101588bea99647 100644 (file)
@@ -11,7 +11,7 @@ class CellValve : public Valve
        public:
                CellValve() = delete;
                CellValve(const CellValve &other) = delete;
-               CellValve(pin pwm_pin, int usec_opened, int usec_barely_opened,
+               CellValve(pin control_pin, int usec_opened, int usec_barely_opened,
                                int isec_closed);
                ~CellValve();
 
index ad2c8b0569c0f5c0f3e8280c47385de0dcb0f7bf..cdd69e5e935d41bc0d4282c27fcfe9e97b667b86 100644 (file)
@@ -1,8 +1,8 @@
 #include "CellValve.h"
 
-CellValve::CellValve(pin pwm_pin, int usec_opened, int usec_barely_opened,
+CellValve::CellValve(pin control_pin, int usec_opened, int usec_barely_opened,
                                int usec_closed)
-       : Valve{pwm_pin, usec_opened, usec_closed}
+       : Valve{control_pin, usec_opened, usec_closed}
        , m_usec_barely_opened{usec_barely_opened}
 {
 }
diff --git a/Valve.h b/Valve.h
index 9ae0a8a64c844ea677a8d254e0822e0993328eff..be9dab229b0569da9a2548338f68e46b9fedb13d 100644 (file)
--- a/Valve.h
+++ b/Valve.h
@@ -21,7 +21,7 @@ class Valve
        public:
                Valve() = delete;
                Valve(const Valve &other) = delete;
-               Valve(pin pwm_pin, int usec_opened, int isec_closed);
+               Valve(pin control_pin, int usec_opened, int isec_closed);
                ~Valve();
 
                Valve   &operator=(const Valve &other) = delete;
index 1c18584fa9c11d9d797c481882d1f58fbbc13ff8..ba64d2720d67f6f55a3a82e8891d51987b32be06 100644 (file)
--- a/Valve.ino
+++ b/Valve.ino
@@ -1,12 +1,12 @@
 #include "Valve.h"
 
-Valve::Valve(pin pwm_pin, int usec_opened, int usec_closed)
+Valve::Valve(pin control_pin, int usec_opened, int usec_closed)
        : m_servo{}
        , m_usec_opened{usec_opened}
        , m_usec_closed{usec_closed}
        , m_usec_current{usec_closed}
 {
-       m_servo.attach(pwm_pin);
+       m_servo.attach(control_pin);
        update_pos();
 }