-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpwrplnt.h
121 lines (105 loc) · 3.16 KB
/
cpwrplnt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//cpwrplnt.h
#ifndef CPWRPLNT_H
#define CPWRPLNT_H
#include "Arduino.h"
#include "settings.h"
#include <Time.h>
enum {
ADDR_ACTIVE = 0,
ADDR_MINMOISTURE = 1,
ADDR_TARGETMOISTURE = 2,
ADDR_WATERINGDURATION = 3,
ADDR_WATERINGPAUSE = 4,
ADDR_LIGHTINTENSITY = 5,
ADDR_SUNRISETIME = 6, /*long*/
ADDR_SUNSETTIME = 10, /*long*/
ADDR_LASTPUMPSTART = 14, /*long*/
ADDR_LASTPUMPSTOP = 18 /*long*/
};
class cPwrplnt
{
public:
cPwrplnt();
void init(void);
/* get humidity, brightness, temperature */
void performMeasurements(void);
/* switch Light and Pump */
void performActions(void);
void setActive(bool);
void setMinMoisture(byte);
void setTargetMoisture(byte);
void setWateringDuration(byte sec);
void setWateringPause(byte sec);
void setLightIntensity(byte intensity);
void setSunriseTime(time_t);
void setSunsetTime(time_t);
void resetEEPROM(void);
//Getters
// Settings
bool getActive(void) const
{ return m_doActions; }
byte getMinMoisture(void) const
{ return m_minMoisture; }
byte getTargetMoisture(void) const
{ return m_targetMoisture; }
byte getWateringDuration(void) const
{ return m_wateringDuration; }
byte getWateringPause(void) const
{ return m_wateringPause; }
byte getLightIntensity(void) const
{ return m_lightIntensity; }
time_t getSunriseTime(void) const
{ return m_timeSunrise; }
time_t getSunsetTime(void) const
{ return m_timeSunset; }
time_t getLastPumpStart(void) const
{ return m_lastPumpStart; }
// States
bool getPumpState(void) const
{ return m_pumpState; }
bool getLightState(void) const
{ return m_lightState; }
// Measurements
byte getMoisture(void) const
{ return m_moisture; }
byte getAirHumidity(void) const
{ return m_airHumidity; }
byte getTemperature(void) const
{ return m_temperature; }
byte getBrightness(void) const
{ return m_brightness; }
bool getWaterLevelOk(void) const
{ return m_waterLevelOk; }
private:
// Helper
/* turn pump on or off */
void switchPump(bool state);
/* turn light on or off */
void switchLight(bool state);
// Settings
/* Activate Actors */
bool m_doActions;
/* Moisture level to start watering */
byte m_minMoisture; /* (%) */
/* Moisture level to stop watering */
byte m_targetMoisture; /* (%) */
/* time the pump is running when watering */
byte m_wateringDuration; /* (seconds) */
/* time to wait for water to settle, before allowing new watering */
byte m_wateringPause; /* (seconds) */
byte m_lightIntensity; /* 0-255 not used yet */
time_t m_timeSunrise;
time_t m_timeSunset;
// States
bool m_pumpState;
bool m_lightState;
time_t m_lastPumpStart;
time_t m_lastPumpStop;
// Measurements
byte m_moisture; /* (%) */
byte m_airHumidity; /* (%) */
byte m_temperature; /* degree celcius */
byte m_brightness; /* (%) */
bool m_waterLevelOk; /* true when water tank has to be refilled */
};
#endif