@@ -5,6 +5,7 @@ bool otaInitialDrawDone = false;
5
5
uint8_t otaState = 0 ;
6
6
uint8_t otaProgress = 0 ;
7
7
8
+ float insideTemp = 0 ;
8
9
uint32_t currTempRotateTime = 0 ;
9
10
10
11
bool initialUpdate = false ;
@@ -31,9 +32,9 @@ void initialize() {
31
32
void temperatureLoop () {
32
33
if (millis () - lastTemperatureSent >= TEMPERATURE_UPDATE * 1000 || lastTemperatureSent == 0 ) {
33
34
sensors.requestTemperatures ();
34
- float temp = sensors.getTempCByIndex (0 );
35
- Homie.getLogger () << F (" Temperature: " ) << temp << endl;
36
- temperatureNode.setProperty (" degrees" ).send (String (temp ));
35
+ insideTemp = sensors.getTempCByIndex (0 );
36
+ Homie.getLogger () << F (" Temperature: " ) << insideTemp << endl;
37
+ temperatureNode.setProperty (" degrees" ).send (String (insideTemp ));
37
38
lastTemperatureSent = millis ();
38
39
}
39
40
}
@@ -64,7 +65,7 @@ void setup() {
64
65
uint8_t allowedHours[] = {12 , 0 };
65
66
forecastClient.setAllowedHours (allowedHours, sizeof (allowedHours));
66
67
67
- Homie_setFirmware (" weather-station" , " 0.0.1 " );
68
+ Homie_setFirmware (" weather-station" , " 0.0.2 " );
68
69
Homie_setBrand (" IoT" );
69
70
Homie.onEvent (onHomieEvent);
70
71
Homie.setSetupFunction (initialize);
@@ -78,6 +79,9 @@ void onHomieEvent(const HomieEvent &event) {
78
79
bootMode = HomieBootMode::NORMAL;
79
80
break ;
80
81
case HomieEventType::OTA_STARTED:
82
+ updateCurrentTicker.detach ();
83
+ updateForecastTicker.detach ();
84
+ updateAstronomyTicker.detach ();
81
85
otaState = 1 ;
82
86
break ;
83
87
case HomieEventType::OTA_SUCCESSFUL:
@@ -218,26 +222,31 @@ void drawProgress(uint8_t percentage, String text) {
218
222
}
219
223
220
224
void drawCurrentWeather () {
225
+ // Rotate every 10 seconds
226
+ bool displayCurrent = millis () - currTempRotateTime < 10 * 1000 ;
227
+ if (millis () - currTempRotateTime > 20 * 1000 ) currTempRotateTime = millis ();
228
+
221
229
gfx.setTransparentColor (MINI_BLACK);
222
230
gfx.drawPalettedBitmapFromPgm (
223
- 0 , 55 , getMeteoconIconFromProgmem (currentWeather.icon ));
231
+ 0 , 55 , getMeteoconIconFromProgmem (displayCurrent ? currentWeather.icon : " 01n " ));
224
232
225
233
gfx.setFont (ArialRoundedMTBold_14);
226
234
gfx.setColor (MINI_BLUE);
227
235
gfx.setTextAlignment (TEXT_ALIGN_RIGHT);
228
- gfx.drawString (220 , 65 , OPEN_WEATHER_DISPLAYED_CITY_NAME);
236
+ gfx.drawString (220 , 65 , displayCurrent ? OPEN_WEATHER_DISPLAYED_CITY_NAME : " Inside " );
229
237
230
238
gfx.setFont (ArialRoundedMTBold_36);
231
239
gfx.setColor (MINI_WHITE);
232
240
gfx.setTextAlignment (TEXT_ALIGN_RIGHT);
233
241
234
- gfx.drawString (220 , 78 ,
235
- String (currentWeather.temp , 1 ) + (IS_METRIC ? " °C" : " °F" ));
242
+ gfx.drawString (220 , 78 , String (displayCurrent ? currentWeather.temp : insideTemp, 1 ) + (IS_METRIC ? " °C" : " °F" ));
236
243
237
- gfx.setFont (ArialRoundedMTBold_14);
238
- gfx.setColor (MINI_YELLOW);
239
- gfx.setTextAlignment (TEXT_ALIGN_RIGHT);
240
- gfx.drawString (220 , 118 , currentWeather.description );
244
+ if (displayCurrent) {
245
+ gfx.setFont (ArialRoundedMTBold_14);
246
+ gfx.setColor (MINI_YELLOW);
247
+ gfx.setTextAlignment (TEXT_ALIGN_RIGHT);
248
+ gfx.drawString (220 , 118 , currentWeather.description );
249
+ }
241
250
}
242
251
243
252
void drawForecast1 (MiniGrafx *display, CarouselState *state, int16_t x,
0 commit comments