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