mirror of
https://github.com/bcomsugi/VSS_Rally_V3.git
synced 2026-01-10 02:12:39 +07:00
bug fix
This commit is contained in:
parent
bda7666301
commit
8bc6fed494
@ -22,7 +22,8 @@
|
||||
}
|
||||
};
|
||||
ws.onmessage = function(event) {
|
||||
console.log(event.data);
|
||||
// console.log(event.data);
|
||||
if (IsJsonString(event.data)){
|
||||
var data = JSON.parse(event.data);
|
||||
if (data.NTPTime=="N/A") document.getElementById("btnNTP").disabled = true;
|
||||
else document.getElementById("btnNTP").disabled = false;
|
||||
@ -35,7 +36,17 @@
|
||||
// document.getElementById("calkm").innerHTML = data.calkm;
|
||||
// document.getElementById("calmeter").innerHTML = data.calmeter;
|
||||
// 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>
|
||||
</head><body>
|
||||
<!--
|
||||
|
||||
@ -64,6 +64,7 @@
|
||||
};
|
||||
ws.onmessage = function(event) {
|
||||
// console.log(event.data);
|
||||
if(event.data && IsJsonString(event.data)){
|
||||
let data = JSON.parse(event.data);
|
||||
// if (data.hasOwnProperty("ping")) {
|
||||
// console.log("with ping key");
|
||||
@ -98,8 +99,19 @@
|
||||
document.getElementById("tdiff1").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
|
||||
|
||||
function checkPing(){
|
||||
@ -175,7 +187,7 @@
|
||||
</div>
|
||||
<!--//ODO1-->
|
||||
<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-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>
|
||||
@ -202,7 +214,7 @@
|
||||
-->
|
||||
<!--//ODO2-->
|
||||
<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-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>
|
||||
|
||||
@ -64,7 +64,7 @@ const char HTML_startrally[] PROGMEM = R"rawliteral(
|
||||
ws.close();
|
||||
};
|
||||
ws.onmessage = function(event) {
|
||||
// console.log(event.data);
|
||||
console.log(event.data);
|
||||
if(event.data && IsJsonString(event.data)){
|
||||
let data = JSON.parse(event.data);
|
||||
// if (data.hasOwnProperty("ping")) {
|
||||
|
||||
21
src/main.cpp
21
src/main.cpp
@ -1597,9 +1597,9 @@ void redrawcalibrationMenu()
|
||||
// }
|
||||
}
|
||||
// Declaration for calculationRally Variable
|
||||
char gcur_speed_str[7];
|
||||
char gcur_distance1_str[7];
|
||||
char gcur_distance2_str[7];
|
||||
char gcur_speed_str[8];
|
||||
char gcur_distance1_str[8];
|
||||
char gcur_distance2_str[8];
|
||||
char gcur_time1_str[12];
|
||||
char gcur_time2_str[12];
|
||||
String gcurTime;
|
||||
@ -1621,7 +1621,8 @@ void redrawcalibrationMenuForESP32()
|
||||
getCalib["counter2"]=VSSCount; /////
|
||||
getCalib["counter"]=String(gVSSCountDiff);
|
||||
getCalib["curTrip"]=String(Trip[curTrip].sub); /////
|
||||
getCalib["curTripSpeed"]=String(Trip[curTrip].speed); /////
|
||||
// getCalib["curTripSpeed"]=String(Trip[curTrip].speed); /////
|
||||
getCalib["curTripSpeed"]=gcur_speed_str; /////gcur_speed_str
|
||||
// String curTime = runningtimeforESP32(6,0);
|
||||
gcurTime = runningtimeforESP32(6,0);
|
||||
getCalib["curTime"]=gcurTime;
|
||||
@ -1651,7 +1652,9 @@ void fillSetTimeJsonForESP32()
|
||||
docSetTime["counter2"]=VSSCount; /////
|
||||
docSetTime["counter"]=String(gVSSCountDiff);
|
||||
docSetTime["curTrip"]=String(Trip[curTrip].sub); /////
|
||||
docSetTime["curTripSpeed"]=String(Trip[curTrip].speed); /////
|
||||
// docSetTime["curTripSpeed"]=String(Trip[curTrip].speed); /////
|
||||
docSetTime["curTripSpeed"]=gcur_speed_str; /////
|
||||
|
||||
// DS3231_get(&t);
|
||||
struct tm NTPTimeInfo;
|
||||
String NTPTime;
|
||||
@ -2155,7 +2158,7 @@ void calculationRally() //calculation only ESP32
|
||||
startsavemillis=millis()+2500;
|
||||
}
|
||||
// Serial.print(Trip[curTrip].sub);Serial.print(Trip[curTrip].speed);Serial.print(";");Serial.println(Trip[curTrip].startHour);
|
||||
delay(1);
|
||||
// delay(1);
|
||||
gcurTime = runningtimeforESP32(6,0);
|
||||
|
||||
sprintf(gcur_speed_str, "%3.01f", speed1);
|
||||
@ -2176,6 +2179,7 @@ void calculationRally() //calculation only ESP32
|
||||
sprintf(gcur_distance1_str, "%04.01f", distance1);
|
||||
}
|
||||
// Serial.print(distance2);Serial.print(";");Serial.println(count2);
|
||||
Serial.print(gcurTime);Serial.print(";");Serial.println(t.hour);
|
||||
|
||||
if (distance2<0) {
|
||||
sprintf(gcur_distance2_str, "%02.02f", distance2);
|
||||
@ -2238,7 +2242,7 @@ void calculationRally() //calculation only ESP32
|
||||
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);
|
||||
}
|
||||
delay(1);
|
||||
// delay(1);
|
||||
// Print Second TIME
|
||||
int secs2, mins2, hours2;
|
||||
|
||||
@ -2259,7 +2263,7 @@ delay(1);
|
||||
tottime2 = totcurrentsecs - tottime2 ;
|
||||
}
|
||||
}
|
||||
delay(1);
|
||||
// delay(1);
|
||||
hours2 = ((int)(tottime2 / 3600))%24;
|
||||
mins2 = (int)((tottime2 % 3600)/60);
|
||||
secs2 = (tottime2 % 60);
|
||||
@ -2271,6 +2275,7 @@ delay(1);
|
||||
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);
|
||||
}
|
||||
Serial.print(gcurTime);Serial.print(t.min);Serial.println(t.sec);
|
||||
// Serial.println("ENDCRal");
|
||||
} ///// calculation only for esp32
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user