From 8414ceb4045fb4cbc23eebf7de438bbe29d9fb3e Mon Sep 17 00:00:00 2001 From: rxf Date: Thu, 11 Jul 2024 23:22:24 +0200 Subject: [PATCH] Hintergrund-Farbe, Wertanzeige znd Version angepasst --- src/grafik.cpp | 44 +++++++++++++++++++++++++++++--------------- src/grafik.h | 8 +++----- src/main.h | 2 +- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/grafik.cpp b/src/grafik.cpp index 1f7b787..2cbcbbf 100644 --- a/src/grafik.cpp +++ b/src/grafik.cpp @@ -16,6 +16,7 @@ void setup_grafik(void) { lv_init(); lv_display_t * disp; disp = lv_tft_espi_create(SCREEN_WIDTH, SCREEN_HEIGHT, draw_buf, sizeof(draw_buf)); + for (int i = 0; i < MAXREADINGS; i++) { bmewert[i] = 0; bmewert_hum[i] = 30; @@ -53,7 +54,7 @@ void buildarc(ARC arc) { sprintf(value, arc.valformat, arc.value); // Serial.println(value); lv_label_set_text(value_label, value); - lv_obj_align(value_label, LV_ALIGN_LEFT_MID, 38, -10); + lv_obj_align(value_label, LV_ALIGN_LEFT_MID, 38 + arc.value_offset, 0); static lv_style_t style_value_label; lv_style_init(&style_value_label); lv_style_set_text_font(&style_value_label, &lv_font_montserrat_18); @@ -69,17 +70,18 @@ void buildarc(ARC arc) { lv_style_set_text_font(&style_high_label, &lv_font_montserrat_10); lv_obj_add_style(high_label, &style_high_label, 0); - lv_obj_t * unit_label = lv_label_create(arc.arc); +/* lv_obj_t * unit_label = lv_label_create(arc.arc); lv_label_set_text(unit_label, arc.unit); lv_obj_align(unit_label, LV_ALIGN_LEFT_MID, 48, 8); static lv_style_t style_unit_label; lv_style_init(&style_unit_label); lv_style_set_text_font(&style_unit_label, &lv_font_montserrat_12); lv_obj_add_style(unit_label, &style_unit_label, 0); - +*/ } void lv_create_main_gui(void) { + // Create a text label aligned on top: https://docs.lvgl.io/master/widgets/label.html time_label = lv_label_create(lv_screen_active()); lv_label_set_text(time_label, "17:30"); @@ -137,6 +139,9 @@ void lv_create_main_gui(void) { arcHum.arc = aHum; buildarc(arcHum); + lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0xADD8E6), LV_PART_MAIN); + + } void setValuetoArc(ARC arc, float value) { @@ -149,18 +154,20 @@ void setValuetoArc(ARC arc, float value) { sprintf(valuestr, arc.valformat, value); lv_label_set_text(value_label, valuestr); - if (value < arc.green) - { - lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_GREEN), LV_PART_INDICATOR); - } - else if (value < arc.yellow) - { - lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_INDICATOR); - } - else - { - lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_RED), LV_PART_INDICATOR); - } + if( strcmp(arc.name, "humi") == 0) { + if (value < arc.green) + { + lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_GREEN), LV_PART_INDICATOR); + } + else if (value < arc.yellow) + { + lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_INDICATOR); + } + else + { + lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_RED), LV_PART_INDICATOR); + } + } } #define CONTAINER_WIDTH SCREEN_WIDTH #define CONTAINER_HEIGHT SCREEN_HEIGHT-145 @@ -182,8 +189,11 @@ void setValuetoArc(ARC arc, float value) { lv_obj_set_scrollbar_mode(container_row, LV_SCROLLBAR_MODE_OFF); static lv_style_t style_container_row; lv_style_set_pad_row(&style_container_row, 0); + //lv_style_set_bg_color(&style_container_row, lv_palette_lighten(LV_PALETTE_LIGHT_BLUE, 4)); lv_obj_add_style(container_row, &style_container_row, 0); lv_obj_set_style_border_side(container_row, LV_BORDER_SIDE_BOTTOM, LV_PART_MAIN); + lv_obj_set_style_bg_color(container_row, lv_color_hex(0xADD8E6), LV_PART_MAIN); + // linke Axe lv_obj_t * scaleT = lv_scale_create(container_row); @@ -208,6 +218,7 @@ void setValuetoArc(ARC arc, float value) { lv_style_init(&style_scaleT); lv_style_set_text_font(&style_scaleT, &lv_font_montserrat_10); lv_style_set_text_color(&style_scaleT, lv_color_hex(0x0000FF)); +// lv_style_set_bg_color(&style_scaleT, lv_color_hex(0xFF00FF)); lv_obj_add_style(scaleT, &style_scaleT, 0); @@ -223,6 +234,8 @@ void setValuetoArc(ARC arc, float value) { lv_obj_set_style_size(chart, 0, 0, LV_PART_INDICATOR); // No points on line lv_obj_set_scrollbar_mode(chart, LV_SCROLLBAR_MODE_OFF); lv_obj_set_style_border_width(chart, 0, LV_PART_MAIN); // No border + lv_obj_set_style_bg_color(chart, lv_color_hex(0xADD8E6), LV_PART_MAIN); + // lv_obj_set_style_pad_right(chart, -10, LV_PART_MAIN); // No border /*Add data series*/ lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_BLUE), LV_CHART_AXIS_PRIMARY_Y); @@ -250,6 +263,7 @@ void setValuetoArc(ARC arc, float value) { lv_obj_set_style_line_width(scale, 0, LV_PART_ITEMS); lv_obj_set_style_line_width(scale, 1, LV_PART_INDICATOR); lv_obj_set_style_line_width(scale, 0, LV_PART_MAIN); + lv_obj_set_style_bg_color(scale, lv_color_hex(0xADD8E6), LV_PART_MAIN); lv_scale_set_range(scale, 40, 100); static lv_style_t style_scale; diff --git a/src/grafik.h b/src/grafik.h index 9f17f55..c7adf17 100644 --- a/src/grafik.h +++ b/src/grafik.h @@ -26,9 +26,7 @@ typedef struct { int highvalue; int green; int yellow; - lv_style_t style_arc; - lv_style_t style_label; - lv_style_t lv_style_value_label; + int value_offset; } ARC; @@ -39,8 +37,8 @@ typedef struct { #ifdef MAIN -ARC arcTemp = {NULL, "temp", 40, -1, 110, 30.0, "%.1f", "°C", 10, 30, 20, 25}; -ARC arcHum = {NULL, "humi", 170, -1, 110, 60.0, "%.0f", "%", 40, 100, 65, 70}; +ARC arcTemp = {NULL, "temp", 40, -1, 110, 30.0, "%.1f°C", "°C", 10, 30, 20, 25, -11}; +ARC arcHum = {NULL, "humi", 170, -1, 110, 60.0, "%.0f%%", "%", 40, 100, 65, 70, 2}; lv_obj_t * date_label; lv_obj_t * time_label; #else diff --git a/src/main.h b/src/main.h index d4d1908..b20a061 100644 --- a/src/main.h +++ b/src/main.h @@ -6,7 +6,7 @@ extern "C" { #include "freertos/timers.h" } -#define VERSION "1.0.0" +#define VERSION "1.1.0" #define VDATE "2024-07-11" //#define MAXREADINGS 224