diff --git a/src/display.cpp b/src/display.cpp index 9388af6..05a11c8 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -41,10 +41,19 @@ char* title_battery; char* title_grid; bool pv_charging = false; -bool show_temp_outside = false; -float temperature_outside = 0.0; +bool show_temp_outside; +float temperature_outside; char* screenbuffer; +void display_setup(bool set_show_temp_outside, char lang[2]) { + show_temp_outside = set_show_temp_outside; + set_display_language(lang); +} + +void display_globals(float temperature_outside) { + temperature_outside = temperature_outside; +} + void display_begin() { display.begin(); } @@ -101,7 +110,7 @@ void display_header(char* TEXT) { display.drawLine(100, 0, 100, 8); if (show_temp_outside) { - display.setCursor(50,7); display.print(temperature_outside); + display.setCursor(70,7); display.print(temperature_outside,1); } } diff --git a/src/display.h b/src/display.h index f69d9e0..78e0569 100644 --- a/src/display.h +++ b/src/display.h @@ -22,6 +22,8 @@ ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN ; THE SOFTWARE. */ +void display_setup(bool set_show_temp_outside,char lang[2]); +void display_globals(float temperature_outside); void display_begin(); void display_init(char* VERSION); void display_logo(); diff --git a/src/main.cpp b/src/main.cpp index d871be4..f9b3801 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,7 +48,7 @@ #include #include -char VERSION[6] = "v0.5b"; +char VERSION[6] = "v0.7b"; //Defaults char mqtt_server[15] = ""; @@ -64,10 +64,6 @@ 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]; @@ -211,7 +207,7 @@ void callback(char* topic, byte* message, unsigned int length) { if (String(topic) == mqtt_temp_outside) { DynamicJsonDocument json(512); deserializeJson(json, messageTemp); - temperature_outside = json["value"]; + display_globals(json["value"]); } //System - AC Load Phase 1 @@ -400,11 +396,14 @@ void setup() { DISPLAY_REFRESH_INTERVAL = strtol(disp_refresh_interval, NULL, 10); 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; + display_setup(true, display_lang); + } + else + { + display_setup(false, display_lang); } client.setServer(mqtt_server, 1883);