Compare commits
9 Commits
c2e715f1cf
...
caf796c818
Author | SHA1 | Date |
---|---|---|
Carsten Schmiemann | caf796c818 | |
Carsten Schmiemann | e8560f5266 | |
Carsten Schmiemann | 4b088a677a | |
Carsten Schmiemann | 0611b17030 | |
Carsten Schmiemann | c41ccff603 | |
Carsten Schmiemann | 1ec239918b | |
Carsten Schmiemann | be2a42e50e | |
Carsten Schmiemann | de2cfe0a06 | |
Carsten Schmiemann | 8e349b96b4 |
|
@ -196,16 +196,24 @@ void display_screen_battery(float battery_voltage, float battery_amps, float bat
|
|||
display.drawFrame(5,38,40,26);
|
||||
display.drawStr(46,45,"F");
|
||||
display.drawStr(46,64,"E");
|
||||
display.setCursor(9,60); display.print(batt_cell_v_min); display.print("V");
|
||||
display.setCursor(9,50); display.print(batt_cell_v_max); display.print("V");
|
||||
display.setCursor(11,60); display.print(batt_cell_v_min); display.print("V");
|
||||
display.setCursor(11,50); display.print(batt_cell_v_max); display.print("V");
|
||||
display.setCursor(72,18); display.print(battery_voltage); display.print("V");
|
||||
display.setCursor(72,28); display.print(battery_amps,1); display.print("A");
|
||||
display.setCursor(72,38); display.print(battery_wattage,0); display.print("W");
|
||||
display.setFont(u8g2_font_inr19_mf);
|
||||
display.setCursor(70,63); display.print(battery_soc,0); display.print("%");
|
||||
if (battery_soc == 100)
|
||||
{
|
||||
display.setCursor(60,63);
|
||||
}
|
||||
else
|
||||
{
|
||||
display.setCursor(70,63);
|
||||
}
|
||||
display.print(battery_soc,0); display.print("%");
|
||||
display.setFont(u8g2_font_6x10_tr);
|
||||
int batt_fill_y = map(battery_soc, 0, 100, 62, 37);
|
||||
int batt_fill_height = map(battery_soc, 0, 100, 0, 25);
|
||||
int batt_fill_y = map(battery_soc, 0, 100, 62, 38);
|
||||
int batt_fill_height = map(battery_soc, 0, 100, 0, 24);
|
||||
display.setDrawColor(2);
|
||||
display.drawBox(6,batt_fill_y,38,batt_fill_height);
|
||||
} while ( display.nextPage() );
|
||||
|
@ -220,8 +228,17 @@ void display_screen_grid(float grid_power, float consum, float inv_power, float
|
|||
display_header(title_grid);
|
||||
display.drawXBM(0,9, grid_width, grid_height, grid_bits);
|
||||
display.setCursor(10,45); display.print(grid_power,0); display.print("W");
|
||||
display.setCursor(40,54); display.print(inv_power,0); display.print("W");
|
||||
display.setCursor(40,63); display.print(inv_current,1); display.print("A");
|
||||
|
||||
if (inv_power == 0)
|
||||
{
|
||||
display.setCursor(46,54); display.print("OFF");
|
||||
}
|
||||
else
|
||||
{
|
||||
display.setCursor(40,54); display.print(inv_power,0); display.print("W");
|
||||
display.setCursor(40,63); display.print(inv_current,1); display.print("A");
|
||||
}
|
||||
|
||||
display.setCursor(87,20); display.print(consum,0); display.print("W");
|
||||
|
||||
if (show_pv_chg_screen)
|
||||
|
@ -246,7 +263,7 @@ void display_screen_grid(float grid_power, float consum, float inv_power, float
|
|||
|
||||
}
|
||||
|
||||
//Graph last 100 values
|
||||
//Display graph screen
|
||||
void display_screen_graph(float *values, char* key, int type, int buffersize)
|
||||
{
|
||||
logPrintlnD("Display graph...");
|
||||
|
@ -261,20 +278,20 @@ void display_screen_graph(float *values, char* key, int type, int buffersize)
|
|||
{
|
||||
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");
|
||||
display.drawLine(13, 60, 15, 60); //X mark
|
||||
display.drawLine(15, 10, 15, 62); //Y boarder
|
||||
display.drawStr(7,64, "0");
|
||||
display.drawStr(7,34, "k");
|
||||
display.drawStr(7,46, "W");
|
||||
display.drawLine(13, 36, 15, 36); //marker Y 5
|
||||
display.drawLine(13, 36, 15, 36); //marker Y .5
|
||||
display.drawLine(13, 13, 15, 13); //marker Y 1
|
||||
|
||||
for (int i = 25; i<120; i += 10)
|
||||
for (int i = 25; i<130; i += 10)
|
||||
{
|
||||
display.drawLine(i, 60, i, 62); //marker X
|
||||
}
|
||||
|
||||
// Auto-scale graph (scale 1kW to 15kW automatically)
|
||||
// Auto-scale graph (scale 1kW to 24kW automatically)
|
||||
float max = values[0];
|
||||
// find highest value
|
||||
for (int i = 0; i<buffersize; i++)
|
||||
|
@ -321,7 +338,7 @@ void display_screen_graph(float *values, char* key, int type, int buffersize)
|
|||
|
||||
for (int i = 0; i<buffersize; i++)
|
||||
{
|
||||
display.drawLine((15+i), 60, (15+i), map(values[i], 0, graph_max_kW, 60, 13));
|
||||
display.drawLine((16+i), 60, (16+i), map(values[i], 0, graph_max_kW, 60, 13));
|
||||
}
|
||||
|
||||
if (strlen(key) < 3) {
|
||||
|
|
26
src/main.cpp
26
src/main.cpp
|
@ -49,7 +49,7 @@
|
|||
#include <lang.h>
|
||||
#include <display.h>
|
||||
|
||||
char VERSION[6] = "v0.9d";
|
||||
char VERSION[6] = "v1.0";
|
||||
|
||||
//Defaults
|
||||
char mqtt_server[15] = "";
|
||||
|
@ -94,11 +94,11 @@ bool display_conf_time_present = false;
|
|||
bool display_conf_dc_pvcharger_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 };
|
||||
float display_graph_ringbuffer_pv_1h[100] = { 0 };
|
||||
float display_graph_ringbuffer_pv_24h[100] = { 0 };
|
||||
const int display_graph_buffersize = 100;
|
||||
const int display_graph_buffersize = 110;
|
||||
float display_graph_ringbuffer_load_1h[display_graph_buffersize] = { 0 };
|
||||
float display_graph_ringbuffer_load_24h[display_graph_buffersize] = { 0 };
|
||||
float display_graph_ringbuffer_pv_1h[display_graph_buffersize] = { 0 };
|
||||
float display_graph_ringbuffer_pv_24h[display_graph_buffersize] = { 0 };
|
||||
int display_refresh_counter = 0;
|
||||
int display_refresh_time;
|
||||
|
||||
|
@ -249,21 +249,21 @@ void callback(char* topic, byte* message, unsigned int length) {
|
|||
DynamicJsonDocument json(512);
|
||||
deserializeJson(json, messageTemp);
|
||||
load_ph1 = json["value"];
|
||||
consum_p = load_ph1 + load_ph2 + load_ph3; //calc consumption on each msg for precision
|
||||
consum_p = load_ph1 + load_ph2 + load_ph3; //calc consumption on each msg for faster response
|
||||
}
|
||||
//System - AC Load Phase 2
|
||||
if (String(topic) == mqtt_grid_power_l2) {
|
||||
DynamicJsonDocument json(512);
|
||||
deserializeJson(json, messageTemp);
|
||||
load_ph2 = json["value"];
|
||||
consum_p = load_ph1 + load_ph2 + load_ph3; //calc consumption on each msg for precision
|
||||
consum_p = load_ph1 + load_ph2 + load_ph3; //calc consumption on each msg for faster response
|
||||
}
|
||||
//System - AC Load Phase 3
|
||||
if (String(topic) == mqtt_grid_power_l3) {
|
||||
DynamicJsonDocument json(512);
|
||||
deserializeJson(json, messageTemp);
|
||||
load_ph3 = json["value"];
|
||||
consum_p = load_ph1 + load_ph2 + load_ph3; //calc consumption on each msg for precision
|
||||
consum_p = load_ph1 + load_ph2 + load_ph3; //calc consumption on each msg for faster response
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -611,9 +611,9 @@ void setup() {
|
|||
Serial.print("display dc pc chg present: "); Serial.println(display_conf_dc_pvcharger_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");
|
||||
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);
|
||||
display_text_fullscreen((char*)"Configuration summary", (char*)"Disp. Refresh:", disp_refresh_interval, (char*)"Disp. rotation:", disp_screen_interval, (char*)" 2/2");
|
||||
display_text_fullscreen((char*)"Configuration summary", (char*)"Disp. Refresh:", disp_refresh_interval, (char*)"Disp. rotation:", disp_screen_interval, (char*)" 2/2");
|
||||
delay(3000);
|
||||
lastDispRefreshTime = millis();
|
||||
lastScreenChangeTime = millis();
|
||||
|
@ -727,7 +727,7 @@ void loop() {
|
|||
{
|
||||
if(millis() - lastGraphRecord_1h >= ((1 *60*60*1000 ) / display_graph_buffersize)) //temporarily set to half minute
|
||||
{
|
||||
display_graph_ringbuffer_add(display_graph_ringbuffer_load_1h, grid_p);
|
||||
display_graph_ringbuffer_add(display_graph_ringbuffer_load_1h, consum_p);
|
||||
if (display_conf_dc_pvcharger_present)
|
||||
{
|
||||
display_graph_ringbuffer_add(display_graph_ringbuffer_pv_1h, pv_w);
|
||||
|
@ -736,7 +736,7 @@ void loop() {
|
|||
}
|
||||
if(millis() - lastGraphRecord_24h >= ((24 *60*60*1000 ) / display_graph_buffersize))
|
||||
{
|
||||
display_graph_ringbuffer_add(display_graph_ringbuffer_load_24h, grid_p);
|
||||
display_graph_ringbuffer_add(display_graph_ringbuffer_load_24h, consum_p);
|
||||
if (display_conf_dc_pvcharger_present)
|
||||
{
|
||||
display_graph_ringbuffer_add(display_graph_ringbuffer_pv_24h, pv_w);
|
||||
|
|
Loading…
Reference in New Issue