diff --git a/IOTroutertraffic.ino b/IOTroutertraffic.ino index 1beb4cd..4073f92 100644 --- a/IOTroutertraffic.ino +++ b/IOTroutertraffic.ino @@ -46,13 +46,13 @@ void setup() setup_display(); // DISPLAY cancella_display(); accendi_backlight(); - scrivi_display_riga_colore ("CONNECT TO WIFI\r\n"+String(name_sensor_default),32, TFT_BLACK); + scrivi_display_riga_colore (" CONNECT TO WIFI\r\n"+String(name_sensor_default),32, TFT_BLACK); WiFiManager wifiManager; wifiManager.autoConnect(name_sensor_default); setup_OTA_MAX(); cancella_display(); - scrivi_display_riga_colore ("IOT Traffic\r\n\r\n by MAX",32,TFT_YELLOW); + scrivi_display_riga_colore (" IOT Traffic\r\n\r\n by MAX",32,TFT_YELLOW); delay(2000); cancella_display(); @@ -72,7 +72,7 @@ void setup() //No time via NTP I reset cancella_display(); DEBUG_PRINTLN("No time, reset"); - scrivi_display_riga_colore ("NO\r\nNETWORK\r\nTIME",16, TFT_GREEN); + scrivi_display_riga_colore (" NO\r\n NETWORK\r\n TIME",16, TFT_GREEN); delay(2000); ESP.reset(); // resetto se non riceve l'orario da server NTP delay(1000); diff --git a/display_mgm_espi.h b/display_mgm_espi.h index 0c28d9a..0709a22 100644 --- a/display_mgm_espi.h +++ b/display_mgm_espi.h @@ -146,7 +146,7 @@ int scan = 1; for (int8_t j = 0; j < 2 * (i + 1); j++) { if (quality > i * 25 || j == 0) { - tft.drawPixel(305 + 2 * i, 6 - j, TFT_WHITE); + tft.drawPixel(309 + 2 * i, 6 - j, TFT_WHITE); } } } @@ -682,19 +682,19 @@ void disegna(long int received_speed, long int sent_speed, int avg_time_ms) Time =(Time *2) ;//timedelay compensation double gx = 1, gy = 185, w = 210, h = 170; - if (millis() - runTime >= (Time*5000)) - { - runTime=millis(); - //tft.fillRect(0,gy-h,gx+w,gy,BLACK); - tft.fillRect(0,0,320,240,BLACK); - scan=1; ///resets X axis - x=scan; - max_speed_r=300; max_speed_s = 100; - graph_3=true; /// add graphs affected by resetting screen - graph_1=true; // radial meters are un affected - graph_2=true; - graph_4=true; - } + if (millis() - runTime >= (Time*5000)) + { + runTime=millis(); + //tft.fillRect(0,gy-h,gx+w,gy,BLACK); + tft.fillRect(0,0,320,240,BLACK); + scan=1; ///resets X axis + x=scan; + max_speed_r=300; max_speed_s = 100; + graph_3=true; /// add graphs affected by resetting screen + graph_1=true; // radial meters are un affected + graph_2=true; + graph_4=true; + } drawWifiQuality(); //void Graph(TFT_eSPI &d, double x, double y, double gx, double gy, double w, double h, double xlo, double xhi, diff --git a/preferences.h b/preferences.h index 3a07e03..f1303ca 100644 --- a/preferences.h +++ b/preferences.h @@ -111,19 +111,23 @@ String twoDigits(int digits); void callback(char* topic, byte* payload, unsigned int length) { #ifndef publisher + StaticJsonBuffer<1024> buffer2_MQTT; + //JsonObject& stampa_MQTT = buffer2_MQTT.createObject(); String messaggio; - char msg[1024]; + char msg[1024] = ""; + JsonVariant read_MQTT; + int i; for (int i = 0; i < length; i++) { messaggio += (char)payload[i]; } - DEBUG_PRINT("MQTT Message arrived ["); + DEBUG_PRINT("MQTT Message ["); DEBUG_PRINT(messaggio); DEBUG_PRINTLN("] "); messaggio.toCharArray(msg,1024); - JsonVariant read_MQTT = buffer_MQTT.parseObject(msg); //only deserialization, assignement to variables to graph data is made in main code - if (!stampa_MQTT.success()) + read_MQTT = buffer2_MQTT.parseObject(msg); //only deserialization, assignement to variables to graph data is made in main code + if (!read_MQTT.success()) { DEBUG_PRINT("Json parsing error"); //additional things? return; @@ -133,7 +137,7 @@ String twoDigits(int digits); kbytes_r_xfreq = read_MQTT[String("Kbsec_rec")]; kbytes_s_xfreq = read_MQTT[String("Kbsec_sent")]; avg_time_ms = read_MQTT[String("ping")]; - DEBUG_PRINTLN("kbsec_r = "+String(kbytes_r_xfreq)+"kbsec_s = "+String(kbytes_s_xfreq)+"avg_ping = "+String(avg_time_ms)); + DEBUG_PRINTLN("kbsec_r = "+String(kbytes_r_xfreq)+" kbsec_s = "+String(kbytes_s_xfreq)+" avg_ping = "+String(avg_time_ms)); } // max & min update if (max_speed_r < kbytes_r_xfreq) @@ -141,6 +145,7 @@ String twoDigits(int digits); if (max_speed_s < kbytes_s_xfreq) max_speed_s = kbytes_s_xfreq; disegna (kbytes_r_xfreq, kbytes_s_xfreq, avg_time_ms); //kbytes per second on lcd screen + messaggio = ""; #endif }