forked from wuspy/portal_calendar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweather.h
80 lines (71 loc) · 1.45 KB
/
weather.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
#include "global.h"
#ifndef PORTALCALENDAR_WEATHER_H
#define PORTALCALENDAR_WEATHER_H
/**
* OWM weather conditions, ordered by severity
*/
enum class WeatherCondition: uint8_t
{
UNKNOWN = 0,
CLEAR,
FEW_CLOUDS,
SCATTERED_CLOUDS,
BROKEN_CLOUDS,
OVERCAST_CLOUDS,
FOG,
SCATTERED_SHOWERS,
SHOWERS,
THUNDERSTORM,
FREEZING_RAIN,
SNOW,
};
enum class OwmResult
{
SUCCESS,
INVALID_LOCATION,
INVALID_API_KEY,
MALFORMED_RESPONSE,
NO_RESPONSE,
};
struct OwmLocation
{
OwmResult result;
float lat;
float lon;
String name;
};
/**
* Stores aggregated weather data for an entire day
*/
struct DailyWeather {
WeatherCondition condition;
int16_t highTemp;
int16_t lowTemp;
bool daylight;
int8_t month;
int8_t mday;
int8_t wday;
};
/**
* Stores a single weather entry from OWM's 5-day/3-hour API
*/
struct WeatherEntry {
WeatherCondition condition;
int16_t temp;
bool daylight;
int8_t clouds;
int8_t pop;
int8_t humidity;
int8_t month;
int8_t mday;
int8_t wday;
int8_t hour;
int8_t minute;
};
extern time_t lastWeatherSync;
void getTodaysWeather(int month, int mday, WeatherEntry (&result)[5]);
void get5DayWeather(int month, int mday, int year, DailyWeather (&result)[5]);
OwmResult testApiKey(String apiKey);
OwmLocation queryLocation(String location, String apiKey);
OwmResult refreshWeather();
#endif // PORTALCALENDAR_WEATHER_H