Hintergrund-Farbe, Wertanzeige znd Version angepasst

This commit is contained in:
rxf
2024-07-11 23:22:24 +02:00
parent 68779b8f6a
commit 8414ceb404
3 changed files with 33 additions and 21 deletions

View File

@@ -16,6 +16,7 @@ void setup_grafik(void) {
lv_init(); lv_init();
lv_display_t * disp; lv_display_t * disp;
disp = lv_tft_espi_create(SCREEN_WIDTH, SCREEN_HEIGHT, draw_buf, sizeof(draw_buf)); disp = lv_tft_espi_create(SCREEN_WIDTH, SCREEN_HEIGHT, draw_buf, sizeof(draw_buf));
for (int i = 0; i < MAXREADINGS; i++) { for (int i = 0; i < MAXREADINGS; i++) {
bmewert[i] = 0; bmewert[i] = 0;
bmewert_hum[i] = 30; bmewert_hum[i] = 30;
@@ -53,7 +54,7 @@ void buildarc(ARC arc) {
sprintf(value, arc.valformat, arc.value); sprintf(value, arc.valformat, arc.value);
// Serial.println(value); // Serial.println(value);
lv_label_set_text(value_label, 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; static lv_style_t style_value_label;
lv_style_init(&style_value_label); lv_style_init(&style_value_label);
lv_style_set_text_font(&style_value_label, &lv_font_montserrat_18); 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_style_set_text_font(&style_high_label, &lv_font_montserrat_10);
lv_obj_add_style(high_label, &style_high_label, 0); 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_label_set_text(unit_label, arc.unit);
lv_obj_align(unit_label, LV_ALIGN_LEFT_MID, 48, 8); lv_obj_align(unit_label, LV_ALIGN_LEFT_MID, 48, 8);
static lv_style_t style_unit_label; static lv_style_t style_unit_label;
lv_style_init(&style_unit_label); lv_style_init(&style_unit_label);
lv_style_set_text_font(&style_unit_label, &lv_font_montserrat_12); lv_style_set_text_font(&style_unit_label, &lv_font_montserrat_12);
lv_obj_add_style(unit_label, &style_unit_label, 0); lv_obj_add_style(unit_label, &style_unit_label, 0);
*/
} }
void lv_create_main_gui(void) { void lv_create_main_gui(void) {
// Create a text label aligned on top: https://docs.lvgl.io/master/widgets/label.html // Create a text label aligned on top: https://docs.lvgl.io/master/widgets/label.html
time_label = lv_label_create(lv_screen_active()); time_label = lv_label_create(lv_screen_active());
lv_label_set_text(time_label, "17:30"); lv_label_set_text(time_label, "17:30");
@@ -137,6 +139,9 @@ void lv_create_main_gui(void) {
arcHum.arc = aHum; arcHum.arc = aHum;
buildarc(arcHum); buildarc(arcHum);
lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0xADD8E6), LV_PART_MAIN);
} }
void setValuetoArc(ARC arc, float value) { void setValuetoArc(ARC arc, float value) {
@@ -149,17 +154,19 @@ void setValuetoArc(ARC arc, float value) {
sprintf(valuestr, arc.valformat, value); sprintf(valuestr, arc.valformat, value);
lv_label_set_text(value_label, valuestr); lv_label_set_text(value_label, valuestr);
if (value < arc.green) 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); {
} lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_GREEN), LV_PART_INDICATOR);
else if (value < arc.yellow) }
{ else if (value < arc.yellow)
lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_INDICATOR); {
} lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_YELLOW), LV_PART_INDICATOR);
else }
{ else
lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_RED), LV_PART_INDICATOR); {
lv_obj_set_style_arc_color(arc.arc, lv_palette_main(LV_PALETTE_RED), LV_PART_INDICATOR);
}
} }
} }
#define CONTAINER_WIDTH SCREEN_WIDTH #define CONTAINER_WIDTH SCREEN_WIDTH
@@ -182,8 +189,11 @@ void setValuetoArc(ARC arc, float value) {
lv_obj_set_scrollbar_mode(container_row, LV_SCROLLBAR_MODE_OFF); lv_obj_set_scrollbar_mode(container_row, LV_SCROLLBAR_MODE_OFF);
static lv_style_t style_container_row; static lv_style_t style_container_row;
lv_style_set_pad_row(&style_container_row, 0); 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_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_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 // linke Axe
lv_obj_t * scaleT = lv_scale_create(container_row); 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_init(&style_scaleT);
lv_style_set_text_font(&style_scaleT, &lv_font_montserrat_10); 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_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); 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_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_scrollbar_mode(chart, LV_SCROLLBAR_MODE_OFF);
lv_obj_set_style_border_width(chart, 0, LV_PART_MAIN); // No border 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 // lv_obj_set_style_pad_right(chart, -10, LV_PART_MAIN); // No border
/*Add data series*/ /*Add data series*/
lv_chart_series_t * ser1 = lv_chart_add_series(chart, lv_palette_main(LV_PALETTE_BLUE), LV_CHART_AXIS_PRIMARY_Y); 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, 0, LV_PART_ITEMS);
lv_obj_set_style_line_width(scale, 1, LV_PART_INDICATOR); 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_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); lv_scale_set_range(scale, 40, 100);
static lv_style_t style_scale; static lv_style_t style_scale;

View File

@@ -26,9 +26,7 @@ typedef struct {
int highvalue; int highvalue;
int green; int green;
int yellow; int yellow;
lv_style_t style_arc; int value_offset;
lv_style_t style_label;
lv_style_t lv_style_value_label;
} ARC; } ARC;
@@ -39,8 +37,8 @@ typedef struct {
#ifdef MAIN #ifdef MAIN
ARC arcTemp = {NULL, "temp", 40, -1, 110, 30.0, "%.1f", "°C", 10, 30, 20, 25}; 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}; ARC arcHum = {NULL, "humi", 170, -1, 110, 60.0, "%.0f%%", "%", 40, 100, 65, 70, 2};
lv_obj_t * date_label; lv_obj_t * date_label;
lv_obj_t * time_label; lv_obj_t * time_label;
#else #else

View File

@@ -6,7 +6,7 @@ extern "C" {
#include "freertos/timers.h" #include "freertos/timers.h"
} }
#define VERSION "1.0.0" #define VERSION "1.1.0"
#define VDATE "2024-07-11" #define VDATE "2024-07-11"
//#define MAXREADINGS 224 //#define MAXREADINGS 224