mirror of
https://github.com/skoelle/wt32sc01-dashboard.git
synced 2026-09-18 09:50:25 +00:00
calender and weather UI updates
This commit is contained in:
@@ -25,42 +25,67 @@ void buildList() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Header row with current conditions.
|
||||
String header = String(lastWeather.current.temperature) + " C " +
|
||||
sanitizeGermanText(lastWeather.current.description);
|
||||
lv_obj_t *h = lv_label_create(list);
|
||||
lv_label_set_text(h, header.c_str());
|
||||
lv_obj_set_style_text_font(h, &lv_font_montserrat_20, 0);
|
||||
lv_obj_set_style_text_color(h, Theme::text(), 0);
|
||||
// Header row with column titles.
|
||||
lv_obj_t *header = lv_label_create(list);
|
||||
lv_label_set_text(header, "Icon Uhrzeit Grad Text Regen %");
|
||||
lv_obj_set_style_text_font(header, &lv_font_montserrat_12, 0);
|
||||
lv_obj_set_style_text_color(header, Theme::text(), 0);
|
||||
|
||||
// Separator line below header.
|
||||
lv_obj_t *header_line = lv_line_create(list);
|
||||
static lv_point_t header_points[] = {{0, 0}, {280, 0}};
|
||||
lv_line_set_points(header_line, header_points, 2);
|
||||
lv_obj_set_style_line_color(header_line, Theme::textDim(), 0);
|
||||
lv_obj_set_style_line_width(header_line, 1, 0);
|
||||
|
||||
for (const auto &fe : lastWeather.forecast) {
|
||||
lv_obj_t *row = lv_obj_create(list);
|
||||
lv_obj_set_size(row, 280, LV_SIZE_CONTENT);
|
||||
lv_obj_set_size(row, 280, 30);
|
||||
lv_obj_set_style_bg_opa(row, LV_OPA_TRANSP, 0);
|
||||
lv_obj_set_style_border_width(row, 0, 0);
|
||||
lv_obj_set_style_pad_all(row, 6, 0);
|
||||
lv_obj_set_style_pad_all(row, 4, 0);
|
||||
lv_obj_clear_flag(row, LV_OBJ_FLAG_SCROLLABLE);
|
||||
|
||||
// time hh:mm
|
||||
int tIdx = fe.time.indexOf('T');
|
||||
String hhmm = tIdx > 0 ? fe.time.substring(tIdx + 1, tIdx + 6) : fe.time;
|
||||
|
||||
String left = hhmm + " " + String(fe.temperature) + "C";
|
||||
lv_obj_t *l = lv_label_create(row);
|
||||
lv_label_set_text(l, left.c_str());
|
||||
lv_obj_set_style_text_color(l, Theme::text(), 0);
|
||||
lv_obj_align(l, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
// icon - use weather symbol
|
||||
lv_obj_t *icon = Icons::createWeatherIcon(row, fe.symbol, fe.description, 24);
|
||||
|
||||
String desc = sanitizeGermanText(fe.description.substring(0, 16));
|
||||
// time column
|
||||
lv_obj_t *time_label = lv_label_create(row);
|
||||
lv_label_set_text(time_label, hhmm.c_str());
|
||||
lv_obj_set_style_text_color(time_label, Theme::text(), 0);
|
||||
lv_obj_align(time_label, LV_ALIGN_TOP_LEFT, 44, 0);
|
||||
|
||||
// degree column
|
||||
lv_obj_t *temp_label = lv_label_create(row);
|
||||
lv_label_set_text(temp_label, String(fe.temperature) + "C");
|
||||
lv_obj_set_style_text_color(temp_label, Theme::text(), 0);
|
||||
lv_obj_align(temp_label, LV_ALIGN_TOP_LEFT, 160, 0);
|
||||
|
||||
// text column
|
||||
String desc = sanitizeGermanText(fe.description.substring(0, 20));
|
||||
if (fe.precipitationType == "rain" && fe.precipitationProbability > 0.0f) {
|
||||
char buf[8];
|
||||
snprintf(buf, sizeof(buf), " %.0f%%", fe.precipitationProbability * 100);
|
||||
desc += buf;
|
||||
}
|
||||
lv_obj_t *d = lv_label_create(row);
|
||||
lv_label_set_text(d, desc.c_str());
|
||||
lv_obj_set_style_text_color(d, Theme::textDim(), 0);
|
||||
lv_obj_align(d, LV_ALIGN_TOP_LEFT, 0, 18);
|
||||
lv_obj_t *desc_label = lv_label_create(row);
|
||||
lv_label_set_text(desc_label, desc.c_str());
|
||||
lv_obj_set_style_text_color(desc_label, Theme::textDim(), 0);
|
||||
lv_obj_align(desc_label, LV_ALIGN_TOP_LEFT, 220, 0);
|
||||
|
||||
// rain probability column - show percentage for rain
|
||||
if (fe.precipitationType == "rain" && fe.precipitationProbability > 0.0f) {
|
||||
char buf[8];
|
||||
snprintf(buf, sizeof(buf), "%.0f%%", fe.precipitationProbability * 100);
|
||||
lv_obj_t *rain_label = lv_label_create(row);
|
||||
lv_label_set_text(rain_label, buf);
|
||||
lv_obj_set_style_text_color(rain_label, Theme::accentRain(), 0);
|
||||
lv_obj_align(rain_label, LV_ALIGN_TOP_LEFT, 260, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user