diff --git a/src/display.cpp b/src/display.cpp index c67e2e3..b86a959 100644 --- a/src/display.cpp +++ b/src/display.cpp @@ -249,15 +249,15 @@ 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 type, int buffersize) { - logPrintD("Display graph..."); + logPrintlnD("Display graph..."); display.firstPage(); do { display_header(title_graph); - if (type = 0) + if (type == 0) { display.drawStr(58,17, title_graph_load); } - else if (type = 1) + else if (type == 1) { display.drawStr(58,17, title_graph_pv); } diff --git a/src/main.cpp b/src/main.cpp index 591b155..500c1e1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -107,7 +107,7 @@ bool shouldSaveConfig = false; //WiFiManager callback notifying us of the need to save config void saveConfigCallback () { - Serial.println("Should save config"); + logPrintlnI("Should save config"); shouldSaveConfig = true; } @@ -316,26 +316,26 @@ void reconnect() { void setup() { Serial.begin(115200); - Serial.println("Booting..."); + logPrintlnI("Booting..."); pinMode(BUTTON_ROTATION, INPUT_PULLUP); pinMode(BUTTON_SETUP, INPUT_PULLUP); pinMode(STATUS_LED, OUTPUT); display_begin(); - Serial.println("Display init..."); + logPrintlnI("Display init..."); display_init(VERSION); delay(2000); //read configuration from Flash json - Serial.println("mounting Flash..."); + logPrintlnI("mounting Flash..."); if (Flash.begin()) { - Serial.println("mounted file system"); + logPrintlnI("mounted file system"); if (Flash.exists("/config.json")) { //file exists, reading and loading - Serial.println("reading config file"); + logPrintlnI("reading config file"); File configFile = Flash.open("/config.json", "r"); if (configFile) { - Serial.println("opened config file"); + logPrintlnI("opened config file"); size_t size = configFile.size(); // Allocate a buffer to store contents of the file. std::unique_ptr buf(new char[size]); @@ -353,7 +353,7 @@ void setup() { json.printTo(Serial); if (json.success()) { #endif - Serial.println("\nparsed json"); + logPrintlnI("\nparsed json"); strcpy(mqtt_server, json["mqtt_server"]); strcpy(gx_vrm_id, json["gx_vrm_id"]); strcpy(disp_refresh_interval, json["disp_refresh_interval"]); @@ -369,13 +369,13 @@ void setup() { strcpy(show_graph, json["show_graph"]); strcpy(show_statistics, json["show_statistics"]); } else { - Serial.println("failed to load json config"); + logPrintlnI("failed to load json config"); } configFile.close(); } } } else { - Serial.println("failed to mount Flash"); + logPrintlnI("failed to mount Flash"); } delay(2000); @@ -508,7 +508,7 @@ void setup() { display_text((char*)" Connected. IP:", ip_address); //save the custom parameters to Flash if (shouldSaveConfig) { - Serial.println("saving config"); + logPrintlnI("saving config"); #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 DynamicJsonDocument json(1024); #else @@ -532,7 +532,7 @@ void setup() { File configFile = Flash.open("/config.json", "w"); if (!configFile) { - Serial.println("failed to open config file for writing"); + logPrintlnI("failed to open config file for writing"); } #if defined(ARDUINOJSON_VERSION_MAJOR) && ARDUINOJSON_VERSION_MAJOR >= 6 @@ -563,42 +563,42 @@ void setup() { delay(1000); //for screen display //Generate mqtt topics from id and address - Serial.println(); - Serial.println("-------------- MQTT topic list --------------"); + logPrintlnI("-------------- MQTT topic list --------------"); sprintf(mqtt_pv_voltage, "N/%s/solarcharger/%s/Pv/V", gx_vrm_id, address_pv_charger); - Serial.println(mqtt_pv_voltage); + logPrintlnI(mqtt_pv_voltage); sprintf(mqtt_pv_power, "N/%s/solarcharger/%s/Yield/Power", gx_vrm_id, address_pv_charger); - Serial.println(mqtt_pv_power); + logPrintlnI(mqtt_pv_power); sprintf(mqtt_pv_yield, "N/%s/solarcharger/%s/History/Daily/0/Yield", gx_vrm_id, address_pv_charger); - Serial.println(mqtt_pv_yield); + logPrintlnI(mqtt_pv_yield); sprintf(mqtt_pv_bat_current, "N/%s/solarcharger/%s/Dc/0/Current", gx_vrm_id, address_pv_charger); - Serial.println(mqtt_pv_bat_current); + logPrintlnI(mqtt_pv_bat_current); sprintf(mqtt_grid_power, "N/%s/grid/%s/Ac/Power", gx_vrm_id, address_grid_meter); - Serial.println(mqtt_grid_power); + logPrintlnI(mqtt_grid_power); sprintf(mqtt_inv_power, "N/%s/vebus/%s/Ac/ActiveIn/L1/P", gx_vrm_id, address_inverter); - Serial.println(mqtt_inv_power); + logPrintlnI(mqtt_inv_power); sprintf(mqtt_inv_current, "N/%s/vebus/%s/Dc/0/Current", gx_vrm_id, address_inverter); - Serial.println(mqtt_inv_current); + logPrintlnI(mqtt_inv_current); sprintf(mqtt_bat_soc, "N/%s/battery/%s/Soc", gx_vrm_id, address_battery); - Serial.println(mqtt_bat_soc); + logPrintlnI(mqtt_bat_soc); sprintf(mqtt_bat_voltage, "N/%s/battery/%s/Dc/0/Voltage", gx_vrm_id, address_battery); - Serial.println(mqtt_bat_voltage); + logPrintlnI(mqtt_bat_voltage); sprintf(mqtt_bat_current, "N/%s/battery/%s/Dc/0/Current", gx_vrm_id, address_battery); - Serial.println(mqtt_bat_current); + logPrintlnI(mqtt_bat_current); sprintf(mqtt_bat_power, "N/%s/battery/%s/Dc/0/Power", gx_vrm_id, address_battery); - Serial.println(mqtt_bat_power); + logPrintlnI(mqtt_bat_power); sprintf(mqtt_bat_max_cell_volt, "N/%s/battery/%s/System/MaxCellVoltage", gx_vrm_id, address_battery); - Serial.println(mqtt_bat_max_cell_volt); + logPrintlnI(mqtt_bat_max_cell_volt); sprintf(mqtt_bat_min_cell_volt, "N/%s/battery/%s/System/MinCellVoltage", gx_vrm_id, address_battery); - Serial.println(mqtt_bat_min_cell_volt); + logPrintlnI(mqtt_bat_min_cell_volt); sprintf(mqtt_temp_outside, "N/%s/temperature/%s/Temperature", gx_vrm_id, address_outside_temperature); - Serial.println(mqtt_temp_outside); + logPrintlnI(mqtt_temp_outside); sprintf(mqtt_grid_power_l1, "N/%s/system/0/Ac/ConsumptionOnInput/L1/Power", gx_vrm_id); - Serial.println(mqtt_grid_power_l1); + logPrintlnI(mqtt_grid_power_l1); sprintf(mqtt_grid_power_l2, "N/%s/system/0/Ac/ConsumptionOnInput/L2/Power", gx_vrm_id); - Serial.println(mqtt_grid_power_l2); + logPrintlnI(mqtt_grid_power_l2); sprintf(mqtt_grid_power_l3, "N/%s/system/0/Ac/ConsumptionOnInput/L3/Power", gx_vrm_id); - Serial.println(mqtt_grid_power_l3); + logPrintlnI(mqtt_grid_power_l3); + Serial.println(); Serial.println("-------------- Settings --------------"); Serial.print("mqtt server: "); Serial.println(mqtt_server);