@@ -49,7 +49,7 @@ Weather::Weather(Controllers::Settings& settingsController,
49
49
50
50
lastUpdated = lv_label_create (lv_scr_act (), nullptr );
51
51
lv_obj_set_style_local_text_color (lastUpdated, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::bg);
52
- lv_label_set_text_fmt (lastUpdated, " " );
52
+ lv_label_set_text (lastUpdated, " " );
53
53
54
54
minTemperature = lv_label_create (lv_scr_act (), nullptr );
55
55
lv_obj_set_style_local_text_color (minTemperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::bg);
@@ -150,20 +150,30 @@ void Weather::Refresh() {
150
150
int8_t minutesSinceWeatherUpdate = secondsSinceWeatherUpdate / 60 ;
151
151
int8_t hoursSinceWeatherUpdate = secondsSinceWeatherUpdate / 3600 ;
152
152
153
- lv_obj_align (lastUpdated, nullptr , LV_ALIGN_CENTER, -31 , -1 );
154
- if ((secondsSinceWeatherUpdate > 9 && secondsSinceWeatherUpdate < 60 ) ||
155
- (minutesSinceWeatherUpdate > 9 && minutesSinceWeatherUpdate < 60 ) || hoursSinceWeatherUpdate > 9 ) {
156
- lv_obj_align (lastUpdated, nullptr , LV_ALIGN_CENTER, -41 , -1 );
157
- }
153
+ constexpr uint8_t Y_POSITION = 108 ;
154
+ constexpr uint8_t X_SINGLE_DIGIT_POSITION = 90 ;
155
+ constexpr uint8_t X_TWO_DIGIT_POSITION = 78 ;
156
+ constexpr uint8_t X_NOW_POSITION = 102 ;
157
+
158
+ lv_obj_set_pos (lastUpdated, X_SINGLE_DIGIT_POSITION, Y_POSITION);
158
159
159
160
if (hoursSinceWeatherUpdate > 0 ) {
161
+ if (hoursSinceWeatherUpdate > 9 ) {
162
+ lv_obj_set_pos (lastUpdated, X_TWO_DIGIT_POSITION, Y_POSITION);
163
+ }
160
164
lv_label_set_text_fmt (lastUpdated, " %dh ago" , hoursSinceWeatherUpdate);
161
165
} else if (minutesSinceWeatherUpdate > 0 ) {
166
+ if (minutesSinceWeatherUpdate > 9 && minutesSinceWeatherUpdate < 60 ) {
167
+ lv_obj_set_pos (lastUpdated, X_TWO_DIGIT_POSITION, Y_POSITION);
168
+ }
162
169
lv_label_set_text_fmt (lastUpdated, " %dm ago" , minutesSinceWeatherUpdate);
163
170
} else if (secondsSinceWeatherUpdate > 30 ) {
171
+ if (secondsSinceWeatherUpdate > 9 && secondsSinceWeatherUpdate < 60 ) {
172
+ lv_obj_set_pos (lastUpdated, X_TWO_DIGIT_POSITION, Y_POSITION);
173
+ }
164
174
lv_label_set_text_fmt (lastUpdated, " %ds ago" , secondsSinceWeatherUpdate);
165
175
} else if (secondsSinceWeatherUpdate < 31 ) {
166
- lv_obj_align (lastUpdated, nullptr , LV_ALIGN_CENTER, - 18 , - 1 );
176
+ lv_obj_set_pos (lastUpdated, X_NOW_POSITION, Y_POSITION );
167
177
lv_label_set_text_fmt (lastUpdated, " Now" , secondsSinceWeatherUpdate);
168
178
}
169
179
} else {
0 commit comments