-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSunSimulation.h
executable file
·61 lines (43 loc) · 1.3 KB
/
SunSimulation.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
// SunSimulation
// Copyright Artem Botnev 2018
// MIT License
#ifndef SUNSIMULATION_H
#define SUNSIMULATION_H
#include "inttypes.h"
#define START_RISE 0
#define PWM_MAX 255
#define DAY_SECONDS 86400
class TimeSet {
public:
TimeSet(uint8_t hour, uint8_t minute, uint16_t duration);
uint8_t getHour();
uint8_t getMinute();
uint16_t getDuration();
private:
uint8_t _hour;
uint8_t _minute;
uint16_t _duration;
};
class SunSimulation {
public:
SunSimulation(TimeSet *sunRise, TimeSet *sunSet);
SunSimulation(TimeSet *sunRise, TimeSet *sunSet, uint8_t *brightness);
const char *regimenInit();
const char *reloadRegimen(TimeSet *sunRise, TimeSet *sunSet);
uint8_t changeBrightness(uint8_t hour, uint8_t minute, uint8_t second, uint8_t *brightness);
uint8_t changeBrightness(uint8_t hour, uint8_t minute, uint8_t second);
private:
TimeSet *_sunRise;
TimeSet *_sunSet;
TimeSet *_startPoint;
// seconds
uint32_t _endRise;
uint32_t _startSet;
uint32_t _endSet;
// true if there is not initialization errors
bool _optionsOk;
uint8_t *_brightness;
bool haveTimeError(TimeSet *set);
uint32_t getSecondsFromStart(TimeSet *sunRise, uint32_t curHour, uint32_t curMinute, uint32_t curSecond);
};
#endif