mirror of
https://github.com/bcomsugi/VSS_Rally_V3.git
synced 2026-01-11 10:52:38 +07:00
fix some bug
This commit is contained in:
parent
7e2ed058a6
commit
bda7666301
29
src/index.h
29
src/index.h
@ -65,6 +65,7 @@ const char HTML_startrally[] PROGMEM = R"rawliteral(
|
|||||||
};
|
};
|
||||||
ws.onmessage = function(event) {
|
ws.onmessage = function(event) {
|
||||||
// console.log(event.data);
|
// console.log(event.data);
|
||||||
|
if(event.data && IsJsonString(event.data)){
|
||||||
let data = JSON.parse(event.data);
|
let data = JSON.parse(event.data);
|
||||||
// if (data.hasOwnProperty("ping")) {
|
// if (data.hasOwnProperty("ping")) {
|
||||||
// console.log("with ping key");
|
// console.log("with ping key");
|
||||||
@ -99,8 +100,19 @@ const char HTML_startrally[] PROGMEM = R"rawliteral(
|
|||||||
document.getElementById("tdiff1").innerHTML = data.TDiff;
|
document.getElementById("tdiff1").innerHTML = data.TDiff;
|
||||||
document.getElementById("tdiff2").innerHTML = data.TDiff;
|
document.getElementById("tdiff2").innerHTML = data.TDiff;
|
||||||
// }
|
// }
|
||||||
|
} else console.log(event.data);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function IsJsonString(str) {
|
||||||
|
try {
|
||||||
|
JSON.parse(str);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
const checkhealt = setInterval(checkPing, 1000); //heartbeat
|
const checkhealt = setInterval(checkPing, 1000); //heartbeat
|
||||||
|
|
||||||
function checkPing(){
|
function checkPing(){
|
||||||
@ -176,7 +188,7 @@ const char HTML_startrally[] PROGMEM = R"rawliteral(
|
|||||||
</div>
|
</div>
|
||||||
<!--//ODO1-->
|
<!--//ODO1-->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-5 "><h3>OD 1>> <span id="odo1">123.456</span> km</h3></div>
|
<div class="col-5 "><h3>OD 1>> <span id="odo1">123.456</span> Km</h3></div>
|
||||||
<div class="col-3"><h3><span id="dir1">DIRECT</span></h3></div>
|
<div class="col-3"><h3><span id="dir1">DIRECT</span></h3></div>
|
||||||
<div class="col-1"><h3><span id="tdiff1">TDiff</span>:</h3></div>
|
<div class="col-1"><h3><span id="tdiff1">TDiff</span>:</h3></div>
|
||||||
<div class="col-3 text-end"><h3><span id="time1">00:00:00</span></h3></div>
|
<div class="col-3 text-end"><h3><span id="time1">00:00:00</span></h3></div>
|
||||||
@ -203,7 +215,7 @@ const char HTML_startrally[] PROGMEM = R"rawliteral(
|
|||||||
-->
|
-->
|
||||||
<!--//ODO2-->
|
<!--//ODO2-->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-5 "><h3>OD 2>> <span id="odo2">123.456</span> km</h3></div>
|
<div class="col-5 "><h3>OD 2>> <span id="odo2">123.456</span> Km</h3></div>
|
||||||
<div class="col-3 "><h3><span id="dir2">DIRECT</span></h3></div>
|
<div class="col-3 "><h3><span id="dir2">DIRECT</span></h3></div>
|
||||||
<div class="col-1"><h3><span id="tdiff2">TDiff</span>:</h3></div>
|
<div class="col-1"><h3><span id="tdiff2">TDiff</span>:</h3></div>
|
||||||
<div class="col-3 text-end"><h3><span id="time2">00:00:00</span></h3></div>
|
<div class="col-3 text-end"><h3><span id="time2">00:00:00</span></h3></div>
|
||||||
@ -505,7 +517,8 @@ const char HTML_SETTIME[] PROGMEM = R"rawliteral(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
ws.onmessage = function(event) {
|
ws.onmessage = function(event) {
|
||||||
console.log(event.data);
|
// console.log(event.data);
|
||||||
|
if (IsJsonString(event.data)){
|
||||||
var data = JSON.parse(event.data);
|
var data = JSON.parse(event.data);
|
||||||
if (data.NTPTime=="N/A") document.getElementById("btnNTP").disabled = true;
|
if (data.NTPTime=="N/A") document.getElementById("btnNTP").disabled = true;
|
||||||
else document.getElementById("btnNTP").disabled = false;
|
else document.getElementById("btnNTP").disabled = false;
|
||||||
@ -518,7 +531,17 @@ const char HTML_SETTIME[] PROGMEM = R"rawliteral(
|
|||||||
// document.getElementById("calkm").innerHTML = data.calkm;
|
// document.getElementById("calkm").innerHTML = data.calkm;
|
||||||
// document.getElementById("calmeter").innerHTML = data.calmeter;
|
// document.getElementById("calmeter").innerHTML = data.calmeter;
|
||||||
// document.getElementById("calval").innerHTML = data.calval;
|
// document.getElementById("calval").innerHTML = data.calval;
|
||||||
|
} else console.log(event.data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function IsJsonString(str) {
|
||||||
|
try {
|
||||||
|
JSON.parse(str);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head><body>
|
</head><body>
|
||||||
<!--
|
<!--
|
||||||
|
|||||||
745
src/main.cpp
745
src/main.cpp
@ -1700,404 +1700,405 @@ void fillSetTimeJsonForESP32()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void redrawrallyMenu()
|
// void redrawrallyMenu()
|
||||||
{
|
// {
|
||||||
// Serial.println("redrawRM");
|
// // Serial.println("redrawRM");
|
||||||
// DS3231_get(&t); //Get time
|
// // DS3231_get(&t); //Get time
|
||||||
//runningtime(6,0);
|
// //runningtime(6,0);
|
||||||
//float distance, distance1, distance2;
|
// //float distance, distance1, distance2;
|
||||||
|
|
||||||
//Serial.print(tempcount1);Serial.print(";"); Serial.print(time1);Serial.print("; ");Serial.print(Calibration); Serial.print(";"); Serial.println(count1);
|
// //Serial.print(tempcount1);Serial.print(";"); Serial.print(time1);Serial.print("; ");Serial.print(Calibration); Serial.print(";"); Serial.println(count1);
|
||||||
updateCount();
|
// updateCount();
|
||||||
|
|
||||||
distance1 = (float)count1/((float)Calibration); // * 1);
|
// distance1 = (float)count1/((float)Calibration); // * 1);
|
||||||
distance2 = (float)count2/((float)Calibration);
|
// distance2 = (float)count2/((float)Calibration);
|
||||||
float speed1=0;
|
// float speed1=0;
|
||||||
|
|
||||||
if ((distance1 - startdistance) > 0) {
|
// if ((distance1 - startdistance) > 0) {
|
||||||
speed1 = (distance1-startdistance)/(millis()-startspeed)*3600000;
|
// speed1 = (distance1-startdistance)/(millis()-startspeed)*3600000;
|
||||||
}
|
// }
|
||||||
|
|
||||||
startdistance = distance1;
|
// startdistance = distance1;
|
||||||
startspeed = millis(); //startspeed is only one no startspeed2
|
// startspeed = millis(); //startspeed is only one no startspeed2
|
||||||
// Serial.println("redrawRM 1");
|
// // Serial.println("redrawRM 1");
|
||||||
if ((millis()-startsavemillis)>0) {
|
// if ((millis()-startsavemillis)>0) {
|
||||||
|
|
||||||
if (distance1 != prevdistance1) {
|
// if (distance1 != prevdistance1) {
|
||||||
mem.writeFloat(832,distance1);
|
// mem.writeFloat(832,distance1);
|
||||||
prevdistance1 = distance1;
|
// prevdistance1 = distance1;
|
||||||
}
|
// }
|
||||||
if (distance2 != prevdistance2) {
|
// if (distance2 != prevdistance2) {
|
||||||
mem.writeFloat(864,distance2);
|
// mem.writeFloat(864,distance2);
|
||||||
prevdistance2 = distance2;
|
// prevdistance2 = distance2;
|
||||||
}
|
// }
|
||||||
saveCount();
|
// saveCount();
|
||||||
startsavemillis=millis()+2500;
|
// startsavemillis=millis()+2500;
|
||||||
}
|
// }
|
||||||
//Serial.print(tempcount1);Serial.print(";"); Serial.print(time1);Serial.print("; ");Serial.print(Calibration); Serial.print(";"); Serial.println(count1);
|
// //Serial.print(tempcount1);Serial.print(";"); Serial.print(time1);Serial.print("; ");Serial.print(Calibration); Serial.print(";"); Serial.println(count1);
|
||||||
|
|
||||||
//Serial.print(millis());Serial.print(";");Serial.println(distance1,3);
|
// //Serial.print(millis());Serial.print(";");Serial.println(distance1,3);
|
||||||
//Serial.print(starttracthour); Serial.print(":"); Serial.print(starttractmin); Serial.print(":"); Serial.println(starttractsec);
|
// //Serial.print(starttracthour); Serial.print(":"); Serial.print(starttractmin); Serial.print(":"); Serial.println(starttractsec);
|
||||||
//Serial.println(distance2,3);
|
// //Serial.println(distance2,3);
|
||||||
|
|
||||||
// lcd.setCursor(4,0);
|
// // lcd.setCursor(4,0);
|
||||||
// lcd.print(Trip[curTrip].sub);
|
// // lcd.print(Trip[curTrip].sub);
|
||||||
// lcd.setCursor(0,2);
|
// // lcd.setCursor(0,2);
|
||||||
|
|
||||||
// lcd.print(Trip[curTrip].speed);
|
// // lcd.print(Trip[curTrip].speed);
|
||||||
// lcd.print("Km/H");
|
// // lcd.print("Km/H");
|
||||||
|
|
||||||
runningtime(6,0);
|
// runningtime(6,0);
|
||||||
|
|
||||||
// lcd.setCursor(11,2);
|
// // lcd.setCursor(11,2);
|
||||||
// char cur_speed_str[6];
|
// // char cur_speed_str[6];
|
||||||
int speedtemp=(int)speed1;
|
// int speedtemp=(int)speed1;
|
||||||
int speedtemp2=(int)((speed1 - (int)speed1)*10);
|
// int speedtemp2=(int)((speed1 - (int)speed1)*10);
|
||||||
|
|
||||||
sprintf(gcur_speed_str, "%3d.%01d", speedtemp , speedtemp2 );
|
// sprintf(gcur_speed_str, "%3d.%01d", speedtemp , speedtemp2 );
|
||||||
// Serial.print(count1); Serial.print(";");Serial.print(Calibration); Serial.print(";");Serial.print(speed1); Serial.print(";");Serial.println(cur_speed_str);
|
// // Serial.print(count1); Serial.print(";");Serial.print(Calibration); Serial.print(";");Serial.print(speed1); Serial.print(";");Serial.println(cur_speed_str);
|
||||||
// Serial.print(distance1); Serial.print(";");Serial.print(startdistance); Serial.print(";");Serial.print(startspeed); Serial.println(";");
|
// // Serial.print(distance1); Serial.print(";");Serial.print(startdistance); Serial.print(";");Serial.print(startspeed); Serial.println(";");
|
||||||
// lcd.print(cur_speed_str);
|
// // lcd.print(cur_speed_str);
|
||||||
// char cur_distance1_str[7];
|
// // char cur_distance1_str[7];
|
||||||
// char cur_distance2_str[7];
|
// // char cur_distance2_str[7];
|
||||||
// lcd.setCursor(0,1);
|
// // lcd.setCursor(0,1);
|
||||||
|
|
||||||
if (distance1<100) {
|
// if (distance1<100) {
|
||||||
sprintf(gcur_distance1_str, "%02d.%03d", (int)distance1, (int)((distance1 - (int)distance1)*1000));
|
// sprintf(gcur_distance1_str, "%02d.%03d", (int)distance1, (int)((distance1 - (int)distance1)*1000));
|
||||||
}
|
// }
|
||||||
else if (distance1<1000) {
|
// else if (distance1<1000) {
|
||||||
sprintf(gcur_distance1_str, "%02d.%02d", (int)distance1, (int)((distance1 - (int)distance1)*100));
|
// sprintf(gcur_distance1_str, "%02d.%02d", (int)distance1, (int)((distance1 - (int)distance1)*100));
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
sprintf(gcur_distance1_str, "%03d.%01d", (int)distance1, (int)((distance1 - (int)distance1)*10));
|
// sprintf(gcur_distance1_str, "%03d.%01d", (int)distance1, (int)((distance1 - (int)distance1)*10));
|
||||||
}
|
// }
|
||||||
// lcd.print(cur_distance1_str);
|
// // lcd.print(cur_distance1_str);
|
||||||
|
|
||||||
// lcd.setCursor(0,3);
|
// // lcd.setCursor(0,3);
|
||||||
if (distance2<100) {
|
// if (distance2<100) {
|
||||||
sprintf(gcur_distance2_str, "%02d.%03d", (int)distance2, (int)((distance2 - (int)distance2)*1000));
|
// sprintf(gcur_distance2_str, "%02d.%03d", (int)distance2, (int)((distance2 - (int)distance2)*1000));
|
||||||
}
|
// }
|
||||||
else if (distance2<1000) {
|
// else if (distance2<1000) {
|
||||||
sprintf(gcur_distance2_str, "%02d.%02d", (int)distance2, (int)((distance2 - (int)distance2)*100));
|
// sprintf(gcur_distance2_str, "%02d.%02d", (int)distance2, (int)((distance2 - (int)distance2)*100));
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
sprintf(gcur_distance2_str, "%03d.%01d", (int)distance2, (int)((distance2 - (int)distance2)*10));
|
// sprintf(gcur_distance2_str, "%03d.%01d", (int)distance2, (int)((distance2 - (int)distance2)*10));
|
||||||
}
|
// }
|
||||||
// lcd.print(cur_distance2_str);
|
// // lcd.print(cur_distance2_str);
|
||||||
// Serial.print(";redrawRM 3;");
|
// // Serial.print(";redrawRM 3;");
|
||||||
float distancetime1 = distance1 * 60 / constanta;
|
// float distancetime1 = distance1 * 60 / constanta;
|
||||||
float distancetime2 = distance2 * 60 / constanta;
|
// float distancetime2 = distance2 * 60 / constanta;
|
||||||
|
|
||||||
//Calculating all about TIME,TDiff(including passing 23:59:59)
|
// //Calculating all about TIME,TDiff(including passing 23:59:59)
|
||||||
// lcd.setCursor(9,1);
|
// // lcd.setCursor(9,1);
|
||||||
int secs1, mins1, hours1;
|
// int secs1, mins1, hours1;
|
||||||
|
|
||||||
secs1 = (distancetime1-(int)distancetime1)*60;
|
// secs1 = (distancetime1-(int)distancetime1)*60;
|
||||||
mins1 = (int)distancetime1 % 60;
|
// mins1 = (int)distancetime1 % 60;
|
||||||
hours1 = (int)distancetime1 / 60;
|
// hours1 = (int)distancetime1 / 60;
|
||||||
unsigned long totcurrentsecs = t.sec + (t.min*60) + ((long)t.hour*3600);
|
// unsigned long totcurrentsecs = t.sec + (t.min*60) + ((long)t.hour*3600);
|
||||||
unsigned long totsecs1 = secs1 + (mins1*60) + ((long)hours1*3600);
|
// unsigned long totsecs1 = secs1 + (mins1*60) + ((long)hours1*3600);
|
||||||
unsigned long totstarttractsecs = starttractsec + (starttractmin*60) + ((long)starttracthour*3600);
|
// unsigned long totstarttractsecs = starttractsec + (starttractmin*60) + ((long)starttracthour*3600);
|
||||||
unsigned long tottime1 = totsecs1 + totstarttractsecs;
|
// unsigned long tottime1 = totsecs1 + totstarttractsecs;
|
||||||
boolean negatifsign1 = false;
|
// boolean negatifsign1 = false;
|
||||||
boolean negatifsign2 = false;
|
// boolean negatifsign2 = false;
|
||||||
// Serial.print(";redrawRM 4;");
|
// // Serial.print(";redrawRM 4;");
|
||||||
//Serial.print((long)starttracthour*3600); Serial.print(";"); Serial.print(starttractmin*60); Serial.println(";");
|
// //Serial.print((long)starttracthour*3600); Serial.print(";"); Serial.print(starttractmin*60); Serial.println(";");
|
||||||
//Serial.print(totsecs1); Serial.print(";"); Serial.print(totstarttractsecs); Serial.print(";");
|
// //Serial.print(totsecs1); Serial.print(";"); Serial.print(totstarttractsecs); Serial.print(";");
|
||||||
//Serial.print(tottime1);Serial.print(";");Serial.println(totcurrentsecs);
|
// //Serial.print(tottime1);Serial.print(";");Serial.println(totcurrentsecs);
|
||||||
if (totcurrentsecs<totstarttractsecs) totcurrentsecs+=86400;
|
// if (totcurrentsecs<totstarttractsecs) totcurrentsecs+=86400;
|
||||||
|
|
||||||
if (!showTIME) {
|
// if (!showTIME) {
|
||||||
if (tottime1 >= totcurrentsecs) { //positif means we are too fast, slow down please.
|
// if (tottime1 >= totcurrentsecs) { //positif means we are too fast, slow down please.
|
||||||
// Serial.println("pos");
|
// // Serial.println("pos");
|
||||||
negatifsign1 = false;
|
// negatifsign1 = false;
|
||||||
tottime1 = tottime1 - totcurrentsecs;
|
// tottime1 = tottime1 - totcurrentsecs;
|
||||||
}
|
// }
|
||||||
else { //negatif means we need to hurry, its late
|
// else { //negatif means we need to hurry, its late
|
||||||
// Serial.println("neg");
|
// // Serial.println("neg");
|
||||||
negatifsign1 = true;
|
// negatifsign1 = true;
|
||||||
tottime1 = totcurrentsecs - tottime1;
|
// tottime1 = totcurrentsecs - tottime1;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
//Serial.print(negatifsign1);Serial.print(";"); Serial.println(tottime1);
|
// //Serial.print(negatifsign1);Serial.print(";"); Serial.println(tottime1);
|
||||||
hours1 = ((int)(tottime1 / 3600))%24;
|
// hours1 = ((int)(tottime1 / 3600))%24;
|
||||||
mins1 = (int)((tottime1 % 3600)/60);
|
// mins1 = (int)((tottime1 % 3600)/60);
|
||||||
secs1 = (tottime1 % 60);
|
// secs1 = (tottime1 % 60);
|
||||||
|
|
||||||
// char cur_time1_str[12];
|
// // char cur_time1_str[12];
|
||||||
if (showTIME) {
|
// if (showTIME) {
|
||||||
// sprintf(cur_time1_str, "%s %02d:%02d:%02d", dircount[dircount1], hours1, mins1, secs1);
|
// // sprintf(cur_time1_str, "%s %02d:%02d:%02d", dircount[dircount1], hours1, mins1, secs1);
|
||||||
sprintf(gcur_time1_str, " %02d:%02d:%02d", hours1, mins1, secs1);
|
// sprintf(gcur_time1_str, " %02d:%02d:%02d", hours1, mins1, secs1);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
// if (hours1 < 10) sprintf(cur_time1_str, "%s %s%01d:%02d:%02d", dircount[dircount1], (negatifsign1?"-":" "), hours1, mins1, secs1);
|
// // if (hours1 < 10) sprintf(cur_time1_str, "%s %s%01d:%02d:%02d", dircount[dircount1], (negatifsign1?"-":" "), hours1, mins1, secs1);
|
||||||
if (hours1 < 10) sprintf(gcur_time1_str, " %s%01d:%02d:%02d", (negatifsign1?"-":" "), hours1, mins1, secs1);
|
// if (hours1 < 10) sprintf(gcur_time1_str, " %s%01d:%02d:%02d", (negatifsign1?"-":" "), hours1, mins1, secs1);
|
||||||
// else sprintf(cur_time1_str, "%s%s%02d:%02d:%02d", dircount[dircount1], (negatifsign1?"-":" "), hours1, mins1, secs1);
|
// // else sprintf(cur_time1_str, "%s%s%02d:%02d:%02d", dircount[dircount1], (negatifsign1?"-":" "), hours1, mins1, secs1);
|
||||||
else sprintf(gcur_time1_str, "%s%02d:%02d:%02d", (negatifsign1?"-":" "), hours1, mins1, secs1);
|
// else sprintf(gcur_time1_str, "%s%02d:%02d:%02d", (negatifsign1?"-":" "), hours1, mins1, secs1);
|
||||||
|
|
||||||
}
|
// }
|
||||||
// lcd.setCursor(9,1);
|
// // lcd.setCursor(9,1);
|
||||||
// lcd.print(cur_time1_str);
|
// // lcd.print(cur_time1_str);
|
||||||
// Serial.println(cur_time1_str);
|
// // Serial.println(cur_time1_str);
|
||||||
// Serial.print((hours1));Serial.print(":");Serial.print((mins1));Serial.print(":");Serial.println((secs1));
|
// // Serial.print((hours1));Serial.print(":");Serial.print((mins1));Serial.print(":");Serial.println((secs1));
|
||||||
// Serial.print(";redrawRM 5;");
|
// // Serial.print(";redrawRM 5;");
|
||||||
// Print Second TIME
|
// // Print Second TIME
|
||||||
// lcd.setCursor(9,3);
|
// // lcd.setCursor(9,3);
|
||||||
int secs2, mins2, hours2;
|
// int secs2, mins2, hours2;
|
||||||
secs2 = (distancetime2-(int)distancetime2)*60;
|
// secs2 = (distancetime2-(int)distancetime2)*60;
|
||||||
mins2 = (int)distancetime2 % 60;
|
// mins2 = (int)distancetime2 % 60;
|
||||||
hours2 = (int)distancetime2 / 60;
|
// hours2 = (int)distancetime2 / 60;
|
||||||
|
|
||||||
unsigned long totsecs2 = secs2 + (mins2*60) + ((long)hours2*3600);
|
// unsigned long totsecs2 = secs2 + (mins2*60) + ((long)hours2*3600);
|
||||||
unsigned long tottime2 = totsecs2 + totstarttractsecs;
|
// unsigned long tottime2 = totsecs2 + totstarttractsecs;
|
||||||
|
|
||||||
if (!showTIME) {
|
// if (!showTIME) {
|
||||||
if (tottime2 >= totcurrentsecs) { //positif means we are too fast, slow down please.
|
// if (tottime2 >= totcurrentsecs) { //positif means we are too fast, slow down please.
|
||||||
negatifsign2 = false;
|
// negatifsign2 = false;
|
||||||
tottime2 = tottime2 - totcurrentsecs;
|
// tottime2 = tottime2 - totcurrentsecs;
|
||||||
}
|
// }
|
||||||
else { //negatif means we need to hurry, its late
|
// else { //negatif means we need to hurry, its late
|
||||||
negatifsign2 = true;
|
// negatifsign2 = true;
|
||||||
tottime2 = totcurrentsecs - tottime2 ;
|
// tottime2 = totcurrentsecs - tottime2 ;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
// Serial.print(";redrawRM 6;");
|
// // Serial.print(";redrawRM 6;");
|
||||||
hours2 = ((int)(tottime2 / 3600))%24;
|
// hours2 = ((int)(tottime2 / 3600))%24;
|
||||||
mins2 = (int)((tottime2 % 3600)/60);
|
// mins2 = (int)((tottime2 % 3600)/60);
|
||||||
secs2 = (tottime2 % 60);
|
// secs2 = (tottime2 % 60);
|
||||||
// char cur_time2_str[12];
|
// // char cur_time2_str[12];
|
||||||
if (showTIME) {
|
// if (showTIME) {
|
||||||
sprintf(gcur_time2_str, " %02d:%02d:%02d", hours2, mins2, secs2);
|
// sprintf(gcur_time2_str, " %02d:%02d:%02d", hours2, mins2, secs2);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
if (hours2<10) sprintf(gcur_time2_str, " %s%01d:%02d:%02d", (negatifsign2?"-":" "), hours2, mins2, secs2);
|
// if (hours2<10) sprintf(gcur_time2_str, " %s%01d:%02d:%02d", (negatifsign2?"-":" "), hours2, mins2, secs2);
|
||||||
else sprintf(gcur_time2_str, "%s%02d:%02d:%02d", (negatifsign2?"-":" "), hours2, mins2, secs2);
|
// else sprintf(gcur_time2_str, "%s%02d:%02d:%02d", (negatifsign2?"-":" "), hours2, mins2, secs2);
|
||||||
}
|
// }
|
||||||
|
|
||||||
lcd.setCursor(4,0);
|
// lcd.setCursor(4,0);
|
||||||
lcd.print(Trip[curTrip].sub);
|
// lcd.print(Trip[curTrip].sub);
|
||||||
lcd.setCursor(0,2);
|
// lcd.setCursor(0,2);
|
||||||
lcd.print(Trip[curTrip].speed);
|
// lcd.print(Trip[curTrip].speed);
|
||||||
lcd.print("Km/H");
|
// lcd.print("Km/H");
|
||||||
|
|
||||||
lcd.setCursor(11,2);
|
// lcd.setCursor(11,2);
|
||||||
lcd.print(gcur_speed_str);
|
// lcd.print(gcur_speed_str);
|
||||||
lcd.print("Km/H");
|
// lcd.setCursor(16,2);
|
||||||
|
// lcd.print("Km/H");
|
||||||
|
|
||||||
lcd.setCursor(0,1);
|
// lcd.setCursor(0,1);
|
||||||
|
|
||||||
lcd.print(gcur_distance1_str);
|
// lcd.print(gcur_distance1_str);
|
||||||
lcd.print("Km");
|
// lcd.print("Km");
|
||||||
|
|
||||||
lcd.setCursor(9,1);
|
// lcd.setCursor(9,1);
|
||||||
lcd.print(dircount[dircount1]);
|
// lcd.print(dircount[dircount1]);
|
||||||
lcd.print(gcur_time1_str);
|
// lcd.print(gcur_time1_str);
|
||||||
|
|
||||||
|
|
||||||
lcd.setCursor(0,3);
|
// lcd.setCursor(0,3);
|
||||||
|
|
||||||
lcd.print(gcur_distance2_str);
|
// lcd.print(gcur_distance2_str);
|
||||||
lcd.print("Km");
|
// lcd.print("Km");
|
||||||
|
|
||||||
lcd.setCursor(9,3);
|
// lcd.setCursor(9,3);
|
||||||
lcd.print(dircount[dircount2]);
|
// lcd.print(dircount[dircount2]);
|
||||||
lcd.print(gcur_time2_str);
|
// lcd.print(gcur_time2_str);
|
||||||
|
|
||||||
// Serial.print("x=");Serial.print(x);Serial.print("y=");Serial.print(y);Serial.println("");
|
// // Serial.print("x=");Serial.print(x);Serial.print("y=");Serial.print(y);Serial.println("");
|
||||||
|
|
||||||
lcd.setCursor(x,y);
|
// lcd.setCursor(x,y);
|
||||||
// Serial.println("END redrawRM");
|
// // Serial.println("END redrawRM");
|
||||||
}
|
// }
|
||||||
|
|
||||||
void calculationRally_BACKUP() //calculation only ESP32
|
// void calculationRally_BACKUP() //calculation only ESP32
|
||||||
{
|
// {
|
||||||
DynamicJsonDocument getRally(1024);
|
// DynamicJsonDocument getRally(1024);
|
||||||
deserializeJson(getRally, strRallyJson);
|
// deserializeJson(getRally, strRallyJson);
|
||||||
// DS3231_get(&t); //Get time
|
// // DS3231_get(&t); //Get time
|
||||||
// Serial.println("startCRal");
|
// // Serial.println("startCRal");
|
||||||
updateCount();
|
// updateCount();
|
||||||
|
|
||||||
distance1 = (float)count1/((float)Calibration); // * 1);
|
// distance1 = (float)count1/((float)Calibration); // * 1);
|
||||||
distance2 = (float)count2/((float)Calibration);
|
// distance2 = (float)count2/((float)Calibration);
|
||||||
float speed1=0;
|
// float speed1=0;
|
||||||
|
|
||||||
if ((distance1 - startdistance) > 0) {
|
// if ((distance1 - startdistance) > 0) {
|
||||||
speed1 = (distance1-startdistance)/(millis()-startspeed)*3600000;
|
// speed1 = (distance1-startdistance)/(millis()-startspeed)*3600000;
|
||||||
}
|
// }
|
||||||
|
|
||||||
startdistance = distance1;
|
// startdistance = distance1;
|
||||||
startspeed = millis(); //startspeed is only one no startspeed2
|
// startspeed = millis(); //startspeed is only one no startspeed2
|
||||||
|
|
||||||
if ((millis()-startsavemillis)>0) {
|
// if ((millis()-startsavemillis)>0) {
|
||||||
|
|
||||||
if (distance1 != prevdistance1) {
|
// if (distance1 != prevdistance1) {
|
||||||
mem.writeFloat(832,distance1);
|
// mem.writeFloat(832,distance1);
|
||||||
prevdistance1 = distance1;
|
// prevdistance1 = distance1;
|
||||||
}
|
// }
|
||||||
if (distance2 != prevdistance2) {
|
// if (distance2 != prevdistance2) {
|
||||||
mem.writeFloat(864,distance2);
|
// mem.writeFloat(864,distance2);
|
||||||
prevdistance2 = distance2;
|
// prevdistance2 = distance2;
|
||||||
}
|
// }
|
||||||
saveCount();
|
// saveCount();
|
||||||
startsavemillis=millis()+2500;
|
// startsavemillis=millis()+2500;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// lcd.setCursor(4,0);
|
// // lcd.setCursor(4,0);
|
||||||
// lcd.print(Trip[curTrip].sub);
|
// // lcd.print(Trip[curTrip].sub);
|
||||||
// lcd.setCursor(0,2);
|
// // lcd.setCursor(0,2);
|
||||||
|
|
||||||
// lcd.print(Trip[curTrip].speed);
|
// // lcd.print(Trip[curTrip].speed);
|
||||||
// lcd.print("Km/H");
|
// // lcd.print("Km/H");
|
||||||
getRally["Trip"]=String(Trip[curTrip].sub); /////
|
// getRally["Trip"]=String(Trip[curTrip].sub); /////
|
||||||
getRally["TSpeed"]=String(Trip[curTrip].speed); /////
|
// getRally["TSpeed"]=String(Trip[curTrip].speed); /////
|
||||||
char sTime[9]; //global can move to the sprintf to change change constanta
|
// char sTime[9]; //global can move to the sprintf to change change constanta
|
||||||
sprintf(sTime, "%02u:%02u:%02u", Trip[curTrip].startHour, Trip[curTrip].startMin, Trip[curTrip].startSec);
|
// sprintf(sTime, "%02u:%02u:%02u", Trip[curTrip].startHour, Trip[curTrip].startMin, Trip[curTrip].startSec);
|
||||||
getRally["TsTime"]=sTime; /////
|
// getRally["TsTime"]=sTime; /////
|
||||||
getRally["TTime"]=String(Trip[curTrip].subTime); /////
|
// getRally["TTime"]=String(Trip[curTrip].subTime); /////
|
||||||
getRally["TDist"]=String(Trip[curTrip].distance); /////
|
// getRally["TDist"]=String(Trip[curTrip].distance); /////
|
||||||
|
|
||||||
// Serial.print(Trip[curTrip].sub);Serial.print(Trip[curTrip].speed);Serial.print(";");Serial.println(Trip[curTrip].startHour);
|
// // Serial.print(Trip[curTrip].sub);Serial.print(Trip[curTrip].speed);Serial.print(";");Serial.println(Trip[curTrip].startHour);
|
||||||
|
|
||||||
gcurTime = runningtimeforESP32(6,0);
|
// gcurTime = runningtimeforESP32(6,0);
|
||||||
// String curTime = runningtimeforESP32(6,0);
|
// // String curTime = runningtimeforESP32(6,0);
|
||||||
// char curTime []= runningtimeforESP32(6,0);
|
// // char curTime []= runningtimeforESP32(6,0);
|
||||||
getRally["Time"]=gcurTime;
|
// getRally["Time"]=gcurTime;
|
||||||
// lcd.setCursor(11,2);
|
// // lcd.setCursor(11,2);
|
||||||
// char cur_speed_str[6];
|
// // char cur_speed_str[6];
|
||||||
sprintf(gcur_speed_str, "%3d.%01d", (int)speed1, (int)((speed1 - (int)speed1)*10));
|
// sprintf(gcur_speed_str, "%3d.%01d", (int)speed1, (int)((speed1 - (int)speed1)*10));
|
||||||
// lcd.print(cur_speed_str);
|
// // lcd.print(cur_speed_str);
|
||||||
getRally["curSpeed"]=gcur_speed_str; /////
|
// getRally["curSpeed"]=gcur_speed_str; /////
|
||||||
|
|
||||||
// char cur_distance1_plain[7];
|
// // char cur_distance1_plain[7];
|
||||||
// char cur_distance2_plain[7];
|
// // char cur_distance2_plain[7];
|
||||||
// lcd.setCursor(0,1);
|
// // lcd.setCursor(0,1);
|
||||||
|
|
||||||
if (distance1<100) {
|
// if (distance1<100) {
|
||||||
sprintf(gcur_distance1_str, "%02d.%03d", (int)distance1, (int)((distance1 - (int)distance1)*1000));
|
// sprintf(gcur_distance1_str, "%02d.%03d", (int)distance1, (int)((distance1 - (int)distance1)*1000));
|
||||||
}
|
// }
|
||||||
else if (distance1<1000) {
|
// else if (distance1<1000) {
|
||||||
sprintf(gcur_distance1_str, "%02d.%02d", (int)distance1, (int)((distance1 - (int)distance1)*100));
|
// sprintf(gcur_distance1_str, "%02d.%02d", (int)distance1, (int)((distance1 - (int)distance1)*100));
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
sprintf(gcur_distance1_str, "%03d.%01d", (int)distance1, (int)((distance1 - (int)distance1)*10));
|
// sprintf(gcur_distance1_str, "%03d.%01d", (int)distance1, (int)((distance1 - (int)distance1)*10));
|
||||||
}
|
// }
|
||||||
|
|
||||||
// lcd.print(cur_distance1_str);
|
// // lcd.print(cur_distance1_str);
|
||||||
getRally["curDist1"]=String(gcur_distance1_str);
|
// getRally["curDist1"]=String(gcur_distance1_str);
|
||||||
// lcd.setCursor(0,3);
|
// // lcd.setCursor(0,3);
|
||||||
|
|
||||||
if (distance2<100) {
|
// if (distance2<100) {
|
||||||
sprintf(gcur_distance2_str, "%02d.%03d", (int)distance2, (int)((distance2 - (int)distance2)*1000));
|
// sprintf(gcur_distance2_str, "%02d.%03d", (int)distance2, (int)((distance2 - (int)distance2)*1000));
|
||||||
}
|
// }
|
||||||
else if (distance2<1000) {
|
// else if (distance2<1000) {
|
||||||
sprintf(gcur_distance2_str, "%02d.%02d", (int)distance2, (int)((distance2 - (int)distance2)*100));
|
// sprintf(gcur_distance2_str, "%02d.%02d", (int)distance2, (int)((distance2 - (int)distance2)*100));
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
sprintf(gcur_distance2_str, "%03d.%01d", (int)distance2, (int)((distance2 - (int)distance2)*10));
|
// sprintf(gcur_distance2_str, "%03d.%01d", (int)distance2, (int)((distance2 - (int)distance2)*10));
|
||||||
}
|
// }
|
||||||
|
|
||||||
// lcd.print(cur_distance2_str);
|
// // lcd.print(cur_distance2_str);
|
||||||
getRally["curDist2"]=gcur_distance2_str;
|
// getRally["curDist2"]=gcur_distance2_str;
|
||||||
|
|
||||||
float distancetime1 = distance1 * 60 / constanta;
|
// float distancetime1 = distance1 * 60 / constanta;
|
||||||
float distancetime2 = distance2 * 60 / constanta;
|
// float distancetime2 = distance2 * 60 / constanta;
|
||||||
|
|
||||||
//Calculating all about TIME,TDiff(including passing 23:59:59)
|
// //Calculating all about TIME,TDiff(including passing 23:59:59)
|
||||||
// lcd.setCursor(9,1);
|
// // lcd.setCursor(9,1);
|
||||||
int secs1, mins1, hours1;
|
// int secs1, mins1, hours1;
|
||||||
|
|
||||||
secs1 = (distancetime1-(int)distancetime1)*60;
|
// secs1 = (distancetime1-(int)distancetime1)*60;
|
||||||
mins1 = (int)distancetime1 % 60;
|
// mins1 = (int)distancetime1 % 60;
|
||||||
hours1 = (int)distancetime1 / 60;
|
// hours1 = (int)distancetime1 / 60;
|
||||||
unsigned long totcurrentsecs = t.sec + (t.min*60) + ((long)t.hour*3600);
|
// unsigned long totcurrentsecs = t.sec + (t.min*60) + ((long)t.hour*3600);
|
||||||
unsigned long totsecs1 = secs1 + (mins1*60) + ((long)hours1*3600);
|
// unsigned long totsecs1 = secs1 + (mins1*60) + ((long)hours1*3600);
|
||||||
unsigned long totstarttractsecs = starttractsec + (starttractmin*60) + ((long)starttracthour*3600);
|
// unsigned long totstarttractsecs = starttractsec + (starttractmin*60) + ((long)starttracthour*3600);
|
||||||
unsigned long tottime1 = totsecs1 + totstarttractsecs;
|
// unsigned long tottime1 = totsecs1 + totstarttractsecs;
|
||||||
boolean negatifsign = false;
|
// boolean negatifsign = false;
|
||||||
|
|
||||||
if (totcurrentsecs<totstarttractsecs) totcurrentsecs+=86400;
|
// if (totcurrentsecs<totstarttractsecs) totcurrentsecs+=86400;
|
||||||
|
|
||||||
if (!showTIME) {
|
// if (!showTIME) {
|
||||||
//if ((long)(tottime1 - totcurrentsecs)>=0) { //positif means we are too fast, slow down please.
|
// //if ((long)(tottime1 - totcurrentsecs)>=0) { //positif means we are too fast, slow down please.
|
||||||
if (tottime1 >= totcurrentsecs) { //positif means we are too fast, slow down please.
|
// if (tottime1 >= totcurrentsecs) { //positif means we are too fast, slow down please.
|
||||||
// Serial.println("pos");
|
// // Serial.println("pos");
|
||||||
negatifsign = false;
|
// negatifsign = false;
|
||||||
tottime1 = tottime1 - totcurrentsecs;
|
// tottime1 = tottime1 - totcurrentsecs;
|
||||||
}
|
// }
|
||||||
else { //negatif means we need to hurry, its late
|
// else { //negatif means we need to hurry, its late
|
||||||
// Serial.println("neg");
|
// // Serial.println("neg");
|
||||||
negatifsign = true;
|
// negatifsign = true;
|
||||||
tottime1 = totcurrentsecs - tottime1;
|
// tottime1 = totcurrentsecs - tottime1;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
//Serial.print(negatifsign);Serial.print(";"); Serial.println(tottime1);
|
// //Serial.print(negatifsign);Serial.print(";"); Serial.println(tottime1);
|
||||||
hours1 = ((int)(tottime1 / 3600))%24;
|
// hours1 = ((int)(tottime1 / 3600))%24;
|
||||||
mins1 = (int)((tottime1 % 3600)/60);
|
// mins1 = (int)((tottime1 % 3600)/60);
|
||||||
secs1 = (tottime1 % 60);
|
// secs1 = (tottime1 % 60);
|
||||||
|
|
||||||
// char cur_time1_str[12];
|
// // char cur_time1_str[12];
|
||||||
// char cur_time1_plain[10];
|
// // char cur_time1_plain[10];
|
||||||
|
|
||||||
if (showTIME) {
|
// if (showTIME) {
|
||||||
sprintf(gcur_time1_str, " %02d:%02d:%02d", hours1, mins1, secs1);
|
// sprintf(gcur_time1_str, " %02d:%02d:%02d", hours1, mins1, secs1);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
if (hours1<10) sprintf(gcur_time1_str, " %s%01d:%02d:%02d", (negatifsign?"-":" "), hours1, mins1, secs1);
|
// if (hours1<10) sprintf(gcur_time1_str, " %s%01d:%02d:%02d", (negatifsign?"-":" "), hours1, mins1, secs1);
|
||||||
else sprintf(gcur_time1_str, "%s%02d:%02d:%02d", (negatifsign?"-":" "), hours1, mins1, secs1);
|
// else sprintf(gcur_time1_str, "%s%02d:%02d:%02d", (negatifsign?"-":" "), hours1, mins1, secs1);
|
||||||
}
|
// }
|
||||||
// lcd.print(cur_time1_str);
|
// // lcd.print(cur_time1_str);
|
||||||
getRally["time1"]=gcur_time1_str;
|
// getRally["time1"]=gcur_time1_str;
|
||||||
getRally["dir1"]=dircount[dircount1];
|
// getRally["dir1"]=dircount[dircount1];
|
||||||
|
|
||||||
// Print Second TIME
|
// // Print Second TIME
|
||||||
// lcd.setCursor(9,3);
|
// // lcd.setCursor(9,3);
|
||||||
int secs2, mins2, hours2;
|
// int secs2, mins2, hours2;
|
||||||
|
|
||||||
secs2 = (distancetime2-(int)distancetime2)*60;
|
// secs2 = (distancetime2-(int)distancetime2)*60;
|
||||||
mins2 = (int)distancetime2 % 60;
|
// mins2 = (int)distancetime2 % 60;
|
||||||
hours2 = (int)distancetime2 / 60;
|
// hours2 = (int)distancetime2 / 60;
|
||||||
|
|
||||||
unsigned long totsecs2 = secs2 + (mins2*60) + ((long)hours2*3600);
|
// unsigned long totsecs2 = secs2 + (mins2*60) + ((long)hours2*3600);
|
||||||
unsigned long tottime2 = totsecs2 + totstarttractsecs;
|
// unsigned long tottime2 = totsecs2 + totstarttractsecs;
|
||||||
//Serial.println(tottime2);
|
// //Serial.println(tottime2);
|
||||||
|
|
||||||
if (!showTIME) {
|
// if (!showTIME) {
|
||||||
if (tottime2 >= totcurrentsecs) { //positif means we are too fast, slow down please.
|
// if (tottime2 >= totcurrentsecs) { //positif means we are too fast, slow down please.
|
||||||
negatifsign = false;
|
// negatifsign = false;
|
||||||
tottime2 = tottime2 - totcurrentsecs;
|
// tottime2 = tottime2 - totcurrentsecs;
|
||||||
}
|
// }
|
||||||
else { //negatif means we need to hurry, its late
|
// else { //negatif means we need to hurry, its late
|
||||||
negatifsign = true;
|
// negatifsign = true;
|
||||||
tottime2 = totcurrentsecs - tottime2 ;
|
// tottime2 = totcurrentsecs - tottime2 ;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Serial.println("MidCRal");
|
// // Serial.println("MidCRal");
|
||||||
|
|
||||||
hours2 = ((int)(tottime2 / 3600))%24;
|
// hours2 = ((int)(tottime2 / 3600))%24;
|
||||||
mins2 = (int)((tottime2 % 3600)/60);
|
// mins2 = (int)((tottime2 % 3600)/60);
|
||||||
secs2 = (tottime2 % 60);
|
// secs2 = (tottime2 % 60);
|
||||||
// char cur_time2_str[12];
|
// // char cur_time2_str[12];
|
||||||
// char cur_time2_plain[9];
|
// // char cur_time2_plain[9];
|
||||||
|
|
||||||
if (showTIME) {
|
// if (showTIME) {
|
||||||
sprintf(gcur_time2_str, " %02d:%02d:%02d", hours2, mins2, secs2);
|
// sprintf(gcur_time2_str, " %02d:%02d:%02d", hours2, mins2, secs2);
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
if (hours2<10) sprintf(gcur_time2_str, " %s%01d:%02d:%02d", (negatifsign?"-":" "), hours2, mins2, secs2);
|
// if (hours2<10) sprintf(gcur_time2_str, " %s%01d:%02d:%02d", (negatifsign?"-":" "), hours2, mins2, secs2);
|
||||||
else sprintf(gcur_time2_str, "%s%02d:%02d:%02d", (negatifsign?"-":" "), hours2, mins2, secs2);
|
// else sprintf(gcur_time2_str, "%s%02d:%02d:%02d", (negatifsign?"-":" "), hours2, mins2, secs2);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// lcd.print(cur_time2_str);
|
// // lcd.print(cur_time2_str);
|
||||||
getRally["time2"]=gcur_time2_str;
|
// getRally["time2"]=gcur_time2_str;
|
||||||
getRally["dir2"]=dircount[dircount2];
|
// getRally["dir2"]=dircount[dircount2];
|
||||||
|
|
||||||
// lcd.setCursor(x,y);
|
// // lcd.setCursor(x,y);
|
||||||
getRally["counter"]=VSSCount;
|
// getRally["counter"]=VSSCount;
|
||||||
strRallyJson="";
|
// strRallyJson="";
|
||||||
serializeJson(getRally, strRallyJson);
|
// serializeJson(getRally, strRallyJson);
|
||||||
// Serial.println("ENDCRal");
|
// // Serial.println("ENDCRal");
|
||||||
} ///// calculation only for esp32
|
// } ///// calculation only for esp32
|
||||||
|
|
||||||
|
|
||||||
void calculationRally() //calculation only ESP32
|
void calculationRally() //calculation only ESP32
|
||||||
@ -2110,13 +2111,35 @@ void calculationRally() //calculation only ESP32
|
|||||||
float speed1=0;
|
float speed1=0;
|
||||||
distance2 = (float)count2/((float)Calibration);
|
distance2 = (float)count2/((float)Calibration);
|
||||||
distance1 = (float)count1/((float)Calibration); // * 1);
|
distance1 = (float)count1/((float)Calibration); // * 1);
|
||||||
|
if(distance1>=9999 || distance1<=-99) {
|
||||||
if ((distance1 - startdistance) > 0) {
|
distance1=0;
|
||||||
|
count1 = 0;
|
||||||
|
backcount1 = 0;
|
||||||
|
time1 = VSSCount;
|
||||||
|
}
|
||||||
|
if(distance2>=9999 || distance2<=-99) {
|
||||||
|
distance2=0;
|
||||||
|
count2 = 0;
|
||||||
|
backcount2 = 0;
|
||||||
|
time2 = VSSCount;
|
||||||
|
}
|
||||||
|
// Serial.print(dircount1);
|
||||||
|
if (dircount1!=FREEZE){ //if direction is freeze on the first odo, then calculate speed from second odo
|
||||||
|
// Serial.print(";not freeze;");Serial.println(distance1);
|
||||||
|
// if ((distance1 - startdistance) > 0) {
|
||||||
speed1 = (distance1-startdistance)/(millis()-startspeed)*3600000;
|
speed1 = (distance1-startdistance)/(millis()-startspeed)*3600000;
|
||||||
|
// }
|
||||||
|
startdistance = distance1;
|
||||||
|
} else {
|
||||||
|
// Serial.print(";not freeze;");Serial.println(distance1);
|
||||||
|
// if ((distance2 - startdistance) > 0) {
|
||||||
|
speed1 = (distance2-startdistance)/(millis()-startspeed)*3600000;
|
||||||
|
// }
|
||||||
|
startdistance = distance2;
|
||||||
}
|
}
|
||||||
startspeed = millis(); //startspeed is only one no startspeed2
|
startspeed = millis(); //startspeed is only one no startspeed2
|
||||||
startdistance = distance1;
|
// startdistance = distance1;
|
||||||
|
if(speed1 > 200 || speed1 < -200) speed1 = 0;
|
||||||
|
|
||||||
if ((millis()-startsavemillis)>0) {
|
if ((millis()-startsavemillis)>0) {
|
||||||
|
|
||||||
@ -2135,28 +2158,43 @@ void calculationRally() //calculation only ESP32
|
|||||||
delay(1);
|
delay(1);
|
||||||
gcurTime = runningtimeforESP32(6,0);
|
gcurTime = runningtimeforESP32(6,0);
|
||||||
|
|
||||||
sprintf(gcur_speed_str, "%3d.%01d", (int)speed1, (int)((speed1 - (int)speed1)*10));
|
sprintf(gcur_speed_str, "%3.01f", speed1);
|
||||||
|
// sprintf(gcur_speed_str, "%3.01f", (int)speed1, (int)((speed1 - (int)speed1)*10));
|
||||||
if (distance1<100) {
|
if (distance1<0) {
|
||||||
sprintf(gcur_distance1_str, "%02d.%03d", (int)distance1, (int)((distance1 - (int)distance1)*1000));
|
sprintf(gcur_distance1_str, "%02.02f", distance1);
|
||||||
|
}
|
||||||
|
else if (distance1<100) {
|
||||||
|
// sprintf(gcur_distance1_str, "%02d.%03d", (int)distance1, (int)((distance1 - (int)distance1)*1000));
|
||||||
|
sprintf(gcur_distance1_str, "%02.03f", distance1);
|
||||||
}
|
}
|
||||||
else if (distance1<1000) {
|
else if (distance1<1000) {
|
||||||
sprintf(gcur_distance1_str, "%02d.%02d", (int)distance1, (int)((distance1 - (int)distance1)*100));
|
// sprintf(gcur_distance1_str, "%02d.%02d", (int)distance1, (int)((distance1 - (int)distance1)*100));
|
||||||
|
sprintf(gcur_distance1_str, "%03.02f", distance1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sprintf(gcur_distance1_str, "%03d.%01d", (int)distance1, (int)((distance1 - (int)distance1)*10));
|
// sprintf(gcur_distance1_str, "%03d.%01d", (int)distance1, (int)((distance1 - (int)distance1)*10));
|
||||||
|
sprintf(gcur_distance1_str, "%04.01f", distance1);
|
||||||
}
|
}
|
||||||
|
// Serial.print(distance2);Serial.print(";");Serial.println(count2);
|
||||||
|
|
||||||
if (distance2<100) {
|
if (distance2<0) {
|
||||||
sprintf(gcur_distance2_str, "%02d.%03d", (int)distance2, (int)((distance2 - (int)distance2)*1000));
|
sprintf(gcur_distance2_str, "%02.02f", distance2);
|
||||||
|
// Serial.println(gcur_distance2_str);
|
||||||
|
}
|
||||||
|
else if (distance2<100) {
|
||||||
|
// sprintf(gcur_distance2_str, "%02d.%03d", (int)distance2, (int)((distance2 - (int)distance2)*1000));
|
||||||
|
sprintf(gcur_distance2_str, "%02.03f", distance2);
|
||||||
}
|
}
|
||||||
else if (distance2<1000) {
|
else if (distance2<1000) {
|
||||||
sprintf(gcur_distance2_str, "%02d.%02d", (int)distance2, (int)((distance2 - (int)distance2)*100));
|
// sprintf(gcur_distance2_str, "%02d.%02d", (int)distance2, (int)((distance2 - (int)distance2)*100));
|
||||||
|
sprintf(gcur_distance2_str, "%03.02f", distance2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sprintf(gcur_distance2_str, "%03d.%01d", (int)distance2, (int)((distance2 - (int)distance2)*10));
|
// sprintf(gcur_distance2_str, "%03d.%01d", (int)distance2, (int)((distance2 - (int)distance2)*10));
|
||||||
|
sprintf(gcur_distance2_str, "%04.01f", distance2);
|
||||||
}
|
}
|
||||||
delay(1);
|
|
||||||
|
// delay(1);
|
||||||
float distancetime1 = distance1 * 60 / constanta;
|
float distancetime1 = distance1 * 60 / constanta;
|
||||||
float distancetime2 = distance2 * 60 / constanta;
|
float distancetime2 = distance2 * 60 / constanta;
|
||||||
|
|
||||||
@ -2247,7 +2285,7 @@ void fillRallyJsonWithData() {
|
|||||||
getRally["TDist"]=String(Trip[curTrip].distance);
|
getRally["TDist"]=String(Trip[curTrip].distance);
|
||||||
getRally["Time"]=gcurTime;
|
getRally["Time"]=gcurTime;
|
||||||
getRally["curSpeed"]=gcur_speed_str;
|
getRally["curSpeed"]=gcur_speed_str;
|
||||||
getRally["curDist1"]=String(gcur_distance1_str);
|
getRally["curDist1"]=gcur_distance1_str;
|
||||||
getRally["curDist2"]=gcur_distance2_str;
|
getRally["curDist2"]=gcur_distance2_str;
|
||||||
getRally["time1"]=gcur_time1_str;
|
getRally["time1"]=gcur_time1_str;
|
||||||
getRally["dir1"]=dircount[dircount1];
|
getRally["dir1"]=dircount[dircount1];
|
||||||
@ -2796,7 +2834,7 @@ Trip[9].startSec = 58;
|
|||||||
|
|
||||||
// Switch on the backlight
|
// Switch on the backlight
|
||||||
/// lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
|
/// lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
|
||||||
// lcd.backlight();
|
// lcd.noBacklight();
|
||||||
// lcd2.backlight();
|
// lcd2.backlight();
|
||||||
/// lcd.setBacklight(LED_ON);
|
/// lcd.setBacklight(LED_ON);
|
||||||
|
|
||||||
@ -4325,6 +4363,7 @@ void loop() //loop from VSS RALLY V2
|
|||||||
ws.textAll(strRallyJson);
|
ws.textAll(strRallyJson);
|
||||||
} else {
|
} else {
|
||||||
Serial.print("strRallyJson error:");Serial.println(strRallyJson);
|
Serial.print("strRallyJson error:");Serial.println(strRallyJson);
|
||||||
|
|
||||||
}
|
}
|
||||||
// Serial.print("calculationRallyToTTime=");Serial.println(micros()-broadcastwebsocket);
|
// Serial.print("calculationRallyToTTime=");Serial.println(micros()-broadcastwebsocket);
|
||||||
broadcastwebsocket = millis();
|
broadcastwebsocket = millis();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user