-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLightController.h
108 lines (85 loc) · 2.84 KB
/
LightController.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
////////////////////////////////////////////////////////////
// Light Controller
////////////////////////////////////////////////////////////
#ifndef LightController_h
#define LightController_h
////////////////////////////////////////////////////////////
// Control the Chicken coop light to adjust for shorter days
// in the winter and keep egg production up.
//
// This object controls the coop light. It has the concept
// and setting of a minimum day length. If the current day
// length (how long the door is open) is shorter
// than the minimum day length then it provides supplemental
// illumination by turning the light on some time before opening
// the door in the morning, and turning it off some time after
// the door is closed in the evening.
//
// Separately, it leaves the light on for some time after opening
// the door in the morning to allow a little morning light to help
// the chickens get down from the perch, and turns the light
// some time before closing the door in the evening to help the
// chickens find their way to the coop and get on the perch.
////////////////////////////////////////////////////////////
class CLightController
{
protected:
bool m_lightIsOn; // Current on/off status of the light
bool m_lastCorrectState; // 'Correct' status on last check
double m_minimumDayLength;
double m_extraLightTimeMorning;
double m_extraLightTimeEvening;
double m_morningLightOnTime;
double m_morningLightOffTime;
double m_eveningLightOnTime;
double m_eveningLightOffTime;
public:
CLightController();
virtual ~CLightController();
void setup();
double getMinimumDayLength()
{
return m_minimumDayLength;
}
telemetrycommandResponseE setMinimumDayLength(double _dayLen)
{
if(_dayLen >= GARY_COOPER_LIGHT_MIN_DAY_LENGTH && _dayLen <= GARY_COOPER_LIGHT_MAX_DAY_LENGTH)
{
m_minimumDayLength = _dayLen;
return telemetry_cmd_response_ack;
}
return telemetry_cmd_response_nak_invalid_value;
}
double getExtraLightTimeMorning()
{
return m_extraLightTimeMorning;
}
double getExtraLightTimeEvening()
{
return m_extraLightTimeEvening;
}
telemetrycommandResponseE setExtraLightTimeMorning(double _elt)
{
if(_elt >= GARY_COOPER_LIGHT_MIN_EXTRA && _elt <= GARY_COOPER_LIGHT_MAX_EXTRA)
{
m_extraLightTimeMorning = _elt;
return telemetry_cmd_response_ack;
}
return telemetry_cmd_response_nak_invalid_value;
}
telemetrycommandResponseE setExtraLightTimeEvening(double _elt)
{
if(_elt >= GARY_COOPER_LIGHT_MIN_EXTRA && _elt <= GARY_COOPER_LIGHT_MAX_EXTRA)
{
m_extraLightTimeEvening = _elt;
return telemetry_cmd_response_ack;
}
return telemetry_cmd_response_nak_invalid_value;
}
void saveSettings(CSaveController &_saveController, bool _defaults);
void loadSettings(CSaveController &_saveController);
void checkTime();
void sendTelemetry();
telemetrycommandResponseE command(bool _on);
};
#endif