@@ -74,38 +74,32 @@ Weather::Weather(Controllers::Settings& settingsController, Controllers::SimpleW
74
74
// LV_TABLE_PART_CELL1: Default table style
75
75
lv_obj_set_style_local_border_color (forecast, LV_TABLE_PART_CELL1, LV_STATE_DEFAULT, LV_COLOR_BLACK);
76
76
lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL1, LV_STATE_DEFAULT, Colors::lightGray);
77
- lv_obj_set_style_local_pad_right (forecast, LV_TABLE_PART_CELL1, LV_STATE_DEFAULT, 6 );
78
77
// LV_TABLE_PART_CELL2: Condition icon
79
78
lv_obj_set_style_local_border_color (forecast, LV_TABLE_PART_CELL2, LV_STATE_DEFAULT, LV_COLOR_BLACK);
80
79
lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL2, LV_STATE_DEFAULT, LV_COLOR_WHITE);
81
80
lv_obj_set_style_local_text_font (forecast, LV_TABLE_PART_CELL2, LV_STATE_DEFAULT, &fontawesome_weathericons);
82
- lv_obj_set_style_local_pad_right (forecast, LV_TABLE_PART_CELL2, LV_STATE_DEFAULT, 6 );
83
81
// LV_TABLE_PART_CELL3: Freezing
84
82
lv_obj_set_style_local_border_color (forecast, LV_TABLE_PART_CELL3, LV_STATE_DEFAULT, LV_COLOR_BLACK);
85
83
lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL3, LV_STATE_DEFAULT, Colors::blue);
86
- lv_obj_set_style_local_pad_right (forecast, LV_TABLE_PART_CELL3, LV_STATE_DEFAULT, 6 );
87
84
// LV_TABLE_PART_CELL4: Ice
88
85
lv_obj_set_style_local_border_color (forecast, LV_TABLE_PART_CELL4, LV_STATE_DEFAULT, LV_COLOR_BLACK);
89
86
lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL4, LV_STATE_DEFAULT, LV_COLOR_CYAN);
90
- lv_obj_set_style_local_pad_right (forecast, LV_TABLE_PART_CELL4, LV_STATE_DEFAULT, 6 );
91
87
// LV_TABLE_PART_CELL5: Normal
92
88
lv_obj_set_style_local_border_color (forecast, LV_TABLE_PART_CELL5, LV_STATE_DEFAULT, LV_COLOR_BLACK);
93
89
lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL5, LV_STATE_DEFAULT, Colors::orange);
94
- lv_obj_set_style_local_pad_right (forecast, LV_TABLE_PART_CELL5, LV_STATE_DEFAULT, 6 );
95
90
// LV_TABLE_PART_CELL6: Hot
96
91
lv_obj_set_style_local_border_color (forecast, LV_TABLE_PART_CELL6, LV_STATE_DEFAULT, LV_COLOR_BLACK);
97
92
lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL6, LV_STATE_DEFAULT, Colors::deepOrange);
98
- lv_obj_set_style_local_pad_right (forecast, LV_TABLE_PART_CELL6, LV_STATE_DEFAULT, 6 );
99
93
100
94
lv_obj_align (forecast, nullptr , LV_ALIGN_IN_BOTTOM_LEFT, 0 , 0 );
101
95
102
96
for (int i = 0 ; i < Controllers::SimpleWeatherService::MaxNbForecastDays; i++) {
103
97
lv_table_set_col_width (forecast, i, 48 );
104
98
lv_table_set_cell_type (forecast, 1 , i, LV_TABLE_PART_CELL2);
105
- lv_table_set_cell_align (forecast, 0 , i, LV_LABEL_ALIGN_RIGHT );
106
- lv_table_set_cell_align (forecast, 1 , i, LV_LABEL_ALIGN_RIGHT );
107
- lv_table_set_cell_align (forecast, 2 , i, LV_LABEL_ALIGN_RIGHT );
108
- lv_table_set_cell_align (forecast, 3 , i, LV_LABEL_ALIGN_RIGHT );
99
+ lv_table_set_cell_align (forecast, 0 , i, LV_LABEL_ALIGN_CENTER );
100
+ lv_table_set_cell_align (forecast, 1 , i, LV_LABEL_ALIGN_CENTER );
101
+ lv_table_set_cell_align (forecast, 2 , i, LV_LABEL_ALIGN_CENTER );
102
+ lv_table_set_cell_align (forecast, 3 , i, LV_LABEL_ALIGN_CENTER );
109
103
}
110
104
111
105
taskRefresh = lv_task_create (RefreshTaskCallback, 1000 , LV_TASK_PRIO_MID, this );
@@ -175,8 +169,19 @@ void Weather::Refresh() {
175
169
const char * dayOfWeek = Controllers::DateTime::DayOfWeekShortToStringLow (static_cast <Controllers::DateTime::Days>(wday));
176
170
lv_table_set_cell_value (forecast, 0 , i, dayOfWeek);
177
171
lv_table_set_cell_value (forecast, 1 , i, Symbols::GetSymbol (optCurrentForecast->days [i].iconId ));
178
- lv_table_set_cell_value_fmt (forecast, 2 , i, " %d" , maxTemp);
179
- lv_table_set_cell_value_fmt (forecast, 3 , i, " %d" , minTemp);
172
+ // Pad cells based on the largest number of digits on each column
173
+ char maxPadding[3 ] = " " ;
174
+ char minPadding[3 ] = " " ;
175
+ int diff = snprintf (nullptr , 0 , " %d" , maxTemp) - snprintf (nullptr , 0 , " %d" , minTemp);
176
+ if (diff <= 0 ) {
177
+ maxPadding[-diff] = ' \0 ' ;
178
+ minPadding[0 ] = ' \0 ' ;
179
+ } else {
180
+ maxPadding[0 ] = ' \0 ' ;
181
+ minPadding[diff] = ' \0 ' ;
182
+ }
183
+ lv_table_set_cell_value_fmt (forecast, 2 , i, " %s%d" , maxPadding, maxTemp);
184
+ lv_table_set_cell_value_fmt (forecast, 3 , i, " %s%d" , minPadding, minTemp);
180
185
}
181
186
} else {
182
187
for (int i = 0 ; i < Controllers::SimpleWeatherService::MaxNbForecastDays; i++) {
0 commit comments