@@ -19,7 +19,7 @@ String moonAgeImage = "";
19
19
uint32_t lastTemperatureSent = 0 ;
20
20
21
21
HomieNode temperatureNode (" temperature" , " temperature" );
22
- HomieSetting<const char *> owApiKey (" ow_api_key" , " Open Weather API Key" );
22
+ HomieSetting<const char *> owApiKey (" ow_api_key" , " Open Weather API Key" );
23
23
24
24
void initialize () {
25
25
currentUpdate = true ;
@@ -30,7 +30,8 @@ void initialize() {
30
30
}
31
31
32
32
void temperatureLoop () {
33
- if (millis () - lastTemperatureSent >= TEMPERATURE_UPDATE * 1000 || lastTemperatureSent == 0 ) {
33
+ if (millis () - lastTemperatureSent >= TEMPERATURE_UPDATE * 1000 ||
34
+ lastTemperatureSent == 0 ) {
34
35
sensors.requestTemperatures ();
35
36
insideTemp = sensors.getTempCByIndex (0 );
36
37
Homie.getLogger () << F (" Temperature: " ) << insideTemp << endl;
@@ -50,9 +51,15 @@ void setup() {
50
51
gfx.fillBuffer (MINI_BLACK);
51
52
gfx.commit ();
52
53
53
- updateCurrentTicker.attach (5 * 60 * 1000 , []() {if (WiFi.status () == WL_CONNECTED) currentUpdate = true ;});
54
- updateForecastTicker.attach (20 * 60 * 1000 , []() {if (WiFi.status () == WL_CONNECTED) forecastUpdate = true ;});
55
- updateAstronomyTicker.attach (60 * 60 * 1000 , []() {if (WiFi.status () == WL_CONNECTED) astronomyUpdate = true ;});
54
+ updateCurrentTicker.attach (5 * 60 * 1000 , []() {
55
+ if (WiFi.status () == WL_CONNECTED) currentUpdate = true ;
56
+ });
57
+ updateForecastTicker.attach (20 * 60 * 1000 , []() {
58
+ if (WiFi.status () == WL_CONNECTED) forecastUpdate = true ;
59
+ });
60
+ updateAstronomyTicker.attach (60 * 60 * 1000 , []() {
61
+ if (WiFi.status () == WL_CONNECTED) astronomyUpdate = true ;
62
+ });
56
63
57
64
carousel.setFrames (frames, frameCount);
58
65
carousel.disableAllIndicators ();
@@ -62,7 +69,6 @@ void setup() {
62
69
currentWeatherClient.setLanguage (OPEN_WEATHER_LANGUAGE);
63
70
forecastClient.setMetric (IS_METRIC);
64
71
forecastClient.setLanguage (OPEN_WEATHER_LANGUAGE);
65
- uint8_t allowedHours[] = {12 , 0 };
66
72
forecastClient.setAllowedHours (allowedHours, sizeof (allowedHours));
67
73
68
74
Homie_setFirmware (" weather-station" , " 0.0.1" );
@@ -99,10 +105,10 @@ void onHomieEvent(const HomieEvent &event) {
99
105
}
100
106
101
107
void loop () {
102
- // Handle OTA display first to ensure it is displaued before restarts
108
+ // Handle OTA display first to ensure it is displayed before restarts
103
109
switch (otaState) {
104
110
case 1 : // started
105
- if (!otaInitialDrawDone || otaProgress % 10 == 0 ) {
111
+ if (!otaInitialDrawDone || otaProgress % 5 == 0 ) {
106
112
drawProgress (otaProgress, F (" Updating..." ));
107
113
otaInitialDrawDone = true ;
108
114
}
@@ -228,18 +234,22 @@ void drawCurrentWeather() {
228
234
229
235
gfx.setTransparentColor (MINI_BLACK);
230
236
gfx.drawPalettedBitmapFromPgm (
231
- 0 , 55 , getMeteoconIconFromProgmem (displayCurrent ? currentWeather.icon : " 01n" ));
237
+ 0 , 55 ,
238
+ getMeteoconIconFromProgmem (displayCurrent ? currentWeather.icon : " 01n" ));
232
239
233
240
gfx.setFont (ArialRoundedMTBold_14);
234
241
gfx.setColor (MINI_BLUE);
235
242
gfx.setTextAlignment (TEXT_ALIGN_RIGHT);
236
- gfx.drawString (220 , 65 , displayCurrent ? OPEN_WEATHER_DISPLAYED_CITY_NAME : " Inside" );
243
+ gfx.drawString (220 , 65 ,
244
+ displayCurrent ? OPEN_WEATHER_DISPLAYED_CITY_NAME : " Inside" );
237
245
238
246
gfx.setFont (ArialRoundedMTBold_36);
239
247
gfx.setColor (MINI_WHITE);
240
248
gfx.setTextAlignment (TEXT_ALIGN_RIGHT);
241
249
242
- gfx.drawString (220 , 78 , String (displayCurrent ? currentWeather.temp : insideTemp, 1 ) + (IS_METRIC ? " °C" : " °F" ));
250
+ gfx.drawString (220 , 78 ,
251
+ String (displayCurrent ? currentWeather.temp : insideTemp, 1 ) +
252
+ (IS_METRIC ? " °C" : " °F" ));
243
253
244
254
if (displayCurrent) {
245
255
gfx.setFont (ArialRoundedMTBold_14);
@@ -351,17 +361,18 @@ void updateData() {
351
361
352
362
if (currentUpdate) {
353
363
drawProgress (50 , F (" Updating conditions..." ));
354
- currentWeatherClient.updateCurrentById (
364
+ currentUpdate = ! currentWeatherClient.updateCurrentById (
355
365
¤tWeather, owApiKey.get (), OPEN_WEATHER_MAP_LOCATION_ID);
356
- currentUpdate = false ;
366
+ Homie.getLogger () << F (" Current Forecast Successful? " )
367
+ << (currentUpdate ? F (" False" ) : F (" True" )) << endl;
357
368
}
358
369
359
370
if (forecastUpdate) {
360
371
drawProgress (70 , F (" Updating forecasts..." ));
361
- forecastClient.updateForecastsById (forecasts, owApiKey. get (),
362
- OPEN_WEATHER_MAP_LOCATION_ID,
363
- MAX_FORECASTS);
364
- forecastUpdate = false ;
372
+ forecastUpdate = ! forecastClient.updateForecastsById (
373
+ forecasts, owApiKey. get (), OPEN_WEATHER_MAP_LOCATION_ID, MAX_FORECASTS);
374
+ Homie. getLogger () << F ( " Forcast Update Successful? " )
375
+ << ( forecastUpdate ? F ( " False " ) : F ( " True " )) << endl ;
365
376
}
366
377
367
378
if (astronomyUpdate) {
0 commit comments