--- /dev/null
+#ifndef CELLVALVE_H
+# define CELLVALVE_H
+
+#include "Valve.h"
+
+class CellValve : public Valve
+{
+ private:
+ const int m_usec_barely_opened;
+
+ public:
+ CellValve() = delete;
+ CellValve(const CellValve &other) = delete;
+ CellValve(pin pwm_pin, int usec_opened, int usec_barely_opened,
+ int isec_closed);
+ ~CellValve();
+
+ CellValve &operator=(const CellValve &other) = delete;
+
+ void open_barely(float seconds = 5);
+};
+
+#endif // CELLVALVE_H
--- /dev/null
+#include "CellValve.h"
+
+CellValve::CellValve(pin pwm_pin, int usec_opened, int usec_barely_opened,
+ int usec_closed)
+ : Valve{pwm_pin, usec_opened, usec_closed}
+ , m_usec_barely_opened{usec_barely_opened}
+{
+}
+
+CellValve::~CellValve()
+{
+}
+
+void CellValve::open_barely(float seconds)
+{
+ write_usec_timed(m_usec_barely_opened, seconds);
+}
SRCS := Servomatic.ino \
PressureSensor.ino \
Valve.ino \
+ CellValve.ino \
Measurement.ino \
class Valve
{
private:
- typedef int pin;
-
const Servo m_servo;
const int m_usec_opened;
- const int m_usec_barely_opened;
const int m_usec_closed;
int m_usec_current;
- void write_usec_timed(int usec_wanted, float seconds);
void update_pos();
+ protected:
+ typedef int pin;
+
+ void write_usec_timed(int usec_wanted, float seconds);
+
public:
Valve() = delete;
Valve(const Valve &other) = delete;
- Valve(pin pwm_pin, int usec_opened, int usec_barely_opened,
- int isec_closed);
+ Valve(pin pwm_pin, int usec_opened, int isec_closed);
~Valve();
Valve &operator=(const Valve &other) = delete;
void open(float seconds = 5);
- void open_barely(float seconds = 5);
void close(float seconds = 5);
};
-
#endif // VALVE_H
#include "Valve.h"
-Valve::Valve(pin pwm_pin, int usec_opened, int usec_barely_opened, int usec_closed)
+Valve::Valve(pin pwm_pin, int usec_opened, int usec_closed)
: m_servo{}
, m_usec_opened{usec_opened}
- , m_usec_barely_opened{usec_barely_opened}
, m_usec_closed{usec_closed}
, m_usec_current{usec_closed}
{
write_usec_timed(m_usec_opened, seconds);
}
-void Valve::open_barely(float seconds)
-{
- write_usec_timed(m_usec_barely_opened, seconds);
-}
-
void Valve::close(float seconds)
{
write_usec_timed(m_usec_closed, seconds);