From 3231d4699473d738cd6eeaef9f0f48b58e9fac62 Mon Sep 17 00:00:00 2001 From: Carsten Schmiemann Date: Sun, 20 Nov 2022 01:54:09 +0100 Subject: [PATCH] Fix esp crash, graph layout --- src/display.cpp | 53 +++++++++++++++++++++++++------------------------ src/display.h | 2 +- src/main.cpp | 2 +- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/display.cpp b/src/display.cpp index 4afe00a..1d406cf 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -245,19 +245,19 @@ void display_screen_grid(float grid_power, float consum, float inv_power, float } //Graph last 100 values -void display_screen_graph(float values[100], char* key, int buffersize) +void display_screen_graph(float *values, char* key, int buffersize) { logPrintD("Display graph..."); display.firstPage(); do { display_header(title_graph); - display.drawLine(7, 60, 9, 60); //X mark - display.drawLine(9, 8, 9, 62); //Y boarder - display.drawStr(1,63, "0"); - display.drawLine(7, 36, 9, 36); //marker Y 5 - display.drawLine(7, 13, 9, 13); //marker Y 1 + display.drawLine(15, 60, 9, 60); //X mark + display.drawLine(15, 8, 15, 62); //Y boarder + display.drawStr(7,63, "0"); + display.drawLine(13, 36, 15, 36); //marker Y 5 + display.drawLine(13, 13, 15, 13); //marker Y 1 - for (int i = 19; i<120; i += 10) + for (int i = 25; i<120; i += 10) { display.drawLine(i, 60, i, 62); //marker X } @@ -273,28 +273,29 @@ void display_screen_graph(float values[100], char* key, int buffersize) } } int graph_max_kW = 1000; - if (max > 2000) { graph_max_kW = 2000; } - else if (max > 3000) { graph_max_kW = 3000; } - else if (max > 4000) { graph_max_kW = 4000; } - else if (max > 4000) { graph_max_kW = 4000; } - else if (max > 5000) { graph_max_kW = 5000; } - else if (max > 6000) { graph_max_kW = 6000; } - else if (max > 7000) { graph_max_kW = 7000; } - else if (max > 8000) { graph_max_kW = 8000; } - else if (max > 9000) { graph_max_kW = 9000; } - else if (max > 10000) { graph_max_kW = 10000; } - else if (max > 11000) { graph_max_kW = 11000; } - else if (max > 12000) { graph_max_kW = 12000; } - else if (max > 13000) { graph_max_kW = 13000; } - else if (max > 14000) { graph_max_kW = 14000; } - else if (max > 15000) { graph_max_kW = 15000; } - else if (max > 16000) { graph_max_kW = 16000; } - display.drawStr(1,17, (char*)(graph_max_kW/1000)); + if (max > 1000) { graph_max_kW = 2000; } + if (max > 2000) { graph_max_kW = 3000; } + if (max > 3000) { graph_max_kW = 4000; } + if (max > 4000) { graph_max_kW = 5000; } + if (max > 5000) { graph_max_kW = 6000; } + if (max > 6000) { graph_max_kW = 7000; } + if (max > 7000) { graph_max_kW = 8000; } + if (max > 8000) { graph_max_kW = 9000; } + if (max > 9000) { graph_max_kW = 10000; } + if (max > 10000) { graph_max_kW = 11000; } + if (max > 11000) { graph_max_kW = 12000; } + if (max > 12000) { graph_max_kW = 13000; } + if (max > 13000) { graph_max_kW = 14000; } + if (max > 14000) { graph_max_kW = 15000; } + if (max > 15000) { graph_max_kW = 16000; } + if (max > 16000) { graph_max_kW = 17000; } + display.setCursor(7,17); + display.print(graph_max_kW/1000); for (int i = 0; i #include -char VERSION[6] = "v0.9a"; +char VERSION[6] = "v0.9d"; //Defaults char mqtt_server[15] = "";