Add different graph display with title

This commit is contained in:
Carsten Schmiemann 2022-11-20 02:44:36 +01:00
parent 3392138f6f
commit 39d9ffc3a1
5 changed files with 62 additions and 13 deletions

View File

@ -40,6 +40,8 @@ char* title_pv;
char* title_battery;
char* title_grid;
char* title_graph;
char* title_graph_load;
char* title_graph_pv;
bool pv_charging = false;
bool show_temp_outside;
@ -245,12 +247,20 @@ void display_screen_grid(float grid_power, float consum, float inv_power, float
}
//Graph last 100 values
void display_screen_graph(float *values, char* key, int buffersize)
void display_screen_graph(float *values, char* key, int type, int buffersize)
{
logPrintD("Display graph...");
display.firstPage();
do {
display_header(title_graph);
if (type = 0)
{
display.drawStr(58,17, title_graph_load);
}
else if (type = 1)
{
display.drawStr(58,17, title_graph_pv);
}
display.drawLine(16, 60, 9, 60); //X mark
display.drawLine(15, 8, 15, 62); //Y boarder
display.drawStr(7,63, "0");

View File

@ -35,4 +35,4 @@ void display_header(char* TEXT);
void display_screen_pv(float pv_voltage, float pv_wattage, float battery_voltage, float pv_amps, float pv_kwh);
void display_screen_battery(float battery_voltage, float battery_amps, float battery_wattage, float battery_soc, float batt_cell_v_min, float batt_cell_v_max);
void display_screen_grid(float grid_power, float consum, float inv_power, float inv_current, float pv_wattage);
void display_screen_graph(float *values, char* key, int buffersize);
void display_screen_graph(float *values, char* key, int type, int buffersize);

View File

@ -33,6 +33,8 @@ void set_display_language(char lang[2])
title_battery = (char*)"Batterie";
title_grid = (char*)"Netz";
title_graph = (char*)"Verlauf";
title_graph_load = (char*)"Last";
title_graph_pv = (char*)"PV";
}
else
{
@ -40,5 +42,7 @@ void set_display_language(char lang[2])
title_battery = (char*)"Battery";
title_grid = (char*)"Grid";
title_graph = (char*)"Graph";
title_graph_load = (char*)"Load";
title_graph_pv = (char*)"PV";
}
}

View File

@ -26,5 +26,7 @@ extern char* title_pv;
extern char* title_battery;
extern char* title_grid;
extern char* title_graph;
extern char* title_graph_load;
extern char* title_graph_pv;
void set_display_language(char lang[2]);

View File

@ -92,7 +92,7 @@ char mqtt_grid_power_l3[80];
bool display_conf_temp_oa_present = false;
bool display_conf_time_present = false;
bool display_conf_dc_pvcharger_present = false;
bool display_conf_graph_pv_present = false;
bool display_conf_graph_present = false;
bool display_conf_statistics_present = false;
float display_graph_ringbuffer_load_1h[100] = { 0 };
float display_graph_ringbuffer_load_24h[100] = { 0 };
@ -484,11 +484,11 @@ void setup() {
}
if (strcmp(show_graph,"yes") == 0)
{
display_conf_graph_pv_present = true;
display_conf_graph_present = true;
}
else
{
display_conf_graph_pv_present = false;
display_conf_graph_present = false;
}
if (strcmp(show_statistics,"yes") == 0)
{
@ -499,7 +499,7 @@ void setup() {
display_conf_statistics_present = false;
}
display_setup(display_lang, display_conf_temp_oa_present, display_conf_time_present, display_conf_dc_pvcharger_present, display_conf_graph_pv_present, display_conf_statistics_present);
display_setup(display_lang, display_conf_temp_oa_present, display_conf_time_present, display_conf_dc_pvcharger_present, display_conf_graph_present, display_conf_statistics_present);
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
@ -609,7 +609,7 @@ void setup() {
Serial.print("display temp present: "); Serial.println(display_conf_temp_oa_present);
Serial.print("display time present: "); Serial.println(display_conf_time_present);
Serial.print("display dc pc chg present: "); Serial.println(display_conf_dc_pvcharger_present);
Serial.print("display graph present: "); Serial.println(display_conf_graph_pv_present);
Serial.print("display graph present: "); Serial.println(display_conf_graph_present);
Serial.print("display stats present: "); Serial.println(display_conf_statistics_present);
display_text_fullscreen((char*)"Configuration summary", (char*)"GX MQTT Server IP:", mqtt_server, (char*)"GX VRM ID:", gx_vrm_id, (char*)" 1/2");
delay(3000);
@ -649,16 +649,49 @@ void loop() {
}
if (display_refresh_counter >= (display_refresh_time*3) && display_refresh_counter <= (display_refresh_time*4))
{
if (display_conf_graph_pv_present)
if (display_conf_graph_present)
{
display_screen_graph(display_graph_ringbuffer_load_1h, (char*)"1h", display_graph_buffersize);
display_screen_graph(display_graph_ringbuffer_load_1h, (char*)"1h", 0, display_graph_buffersize);
}
else
{
display_refresh_counter = (display_refresh_time*4) + 1;
}
}
if (display_refresh_counter >= (display_refresh_time*4) && display_refresh_counter <= (display_refresh_time*5))
if (display_refresh_counter >= (display_refresh_time*4) && display_refresh_counter <= (display_refresh_time*5))
{
if (display_conf_graph_present)
{
display_screen_graph(display_graph_ringbuffer_load_24h, (char*)"24h", 0, display_graph_buffersize);
}
else
{
display_refresh_counter = (display_refresh_time*5) + 1;
}
}
if (display_refresh_counter >= (display_refresh_time*5) && display_refresh_counter <= (display_refresh_time*6))
{
if (display_conf_graph_present && display_conf_dc_pvcharger_present)
{
display_screen_graph(display_graph_ringbuffer_pv_1h, (char*)"1h", 1, display_graph_buffersize);
}
else
{
display_refresh_counter = (display_refresh_time*6) + 1;
}
}
if (display_refresh_counter >= (display_refresh_time*6) && display_refresh_counter <= (display_refresh_time*7))
{
if (display_conf_graph_present && display_conf_dc_pvcharger_present)
{
display_screen_graph(display_graph_ringbuffer_pv_24h, (char*)"24h", 1, display_graph_buffersize);
}
else
{
display_refresh_counter = (display_refresh_time*7) + 1;
}
}
if (display_refresh_counter >= (display_refresh_time*7) && display_refresh_counter <= (display_refresh_time*8))
{
if (display_conf_statistics_present)
{
@ -666,12 +699,12 @@ void loop() {
}
else
{
display_refresh_counter = (display_refresh_time*5) + 1;
display_refresh_counter = (display_refresh_time*8) + 1;
}
}
display_refresh_counter++;
if (display_refresh_counter > (display_refresh_time*5))
if (display_refresh_counter > (display_refresh_time*8))
{
display_refresh_counter = 0;
}
@ -690,7 +723,7 @@ void loop() {
}
//Graph recorder - 1h
if (display_conf_graph_pv_present)
if (display_conf_graph_present)
{
if(millis() - lastGraphRecord_1h >= 30000) //temporarily set to half minute
{