V 1.3.2 - X-Achse dazu
This commit is contained in:
@@ -25,6 +25,7 @@ void setup_grafik(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void buildarc(ARC arc)
|
||||
{
|
||||
lv_obj_set_size(arc.arc, arc.size, arc.size);
|
||||
@@ -87,15 +88,26 @@ void showAussenData(float val, bool what)
|
||||
{
|
||||
ta_label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(ta_label," ");
|
||||
tta_label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(tta_label," ");
|
||||
|
||||
fa_label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(fa_label," ");
|
||||
tfa_label = lv_label_create(lv_screen_active());
|
||||
lv_label_set_text(tfa_label," ");
|
||||
|
||||
static lv_style_t style_ta_label;
|
||||
lv_style_init(&style_ta_label);
|
||||
lv_style_set_text_font(&style_ta_label, &lv_font_montserrat_16);
|
||||
lv_obj_add_style(ta_label, &style_ta_label, 0);
|
||||
lv_obj_add_style(fa_label, &style_ta_label, 0);
|
||||
|
||||
static lv_style_t style_tta_label;
|
||||
lv_style_init(&style_tta_label);
|
||||
lv_style_set_text_font(&style_tta_label, &lv_font_montserrat_10);
|
||||
lv_style_set_text_color(&style_tta_label, LV_COLOR_MAKE(0x60, 0x60, 0xFF));
|
||||
lv_obj_add_style(tta_label, &style_tta_label, 0);
|
||||
lv_obj_add_style(tfa_label, &style_tta_label, 0);
|
||||
}
|
||||
|
||||
void lv_create_main_gui(void)
|
||||
@@ -162,6 +174,8 @@ void lv_create_main_gui(void)
|
||||
|
||||
showAussenData(0, true);
|
||||
showAussenData(0, false);
|
||||
|
||||
// show2lines();
|
||||
}
|
||||
|
||||
void setValuetoArc(ARC arc, float value)
|
||||
@@ -201,6 +215,7 @@ void setValuetoArc(ARC arc, float value)
|
||||
void drawChart()
|
||||
{
|
||||
Serial.println("draw_chart ");
|
||||
int scaleHeight = 85;
|
||||
|
||||
// Create a container to display the chart and scale
|
||||
lv_obj_t *container_row = lv_obj_create(lv_screen_active());
|
||||
@@ -219,7 +234,7 @@ void drawChart()
|
||||
|
||||
// linke Axe
|
||||
lv_obj_t *scaleT = lv_scale_create(container_row);
|
||||
lv_obj_set_size(scaleT, 30, 75);
|
||||
lv_obj_set_size(scaleT, 30, scaleHeight);
|
||||
lv_scale_set_mode(scaleT, LV_SCALE_MODE_VERTICAL_LEFT);
|
||||
|
||||
static const char *scaleT_labels[6] = {"15°C", "20°C", "25°C", "30°C", "35°C"};
|
||||
@@ -244,7 +259,7 @@ void drawChart()
|
||||
lv_obj_add_style(scaleT, &style_scaleT, 0);
|
||||
|
||||
// Create a chart
|
||||
|
||||
// Info: die Breite eines X-Abschnittes (von vertikaler Linie zu vertikaler Linie) beträgt 55 Pixel
|
||||
chart = lv_chart_create(container_row);
|
||||
lv_obj_set_size(chart, CHART_WIDTH, CHART_HEIGHT);
|
||||
lv_chart_set_type(chart, LV_CHART_TYPE_LINE); /*Show lines and points too*/
|
||||
@@ -269,7 +284,7 @@ void drawChart()
|
||||
|
||||
// rechte Axe
|
||||
lv_obj_t *scale = lv_scale_create(container_row);
|
||||
lv_obj_set_size(scale, 30, 75);
|
||||
lv_obj_set_size(scale, 30, scaleHeight);
|
||||
lv_scale_set_mode(scale, LV_SCALE_MODE_VERTICAL_RIGHT);
|
||||
|
||||
static const char *scale_labels[5] = {"40%", "55%", "70%", "85%", "100%"};
|
||||
@@ -293,15 +308,33 @@ void drawChart()
|
||||
lv_style_set_text_color(&style_scale, lv_color_hex(0xFF0000));
|
||||
lv_obj_add_style(scale, &style_scale, 0);
|
||||
|
||||
/* // Label an der Axe
|
||||
lv_obj_t * unitxAx_label = lv_label_create(container_row);
|
||||
lv_label_set_text(unitxAx_label, "°C");
|
||||
lv_obj_align(unitxAx_label, LV_ALIGN_TOP_RIGHT, -20, 8);
|
||||
static lv_style_t style_unitxAx_label;
|
||||
lv_style_init(&style_unitxAx_label);
|
||||
lv_style_set_text_font(&style_unitxAx_label, &lv_font_montserrat_12);
|
||||
lv_obj_add_style(unitxAx_label, &style_unitxAx_label, 0);
|
||||
*/
|
||||
// X-Achse
|
||||
lv_obj_t *xscale = lv_scale_create(chart);
|
||||
lv_obj_set_size(xscale, 220, 30);
|
||||
lv_scale_set_mode(xscale, LV_SCALE_MODE_HORIZONTAL_TOP);
|
||||
|
||||
//static const char *xscale_labels[6] = {"200", "150", "100", "50", "0"};
|
||||
//lv_scale_set_text_src(xscale, xscale_labels);
|
||||
lv_scale_set_label_show(xscale, true);
|
||||
|
||||
lv_scale_set_total_tick_count(xscale, 21);
|
||||
lv_scale_set_major_tick_every(xscale, 5);
|
||||
|
||||
lv_obj_set_style_length(xscale, 0, LV_PART_ITEMS);
|
||||
lv_obj_set_style_length(xscale, 0, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_line_width(xscale, 0, LV_PART_ITEMS);
|
||||
lv_obj_set_style_line_width(xscale, 0, LV_PART_INDICATOR);
|
||||
lv_obj_set_style_line_width(xscale, 0, LV_PART_MAIN);
|
||||
lv_scale_set_range(xscale, -110, 0);
|
||||
lv_obj_set_pos(xscale, 5, -25);
|
||||
|
||||
|
||||
static lv_style_t style_xscale;
|
||||
lv_style_init(&style_xscale);
|
||||
lv_style_set_text_font(&style_xscale, &lv_font_montserrat_10);
|
||||
lv_style_set_text_color(&style_xscale, lv_color_hex(0x0000FF));
|
||||
lv_obj_add_style(xscale, &style_xscale, 0);
|
||||
|
||||
|
||||
/* ganz unten etwas Info anzeigen */
|
||||
// Style dafür
|
||||
@@ -315,16 +348,16 @@ void drawChart()
|
||||
char ver[20];
|
||||
sprintf(ver, "V %s %s", VERSION, VDATE);
|
||||
lv_label_set_text(version_label, ver);
|
||||
lv_obj_align(version_label, LV_ALIGN_BOTTOM_RIGHT, -10, 0);
|
||||
lv_obj_align(version_label, LV_ALIGN_BOTTOM_MID, 0, 0);
|
||||
lv_obj_add_style(version_label, &style_info_label, LV_PART_MAIN);
|
||||
|
||||
// links davon die Abtastrate
|
||||
bmr_label = lv_label_create(lv_screen_active());
|
||||
char rate[20];
|
||||
sprintf(rate, "Rate: %ds", updateTime / 1000);
|
||||
lv_label_set_text(bmr_label, rate);
|
||||
lv_obj_align(bmr_label, LV_ALIGN_BOTTOM_LEFT, 10, 0);
|
||||
lv_obj_add_style(bmr_label, &style_info_label, LV_PART_MAIN);
|
||||
// bmr_label = lv_label_create(lv_screen_active());
|
||||
// char rate[20];
|
||||
// sprintf(rate, "Rate: %ds", updateTime / 1000);
|
||||
// lv_label_set_text(bmr_label, rate);
|
||||
// lv_obj_align(bmr_label, LV_ALIGN_BOTTOM_LEFT, 40, 0);
|
||||
// lv_obj_add_style(bmr_label, &style_info_label, LV_PART_MAIN);
|
||||
}
|
||||
|
||||
void showRate(int r) {
|
||||
@@ -348,18 +381,43 @@ void updatechartData(float value, float humvalue)
|
||||
lv_chart_refresh(chart);
|
||||
}
|
||||
|
||||
void setAussenDataValues(float val, bool what)
|
||||
void setAussenDataValues(float val, bool what, struct tm t)
|
||||
{
|
||||
if (what)
|
||||
{
|
||||
lv_label_set_text_fmt(ta_label,"Ta:\n%.1f °C", val);
|
||||
lv_obj_align(ta_label, LV_ALIGN_TOP_LEFT, 10, 10);
|
||||
lv_label_set_text_fmt(tta_label,"%02d:%02d\n", t.tm_hour, t.tm_min);
|
||||
lv_obj_align(tta_label, LV_ALIGN_TOP_LEFT, 10, 45);
|
||||
}
|
||||
else
|
||||
{
|
||||
lv_label_set_text_fmt(fa_label,"Fa:\n%.0f %%", val);
|
||||
lv_obj_align(fa_label, LV_ALIGN_TOP_RIGHT, -10, 10);
|
||||
lv_label_set_text_fmt(tfa_label,"%02d:%02d\n", t.tm_hour, t.tm_min);
|
||||
lv_obj_align(tfa_label, LV_ALIGN_TOP_RIGHT, -23, 45);
|
||||
}
|
||||
}
|
||||
|
||||
void show2lines() {
|
||||
int x1 = 104;
|
||||
int x2 = x1 + 56;
|
||||
static lv_point_precise_t line1_points[] = { {x1, 70}, {x1, 220} };
|
||||
static lv_point_precise_t line2_points[] = { {x2, 70}, {x2, 220}};
|
||||
|
||||
static lv_style_t style_line;
|
||||
lv_style_init(&style_line);
|
||||
lv_style_set_line_width(&style_line, 1);
|
||||
lv_style_set_line_color(&style_line, lv_palette_main(LV_PALETTE_BLUE));
|
||||
|
||||
lv_obj_t *line1, *line2;
|
||||
line1 = lv_line_create(lv_screen_active());
|
||||
lv_line_set_points(line1, line1_points, 2);
|
||||
lv_obj_add_style(line1, &style_line, 0);
|
||||
|
||||
line2 = lv_line_create(lv_screen_active());
|
||||
lv_line_set_points(line2, line2_points, 2);
|
||||
lv_obj_add_style(line2, &style_line, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ lv_obj_t * time_label;
|
||||
lv_obj_t * ta_label;
|
||||
lv_obj_t * fa_label;
|
||||
lv_obj_t * bmr_label;
|
||||
lv_obj_t * tta_label;
|
||||
lv_obj_t * tfa_label;
|
||||
#else
|
||||
extern ARC arcTemp;
|
||||
extern ARC arcHum;
|
||||
@@ -51,6 +53,8 @@ extern lv_obj_t * time_label;
|
||||
extern lv_obj_t * ta_label;
|
||||
extern lv_obj_t * fa_label;
|
||||
extern lv_obj_t * bmr_label;
|
||||
extern lv_obj_t * tta_label;
|
||||
extern lv_obj_t * tfa_label;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -59,8 +63,10 @@ void lv_create_main_gui(void);
|
||||
void setValuetoArc(ARC arc, float value);
|
||||
void drawChart();
|
||||
void updatechartData(float value, float value_hum);
|
||||
void setAussenDataValues(float val, bool what);
|
||||
void setAussenDataValues(float val, bool what, struct tm t);
|
||||
void showRate(int r);
|
||||
void show2lines();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ void loop() {
|
||||
timeinfo = gettheTime(NTPREADTIME);
|
||||
if (timeinfo.tm_sec == 0) { // minute over
|
||||
showDateTime(timeinfo);
|
||||
}
|
||||
}
|
||||
if (millis() - bmeReadtimer > bmeReadTime) {
|
||||
bmeReadtimer = millis();
|
||||
bmedata = readBME280();
|
||||
|
||||
@@ -6,8 +6,8 @@ extern "C" {
|
||||
#include "freertos/timers.h"
|
||||
}
|
||||
|
||||
#define VERSION "1.3.1"
|
||||
#define VDATE "2024-07-22"
|
||||
#define VERSION "1.3.2"
|
||||
#define VDATE "2024-07-23"
|
||||
|
||||
//#define MAXREADINGS 224
|
||||
#define MAXREADINGS 200
|
||||
@@ -17,12 +17,13 @@ TimerHandle_t mqttReconnectTimer;
|
||||
TimerHandle_t wifiReconnectTimer;
|
||||
int bmeReadTime = 10000;
|
||||
int updateTime = 30000;
|
||||
|
||||
struct tm timeinfo;
|
||||
#else
|
||||
extern TimerHandle_t mqttReconnectTimer;
|
||||
extern TimerHandle_t wifiReconnectTimer;
|
||||
extern int bmeReadTime;
|
||||
extern int updateTime;
|
||||
extern struct tm timeinfo;
|
||||
#endif
|
||||
|
||||
void setBMEreadtime(int time);
|
||||
|
||||
11
src/mqtt.cpp
11
src/mqtt.cpp
@@ -71,13 +71,18 @@ void parseMQTTmessages(char *topic, String msg) {
|
||||
return;
|
||||
}
|
||||
// Extract values
|
||||
bool istemp = true;
|
||||
float val = 0.0;
|
||||
if (strcmp(topic, "CYD/set/hm/aussen") == 0) {
|
||||
if(doc.containsKey("temperature")) {
|
||||
setAussenDataValues(doc["temperature"], true);
|
||||
istemp = true;
|
||||
val = doc["temperature"];
|
||||
}
|
||||
if(doc.containsKey("humidity")) {
|
||||
setAussenDataValues(doc["humidity"], false);
|
||||
istemp = false;
|
||||
val = doc["humidity"];
|
||||
}
|
||||
setAussenDataValues(val, istemp, timeinfo);
|
||||
} else if (strcmp(topic, "CYD/set/parameter") == 0) {
|
||||
if(doc.containsKey("bmerate")) {
|
||||
setBMEreadtime(doc["bmerate"]);
|
||||
@@ -85,7 +90,7 @@ void parseMQTTmessages(char *topic, String msg) {
|
||||
}
|
||||
if(doc.containsKey("updaterate")) {
|
||||
setBMEreadtime(doc["updaterate"]);
|
||||
showRate(doc["updaterate"]);
|
||||
// showRate(doc["updaterate"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "weifi.h"
|
||||
#include "mqtt.h"
|
||||
#include "main.h"
|
||||
|
||||
struct tm gettheTime(int repeat) {
|
||||
if(!getLocalTime(&timeinfo)){
|
||||
|
||||
@@ -6,11 +6,7 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#ifdef MAIN
|
||||
struct tm timeinfo;
|
||||
#else
|
||||
extern struct tm timeinfo;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef WEIFI
|
||||
const char* ssid = "Mizar";
|
||||
|
||||
Reference in New Issue
Block a user