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
@ -3,9 +3,9 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- Bootstrap CSS -->
|
||||
<!--
|
||||
<!--
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
||||
-->
|
||||
-->
|
||||
<link href="bootstrap.css" rel="stylesheet">
|
||||
<script type = "text/javascript">
|
||||
const ws = new WebSocket("ws://%serveripaddress%/wssettime");
|
||||
@ -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,14 +36,24 @@
|
||||
// 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>
|
||||
<!--
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
||||
-->
|
||||
<script src="bootstrap.bundle.min.js"></script>
|
||||
<div class=" bg-secondary text-white">
|
||||
</head><body>
|
||||
<!--
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
|
||||
-->
|
||||
<script src="bootstrap.bundle.min.js"></script>
|
||||
<div class=" bg-secondary text-white">
|
||||
<div class="row">
|
||||
<div class="col-2 mt-1"><h6><span id="counter">12345</span></h6></div>
|
||||
<div class="col-3 mt-1"><h2>TRIP <span id="currenttrack">A</span></h2></div>
|
||||
@ -50,7 +61,7 @@
|
||||
<div class="col-3 mt-1 text-end"><h2><span id="speed">123.4</span>Km/h</h2></div>
|
||||
<hr>
|
||||
</div>
|
||||
<!--//Calibration Menu-->
|
||||
<!--//Calibration Menu-->
|
||||
<div class="row">
|
||||
<div class="col text-end"><h3>Set Time (NTP Time:<span id="ntptime">9</span>)-></h3></div>
|
||||
<div class="col text-start"><h3>
|
||||
@ -61,9 +72,9 @@
|
||||
</h3></div>
|
||||
</div>
|
||||
<button ondblclick="location.href='/menu';" class="btn btn-primary fw-bold btn-sm mt-2 mb-2 ms-3">Back to Menu</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<script>
|
||||
function setTime(e){
|
||||
let setTime;
|
||||
if (e) setTime = "NTP";
|
||||
@ -72,5 +83,5 @@
|
||||
console.log(full_data);
|
||||
ws.send(full_data);
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
</body></html>
|
||||
@ -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