From 4fc55377db44397a54adf37af549c132972bde7f Mon Sep 17 00:00:00 2001 From: Carsten Schmiemann Date: Sun, 13 Nov 2022 00:41:57 +0100 Subject: [PATCH] Show outside temp in title bar --- src/display.cpp | 6 ++++++ src/main.cpp | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index f71a147..9388af6 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -41,6 +41,8 @@ char* title_battery; char* title_grid; bool pv_charging = false; +bool show_temp_outside = false; +float temperature_outside = 0.0; char* screenbuffer; void display_begin() { @@ -97,6 +99,10 @@ void display_header(char* TEXT) { display.drawStr(2,7,TEXT); display.drawLine(0, 8, 128, 8); display.drawLine(100, 0, 100, 8); + if (show_temp_outside) + { + display.setCursor(50,7); display.print(temperature_outside); + } } diff --git a/src/main.cpp b/src/main.cpp index 98e08d5..955ecfe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -64,6 +64,10 @@ char display_lang[2] = ""; long unsigned int DISPLAY_REFRESH_INTERVAL; long unsigned int DISPLAY_SCREEN_INTERVAL; +//Display config +extern bool show_temp_outside; +extern float temperature_outside; + //MQTT connect strings char mqtt_pv_voltage[80]; char mqtt_pv_power[80]; @@ -99,7 +103,7 @@ PubSubClient client(espClient); //Globals long lastMsg = 0; char msg[50]; -float pv_v = 0, pv_w = 0, pv_i = 0, pv_kwh = 0, inv_p = 0, inv_i = 0, batt_v = 0, batt_i = 0, batt_p = 0, batt_c_min = 0, batt_c_max = 0, grid_p = 0, batt_soc = 0, temp_outside = 0, load_ph1 = 0, load_ph2 = 0, load_ph3 = 0; +float pv_v = 0, pv_w = 0, pv_i = 0, pv_kwh = 0, inv_p = 0, inv_i = 0, batt_v = 0, batt_i = 0, batt_p = 0, batt_c_min = 0, batt_c_max = 0, grid_p = 0, batt_soc = 0, load_ph1 = 0, load_ph2 = 0, load_ph3 = 0; bool lastButtonRotationState = HIGH, lastButtonSetupState = HIGH; bool currentButtonRotationState, currentButtonSetupState; int display_screen = 0; @@ -207,7 +211,7 @@ void callback(char* topic, byte* message, unsigned int length) { if (String(topic) == mqtt_temp_outside) { DynamicJsonDocument json(512); deserializeJson(json, messageTemp); - temp_outside = json["value"]; + temperature_outside = json["value"]; } //System - AC Load Phase 1 @@ -398,6 +402,11 @@ void setup() { DISPLAY_SCREEN_INTERVAL = strtol(disp_screen_interval, NULL, 10); set_display_language(display_lang); + if (strtol(address_outside_temperature, NULL, 10) != 0) + { + show_temp_outside = true; + } + client.setServer(mqtt_server, 1883); client.setCallback(callback); char* ip_address = new char[40]();