MQTT nun mit PubSub

Grafik etwas angepasst
This commit is contained in:
rxf
2024-08-19 17:23:13 +02:00
parent 3c170a1f69
commit eb1a102120
7 changed files with 145 additions and 146 deletions

View File

@@ -31,7 +31,7 @@ void buildarc(ARC arc)
lv_obj_set_size(arc.arc, arc.size, arc.size);
lv_arc_set_rotation(arc.arc, 180);
lv_arc_set_bg_angles(arc.arc, 0, 180);
lv_arc_set_value(arc.arc, arc.value);
lv_arc_set_value(arc.arc, arc.value+arc.value_offset);
lv_obj_align(arc.arc, LV_ALIGN_LEFT_MID, arc.x, arc.y);
lv_obj_remove_style(arc.arc, NULL, LV_PART_KNOB);
@@ -55,10 +55,10 @@ void buildarc(ARC arc)
lv_obj_t *value_label = lv_label_create(arc.arc);
char value[10];
sprintf(value, arc.valformat, arc.value);
sprintf(value, arc.valformat, arc.value + arc.value_offset);
// Serial.println(value);
lv_label_set_text(value_label, value);
lv_obj_align(value_label, LV_ALIGN_LEFT_MID, 38 + arc.value_offset, 0);
lv_obj_align(value_label, LV_ALIGN_LEFT_MID, 38 + arc.value_xoffset, 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);
@@ -141,27 +141,6 @@ void lv_create_main_gui(void)
lv_obj_align(refresh_label, LV_ALIGN_CENTER, 0, -45);
*/
// Text als Überschrift an die Axen
lv_obj_t *feuchte_label = lv_label_create(lv_screen_active());
lv_label_set_text(feuchte_label, "Feuchte");
lv_obj_align(feuchte_label, LV_ALIGN_RIGHT_MID, -3, 15);
// Set font type and font size. More information: https://docs.lvgl.io/master/overview/font.html
static lv_style_t style_feuchte_label;
lv_style_init(&style_feuchte_label);
lv_style_set_text_font(&style_feuchte_label, &lv_font_montserrat_10);
lv_obj_add_style(feuchte_label, &style_feuchte_label, 0);
lv_obj_t *temp_label = lv_label_create(lv_screen_active());
lv_label_set_text(temp_label, "Temperatur");
lv_obj_align(temp_label, LV_ALIGN_LEFT_MID, 3, 15);
// Set font type and font size. More information: https://docs.lvgl.io/master/overview/font.html
static lv_style_t style_temp_label;
lv_style_init(&style_temp_label);
lv_style_set_text_font(&style_temp_label, &lv_font_montserrat_10);
lv_obj_add_style(temp_label, &style_temp_label, 0);
/*Create an Arc*/
lv_obj_t *aTemp = lv_arc_create(lv_screen_active());
arcTemp.arc = aTemp;
@@ -220,7 +199,7 @@ void drawChart()
// Create a container to display the chart and scale
lv_obj_t *container_row = lv_obj_create(lv_screen_active());
lv_obj_set_size(container_row, CONTAINER_WIDTH, CONTAINER_HEIGHT);
lv_obj_align(container_row, LV_ALIGN_BOTTOM_MID, 0, 0);
lv_obj_align(container_row, LV_ALIGN_BOTTOM_MID, 0, -4);
// Set the container in a flexbox row layout aligned center
lv_obj_set_flex_flow(container_row, LV_FLEX_FLOW_ROW);
lv_obj_set_flex_align(container_row, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER);
@@ -229,7 +208,7 @@ void drawChart()
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_border_side(container_row, LV_BORDER_SIDE_NONE, LV_PART_MAIN);
lv_obj_set_style_bg_color(container_row, lv_color_hex(BACKGROUND_COLOR), LV_PART_MAIN);
// linke Axe
@@ -335,6 +314,21 @@ void drawChart()
lv_style_set_text_color(&style_xscale, lv_color_hex(0x0000FF));
lv_obj_add_style(xscale, &style_xscale, 0);
// Text als Überschrift an die Axen
lv_obj_t *feuchte_label = lv_label_create(lv_screen_active());
lv_label_set_text(feuchte_label, "Feuchte");
lv_obj_align(feuchte_label, LV_ALIGN_RIGHT_MID, -3, 8);
lv_obj_t *temp_label = lv_label_create(lv_screen_active());
lv_label_set_text(temp_label, "Temperatur");
lv_obj_align(temp_label, LV_ALIGN_LEFT_MID, 3, 8);
// Set font type and font size. More information: https://docs.lvgl.io/master/overview/font.html
static lv_style_t style_tf_label;
lv_style_init(&style_tf_label);
lv_style_set_text_font(&style_tf_label, &lv_font_montserrat_10);
lv_obj_add_style(feuchte_label, &style_tf_label, 0);
lv_obj_add_style(temp_label, &style_tf_label, 0);
/* ganz unten etwas Info anzeigen */
// Style dafür
@@ -420,4 +414,18 @@ void show2lines() {
lv_obj_add_style(line2, &style_line, 0);
}
void showResetTime(struct tm tinfo) {
static lv_style_t style_info_label;
lv_style_init(&style_info_label);
lv_style_set_text_font(&style_info_label, &lv_font_montserrat_8);
lv_style_set_text_color(&style_info_label, LV_COLOR_MAKE(0x40, 0x40, 0x40));
char date[20];
strftime(date, 20, "%d-%m-%Y %H:%M", &tinfo);
lv_obj_t *resdate_label = lv_label_create(lv_screen_active());
lv_label_set_text(resdate_label, date);
lv_obj_align(resdate_label, LV_ALIGN_BOTTOM_LEFT, 4, 0);
lv_obj_add_style(resdate_label, &style_info_label, LV_PART_MAIN);
}