MistyGro API
C++ API for MistyGro's ESP32 controller based on the Arduino framework
light_scheduler.h
Go to the documentation of this file.
1 /*
2  * Copyright 2023 Myron Rodrigues
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef _LIGHT_SCHEDULER_H_
18 #define _LIGHT_SCHEDULER_H_
19 
20 #include <Arduino.h>
21 
22 #include "relay.h"
23 
29 {
30 private:
31  Relay * light_;
32  uint64_t light_duration_;
33  time_t start_time_;
34  int prev_wday_;
35  int start_hour_;
36  int start_min_;
37 
38 public:
48  Relay * light, int start_hour, int start_min, uint64_t duration_sec);
49 
55  void reset(tm * time);
56 
63  void run(tm * time, bool is_bright);
64 };
65 
66 #endif
RelayAL light(14)
Definition: main.cpp:33
Schedules light switching depending on time of day and ambient light.
void reset(tm *time)
reset start time to given time
void run(tm *time, bool is_bright)
Run this in a loop and pass the current time and a boolean indicating if its bright.
LightScheduler(Relay *light, int start_hour, int start_min, uint64_t duration_sec)
Construct a new Light Scheduler object.
Abstract relay class.
Definition: relay.h:29