V1.6.2 IP-Adresse per MQTT

This commit is contained in:
rxf
2024-08-23 14:24:39 +02:00
parent 251c73b517
commit 23abbb837a
6 changed files with 38 additions and 31 deletions

View File

@@ -5,6 +5,14 @@
#include "main.h"
#include "grafik.h"
// Definition der diversen Farben
#define TEXTCOLOTR_TFAUSSEN 0x57d3F7
#define BACKGROUND_COLOR 0xD3F0FF
#define TEXTCOLOR 0x0000FF
#define TEXTCOLOR_FEUCHTE 0xFF0000
#define TEXTCOLOR_XACHSE 0x0000FF
#define TEXTCOLOR_INFO 0x404040
#define DRAW_BUF_SIZE (SCREEN_WIDTH * SCREEN_HEIGHT / 10 * (LV_COLOR_DEPTH / 8))
uint32_t draw_buf[DRAW_BUF_SIZE / 4];
@@ -105,7 +113,7 @@ void showAussenData(float val, bool what)
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_style_set_text_color(&style_tta_label, lv_color_hex(TEXTCOLOTR_TFAUSSEN));
lv_obj_add_style(tta_label, &style_tta_label, 0);
lv_obj_add_style(tfa_label, &style_tta_label, 0);
}
@@ -233,7 +241,7 @@ void drawChart()
static lv_style_t style_scaleT;
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_text_color(&style_scaleT, lv_color_hex(TEXTCOLOR));
// lv_style_set_bg_color(&style_scaleT, lv_color_hex(0xFF00FF));
lv_obj_add_style(scaleT, &style_scaleT, 0);
@@ -284,7 +292,7 @@ void drawChart()
static lv_style_t style_scale;
lv_style_init(&style_scale);
lv_style_set_text_font(&style_scale, &lv_font_montserrat_10);
lv_style_set_text_color(&style_scale, lv_color_hex(0xFF0000));
lv_style_set_text_color(&style_scale, lv_color_hex(TEXTCOLOR_FEUCHTE));
lv_obj_add_style(scale, &style_scale, 0);
// X-Achse
@@ -311,7 +319,7 @@ void drawChart()
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_style_set_text_color(&style_xscale, lv_color_hex(TEXTCOLOR_XACHSE));
lv_obj_add_style(xscale, &style_xscale, 0);
// Text als Überschrift an die Axen
@@ -335,23 +343,15 @@ void drawChart()
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));
lv_style_set_text_color(&style_info_label, lv_color_hex(TEXTCOLOR_INFO));
// Versionsnummer und Datum
// Versionsnummer, IP-Adresse und Datum
lv_obj_t *version_label = lv_label_create(lv_screen_active());
char ver[40];
sprintf(ver, "V %s %s %s", VERSION, VDATE, VTIME);
lv_label_set_text(version_label, ver);
lv_obj_align(version_label, LV_ALIGN_BOTTOM_MID, 0, 0);
lv_obj_align(version_label, LV_ALIGN_BOTTOM_RIGHT, -4, 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, 40, 0);
// lv_obj_add_style(bmr_label, &style_info_label, LV_PART_MAIN);
}
void showRate(int r) {
@@ -360,7 +360,6 @@ void showRate(int r) {
lv_label_set_text(bmr_label, rate);
}
void updatechartData(float value, float humvalue)
{
int i = 0;
@@ -418,7 +417,7 @@ 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));
lv_style_set_text_color(&style_info_label, lv_color_hex(TEXTCOLOR_INFO));
char date[20];
strftime(date, 20, "%d-%m-%Y %H:%M", &tinfo);

View File

@@ -35,7 +35,6 @@ typedef struct {
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define BACKGROUND_COLOR 0xD3F0FF
#ifdef MAIN
ARC arcTemp = {NULL, "temp", 40, -10, 110, 30.0, "%.1f°C", "°C", 15, 35, 20, 25, -11, 0.0};
ARC arcHum = {NULL, "humi", 170, -10, 110, 60.0, "%.0f%%", "%", 40, 100, 65, 70, 2, 0.0};

View File

@@ -31,8 +31,6 @@ extern struct tm timeinfo;
#endif
void setBMEreadtime(int time);
char * getChipID(void);
#endif

View File

@@ -52,9 +52,18 @@ void onmessage(char *tp, byte *msg, unsigned int length)
humOffset = (float)doc["humoffset"];
}
Serial.printf("tempoffset: %.1f, humoffset: %.1f\n",tempOffset, humOffset);
} else if (topic == MQTT_TOPIC "get") {
if(doc.containsKey("send")) {
if(doc["send"] == "ip") {
char ip[30];
sprintf(ip, "{\"ip\":\"%s\"}", WiFi.localIP().toString().c_str());
client.publish(MQTT_TOPIC "get/ip", ip);
}
}
}
}
// Connect or reconnect to MQTT and subscribe
void reconnect(void)
{
@@ -74,6 +83,7 @@ void reconnect(void)
}
Serial.println("Connected");
client.subscribe(MQTT_TOPIC "set/parameter");
client.subscribe(MQTT_TOPIC "get");
client.subscribe("hm/status/Aussen_Temp:1/#");
}

View File

@@ -4,17 +4,9 @@
#include <PubSubClient.h>
#include <ArduinoJson.h>
//#define MQTT_BROKER "rexfue.de"
#define MQTT_BROKER "nuccy"
#define MQTT_PORT 1883
//#define MQTT_USER "stzuhr"
//#define MQTT_PASSWD "74chQCYb"
#define MQTT_USER "rxf"
#define MQTT_PASSWD "Tux4S!ech"
#define CLIENT_ID "Bad"
#define MQTT_TOPIC "CYD/Bad/"
#define MQTT_PUB_TEMP "CYD/Bad/put/bme280"
#define MQTT_PUB_TEMP "CYD/Bad/state/bme280"
#ifdef MQTT
WiFiClient espClient;

View File

@@ -1,11 +1,20 @@
// Versionsgeschichte
#define VERSION "1.6.0"
#define VERSION "1.6.2"
#define VDATE "2024-08-23"
#define VTIME "07:45 UTC"
#define VTIME "12:15 UTC"
/*
Version Date Author
1.6.2 2024-08-23 rxf
- IP-Adresse per MQTT abfragen
- Farben per #define festlegen
1.6.1 2024-08-23 rxf
- Publish mit Topic CYD/Bad/status/bme280
- MQTT confidentials nach config.h verschoben
- Versionsnummer nach rechts
1.6.0 2024-08-23 rxf
- MQTT CLINT_ID auf 'Bad'
- MQTT_TOPIC auf 'CYD/Bad/'