Repository navigation
Expand file tree
/
Copy pathData.h
More file actions
90 lines (79 loc) · 2.29 KB
/
Copy pathData.h
File metadata and controls
90 lines (79 loc) · 2.29 KB
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
#ifndef DATA_H
#define DATA_H
#include "API.h"
#include "RTC.h"
#include "TimeFuncs.h"
#include "CalendarFuncs.h"
// Time data
String curr_time;
Date curr_date;
Weekday curr_weekday;
// Weather data
WeatherOverview weather_overview;
int8_t temperature_curr_c = -100;
int8_t temperature_max_c = -100;
uint8_t humidity_curr_pc = 0;
uint8_t humidity_max_pc = 0;
uint8_t wind_speed_curr_kmh = 0;
uint8_t wind_speed_max_kmh = 0;
float uv_index_curr = 0.0;
float uv_index_max = 0.0;
uint8_t cloudiness_curr_pc = 0;
uint8_t cloudiness_max_pc = 0;
uint8_t precipitation_chances_curr_pc = 0;
uint8_t precipitation_chances_max_pc = 0;
float precipitation_amount_curr_mm = 0.0;
float precipitation_amount_max_mm = 0.0;
// Sun/moon data
String sunrise;
String sunset;
String day_length;
uint8_t next_solstice;
MoonPhase moon_phase;
uint8_t days_to_next_full_moon;
uint16_t current_day;
uint8_t current_week;
void update_data(bool force_reset_highs = false)
{
curr_time = get_current_time();
curr_date = get_current_date();
// If it's hour 0 (midnight), it's a new day so the highs will be different
// Otherwise, the highs should be preserved because the API only does predictions and can sometimes
// give lower values than it previously gave for the highs that day
uint8_t current_hour = curr_time.substring(0, 2).toInt();
bool new_day = (current_hour == 0) || force_reset_highs;
get_environment_data(
new_day,
// Weather data
&weather_overview,
&temperature_curr_c,
&temperature_max_c,
&humidity_curr_pc,
&humidity_max_pc,
&wind_speed_curr_kmh,
&wind_speed_max_kmh,
&uv_index_curr,
&uv_index_max,
&cloudiness_curr_pc,
&cloudiness_max_pc,
&precipitation_chances_curr_pc,
&precipitation_chances_max_pc,
&precipitation_amount_curr_mm,
&precipitation_amount_max_mm,
// Sun / moon data
&sunrise,
&sunset,
&day_length,
&moon_phase,
&days_to_next_full_moon
);
next_solstice = daysUntilNextSolstice(curr_date.year, (int)curr_date.month, curr_date.day);
current_day = calculateDayOfYear(curr_date.year, (int)curr_date.month, curr_date.day);
current_week = calculateWeekOfYear(curr_date.year, (int)curr_date.month, curr_date.day);
}
void update_date_and_time()
{
curr_time = get_current_time();
curr_date = get_current_date();
}
#endif