Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sorriso93 authored Jun 10, 2019
1 parent 6ffc228 commit f04c36b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
6 changes: 3 additions & 3 deletions IOTroutertraffic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions display_mgm_espi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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,
Expand Down
15 changes: 10 additions & 5 deletions preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -133,14 +137,15 @@ 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)
max_speed_r = kbytes_r_xfreq;
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
}

Expand Down

0 comments on commit f04c36b

Please sign in to comment.