Move daylight info code in to own file.
This commit is contained in:
parent
c8431783f5
commit
4567adf91b
3 changed files with 86 additions and 57 deletions
22
NaturalLight.h
Normal file
22
NaturalLight.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#ifndef _DAYLIGHT_h
|
||||
#define _DAYLIGHT_h
|
||||
#include <Arduino.h>
|
||||
|
||||
#define SOLAR_EVENT_URL "http://api.sunrise-sunset.org/json?lat=%s&lng=%s&formatted=0"
|
||||
|
||||
class NaturalLight {
|
||||
int _astronomicalTwilightBegin, _sunrise, _sunset, _astronomicalTwilightEnd, _timezoneOffset;
|
||||
char _url[80];
|
||||
String getSolarEventJson();
|
||||
int getEpoch(const char *str);
|
||||
int adjustForTimezone(int epoch);
|
||||
|
||||
public:
|
||||
NaturalLight(char *lat, char *lon, int timezoneOffset);
|
||||
void update();
|
||||
int getAstronomicalTwilightBegin() { return _astronomicalTwilightBegin; }
|
||||
int getSunrise() { return _sunrise; }
|
||||
int getSunset() { return _sunset; }
|
||||
int getAstronomicalTwilightEnd() { return _astronomicalTwilightEnd; }
|
||||
};
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue