add graph screen and modular rotation
This commit is contained in:
parent
ec45a14bbe
commit
29e46d526c
3 changed files with 38 additions and 16 deletions
|
@ -241,4 +241,22 @@ void display_screen_grid(float grid_power, float inv_power, float inv_current, f
|
|||
}
|
||||
} while ( display.nextPage() );
|
||||
|
||||
}
|
||||
|
||||
//Graph last 100 values
|
||||
void display_screen_graph(float values[100])
|
||||
{
|
||||
logPrintD("Display graph...");
|
||||
display.firstPage();
|
||||
do {
|
||||
display_header("Graph");
|
||||
display.drawLine(8, 27, 127, 27);
|
||||
display.drawLine(8, 10, 8, 27);
|
||||
display.drawStr(18,53, "0");
|
||||
display.drawStr(7,28, "500");
|
||||
display.drawStr(1,10, "100");
|
||||
display.drawLine(6, 57, 8, 57);
|
||||
display.drawLine(6, 28, 8, 28);
|
||||
display.drawLine(6, 53, 8, 53);
|
||||
} while ( display.nextPage() );
|
||||
}
|
|
@ -35,3 +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 inv_power, float inv_current, float pv_wattage);
|
||||
void display_screen_graph(float values[100]);
|
||||
|
|
35
src/main.cpp
35
src/main.cpp
|
@ -94,6 +94,7 @@ bool display_conf_time_present = false;
|
|||
bool display_conf_dc_pvcharger_present = false;
|
||||
bool display_conf_graph_pv_present = false;
|
||||
bool display_conf_statistics_present = false;
|
||||
float display_graph_power[100] = { 0 };
|
||||
|
||||
//WiFiManager flag for saving data
|
||||
bool shouldSaveConfig = false;
|
||||
|
@ -120,7 +121,6 @@ float pv_v = 0, pv_w = 0, pv_i = 0, pv_kwh = 0, inv_p = 0, inv_i = 0, batt_v = 0
|
|||
bool lastButtonRotationState = HIGH, lastButtonSetupState = HIGH;
|
||||
bool currentButtonRotationState, currentButtonSetupState;
|
||||
int display_screen = 0;
|
||||
int display_last_screen = 2;
|
||||
|
||||
//MQTT topics
|
||||
void callback(char* topic, byte* message, unsigned int length) {
|
||||
|
@ -605,15 +605,22 @@ void loop() {
|
|||
{
|
||||
digitalWrite(STATUS_LED, LOW); //Turn Status LED ON again
|
||||
lastDispRefreshTime += DISPLAY_REFRESH_INTERVAL;
|
||||
|
||||
if (display_screen == 0) {
|
||||
display_screen_pv(pv_v, pv_w, batt_v, pv_i, pv_kwh);
|
||||
display_screen_grid(grid_p, inv_p, inv_i, pv_w);
|
||||
}
|
||||
if (display_screen == 1) {
|
||||
display_screen_battery(batt_v, batt_i, batt_p, batt_soc, batt_c_min, batt_c_max);
|
||||
}
|
||||
if (display_screen == 2) {
|
||||
display_screen_grid(grid_p, inv_p, inv_i, pv_w);
|
||||
}
|
||||
if (display_screen == 2 && display_conf_dc_pvcharger_present) {
|
||||
display_screen_pv(pv_v, pv_w, batt_v, pv_i, pv_kwh);
|
||||
} else {display_screen++;}
|
||||
if (display_screen == 3 && display_conf_graph_pv_present) {
|
||||
display_screen_graph(display_graph_power[100]);
|
||||
} else {display_screen++;}
|
||||
if (display_screen == 4 && display_conf_statistics_present) {
|
||||
//To Do: display_screen_statistics(mqtt_grid_power_l1, mqtt_grid_power_l2, mqtt_grid_power_l3);
|
||||
} else {display_screen++;}
|
||||
}
|
||||
|
||||
//Change screen after time if intervall setting not zero
|
||||
|
@ -623,22 +630,18 @@ void loop() {
|
|||
{
|
||||
time(&now); localtime_r(&now, &tm); //Get local time
|
||||
display_time(tm.tm_hour, tm.tm_min);
|
||||
|
||||
display_screen++;
|
||||
|
||||
lastScreenChangeTime += DISPLAY_SCREEN_INTERVAL;
|
||||
if (display_screen == display_last_screen + 1)
|
||||
|
||||
if (display_screen == 6)
|
||||
{
|
||||
//If no pv power generated, skip PV charger screen
|
||||
if (pv_kwh == 0)
|
||||
{
|
||||
display_screen = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
display_screen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Rotate screen if BUTTON_ROTATION is pressed
|
||||
currentButtonRotationState = digitalRead(BUTTON_ROTATION);
|
||||
|
|
Loading…
Reference in a new issue