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
@ -1,28 +1,29 @@
|
|||||||
<!DOCTYPE HTML><html><head>
|
<!DOCTYPE HTML><html><head>
|
||||||
<title>Rally TerraTrip v1 Set Main Time</title>
|
<title>Rally TerraTrip v1 Set Main Time</title>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<!-- Bootstrap CSS -->
|
<!-- 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="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">
|
<link href="bootstrap.css" rel="stylesheet">
|
||||||
<script type = "text/javascript">
|
<script type = "text/javascript">
|
||||||
const ws = new WebSocket("ws://%serveripaddress%/wssettime");
|
const ws = new WebSocket("ws://%serveripaddress%/wssettime");
|
||||||
ws.onopen = function() {
|
ws.onopen = function() {
|
||||||
console.log("WebSocket Connected");
|
console.log("WebSocket Connected");
|
||||||
if(document.getElementById("mainTime").classList.contains("bg-danger")){
|
if(document.getElementById("mainTime").classList.contains("bg-danger")){
|
||||||
document.getElementById("mainTime").classList.remove("bg-danger")
|
document.getElementById("mainTime").classList.remove("bg-danger")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
ws.onclose = function() {
|
ws.onclose = function() {
|
||||||
// alert("WS Connection Closed");
|
// alert("WS Connection Closed");
|
||||||
if(!document.getElementById("mainTime").classList.contains("bg-danger")){
|
if(!document.getElementById("mainTime").classList.contains("bg-danger")){
|
||||||
document.getElementById("mainTime").classList.add("bg-danger")
|
document.getElementById("mainTime").classList.add("bg-danger")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
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;
|
||||||
@ -35,42 +36,52 @@
|
|||||||
// 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);
|
||||||
</script>
|
};
|
||||||
</head><body>
|
|
||||||
<!--
|
function IsJsonString(str) {
|
||||||
<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>
|
try {
|
||||||
-->
|
JSON.parse(str);
|
||||||
<script src="bootstrap.bundle.min.js"></script>
|
} catch (e) {
|
||||||
<div class=" bg-secondary text-white">
|
return false;
|
||||||
<div class="row">
|
}
|
||||||
<div class="col-2 mt-1"><h6><span id="counter">12345</span></h6></div>
|
return true;
|
||||||
<div class="col-3 mt-1"><h2>TRIP <span id="currenttrack">A</span></h2></div>
|
|
||||||
<div class="col mt-1 text-center" id="mainTime"><h2>Time: <span id="currenttime">00:00:00</span></h2></div>
|
|
||||||
<div class="col-3 mt-1 text-end"><h2><span id="speed">123.4</span>Km/h</h2></div>
|
|
||||||
<hr>
|
|
||||||
</div>
|
|
||||||
<!--//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>
|
|
||||||
<input type="time" step="any" maxlength="6" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
|
||||||
id="settime" name="settime" size="4">
|
|
||||||
<button class="btn btn-primary mb-2 fw-bold" onclick="setTime(0)">SET Time</button>
|
|
||||||
<button id="btnNTP" class="btn btn-primary mb-2 fw-bold" onclick="setTime(1)">Use NTP</button>
|
|
||||||
</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>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function setTime(e){
|
|
||||||
let setTime;
|
|
||||||
if (e) setTime = "NTP";
|
|
||||||
else setTime = document.getElementById("settime").value;
|
|
||||||
var full_data='{"setTime":"'+setTime+'"}';
|
|
||||||
console.log(full_data);
|
|
||||||
ws.send(full_data);
|
|
||||||
}
|
}
|
||||||
</script>
|
</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">
|
||||||
|
<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>
|
||||||
|
<div class="col mt-1 text-center" id="mainTime"><h2>Time: <span id="currenttime">00:00:00</span></h2></div>
|
||||||
|
<div class="col-3 mt-1 text-end"><h2><span id="speed">123.4</span>Km/h</h2></div>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
<!--//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>
|
||||||
|
<input type="time" step="any" maxlength="6" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
||||||
|
id="settime" name="settime" size="4">
|
||||||
|
<button class="btn btn-primary mb-2 fw-bold" onclick="setTime(0)">SET Time</button>
|
||||||
|
<button id="btnNTP" class="btn btn-primary mb-2 fw-bold" onclick="setTime(1)">Use NTP</button>
|
||||||
|
</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>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function setTime(e){
|
||||||
|
let setTime;
|
||||||
|
if (e) setTime = "NTP";
|
||||||
|
else setTime = document.getElementById("settime").value;
|
||||||
|
var full_data='{"setTime":"'+setTime+'"}';
|
||||||
|
console.log(full_data);
|
||||||
|
ws.send(full_data);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body></html>
|
</body></html>
|
||||||
@ -64,42 +64,54 @@
|
|||||||
};
|
};
|
||||||
ws.onmessage = function(event) {
|
ws.onmessage = function(event) {
|
||||||
// console.log(event.data);
|
// console.log(event.data);
|
||||||
let data = JSON.parse(event.data);
|
if(event.data && IsJsonString(event.data)){
|
||||||
// if (data.hasOwnProperty("ping")) {
|
let data = JSON.parse(event.data);
|
||||||
// console.log("with ping key");
|
// if (data.hasOwnProperty("ping")) {
|
||||||
// ping++;
|
// console.log("with ping key");
|
||||||
// } else{
|
// ping++;
|
||||||
let curTrack=document.getElementById("currenttrack").innerHTML;
|
// } else{
|
||||||
let tripSpeed=document.getElementById("tripspeed").innerHTML;
|
let curTrack=document.getElementById("currenttrack").innerHTML;
|
||||||
let tripDist=document.getElementById("tripdist").innerHTML;
|
let tripSpeed=document.getElementById("tripspeed").innerHTML;
|
||||||
let tripTime=document.getElementById("triptime").innerHTML;
|
let tripDist=document.getElementById("tripdist").innerHTML;
|
||||||
let tripsTime=document.getElementById("tripstime").innerHTML;
|
let tripTime=document.getElementById("triptime").innerHTML;
|
||||||
if(curTrack==data.Trip){
|
let tripsTime=document.getElementById("tripstime").innerHTML;
|
||||||
if(tripSpeed!=data.TSpeed || tripDist != data.TDist || tripTime!=data.TTime ||tripsTime!=data.TsTime){
|
if(curTrack==data.Trip){
|
||||||
console.log("Refresh Trip "+data.Trip);
|
if(tripSpeed!=data.TSpeed || tripDist != data.TDist || tripTime!=data.TTime ||tripsTime!=data.TsTime){
|
||||||
changeTrip(data.Trip);
|
console.log("Refresh Trip "+data.Trip);
|
||||||
}
|
changeTrip(data.Trip);
|
||||||
}
|
}
|
||||||
ping++;
|
}
|
||||||
document.getElementById("counter").innerHTML = data.counter+";"+data.counter2;
|
ping++;
|
||||||
document.getElementById("currenttime").innerHTML = data.Time;
|
document.getElementById("counter").innerHTML = data.counter+";"+data.counter2;
|
||||||
document.getElementById("currenttrack").innerHTML = data.Trip;
|
document.getElementById("currenttime").innerHTML = data.Time;
|
||||||
document.getElementById("tripspeed").innerHTML = data.TSpeed;
|
document.getElementById("currenttrack").innerHTML = data.Trip;
|
||||||
document.getElementById("tripdist").innerHTML = data.TDist;
|
document.getElementById("tripspeed").innerHTML = data.TSpeed;
|
||||||
document.getElementById("triptime").innerHTML = data.TTime;
|
document.getElementById("tripdist").innerHTML = data.TDist;
|
||||||
document.getElementById("tripstime").innerHTML = data.TsTime;
|
document.getElementById("triptime").innerHTML = data.TTime;
|
||||||
document.getElementById("currentspeed").innerHTML = data.curSpeed;
|
document.getElementById("tripstime").innerHTML = data.TsTime;
|
||||||
document.getElementById("dir1").innerHTML = data.dir1;
|
document.getElementById("currentspeed").innerHTML = data.curSpeed;
|
||||||
document.getElementById("dir2").innerHTML = data.dir2;
|
document.getElementById("dir1").innerHTML = data.dir1;
|
||||||
document.getElementById("odo1").innerHTML = data.curDist1;
|
document.getElementById("dir2").innerHTML = data.dir2;
|
||||||
document.getElementById("odo2").innerHTML = data.curDist2;
|
document.getElementById("odo1").innerHTML = data.curDist1;
|
||||||
document.getElementById("time1").innerHTML = data.time1;
|
document.getElementById("odo2").innerHTML = data.curDist2;
|
||||||
document.getElementById("time2").innerHTML = data.time2;
|
document.getElementById("time1").innerHTML = data.time1;
|
||||||
document.getElementById("tdiff1").innerHTML = data.TDiff;
|
document.getElementById("time2").innerHTML = data.time2;
|
||||||
document.getElementById("tdiff2").innerHTML = data.TDiff;
|
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
|
const checkhealt = setInterval(checkPing, 1000); //heartbeat
|
||||||
|
|
||||||
function checkPing(){
|
function checkPing(){
|
||||||
@ -175,7 +187,7 @@
|
|||||||
</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>
|
||||||
@ -202,7 +214,7 @@
|
|||||||
-->
|
-->
|
||||||
<!--//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>
|
||||||
|
|||||||
@ -64,7 +64,7 @@ const char HTML_startrally[] PROGMEM = R"rawliteral(
|
|||||||
ws.close();
|
ws.close();
|
||||||
};
|
};
|
||||||
ws.onmessage = function(event) {
|
ws.onmessage = function(event) {
|
||||||
// console.log(event.data);
|
console.log(event.data);
|
||||||
if(event.data && IsJsonString(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")) {
|
||||||
|
|||||||
21
src/main.cpp
21
src/main.cpp
@ -1597,9 +1597,9 @@ void redrawcalibrationMenu()
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
// Declaration for calculationRally Variable
|
// Declaration for calculationRally Variable
|
||||||
char gcur_speed_str[7];
|
char gcur_speed_str[8];
|
||||||
char gcur_distance1_str[7];
|
char gcur_distance1_str[8];
|
||||||
char gcur_distance2_str[7];
|
char gcur_distance2_str[8];
|
||||||
char gcur_time1_str[12];
|
char gcur_time1_str[12];
|
||||||
char gcur_time2_str[12];
|
char gcur_time2_str[12];
|
||||||
String gcurTime;
|
String gcurTime;
|
||||||
@ -1621,7 +1621,8 @@ void redrawcalibrationMenuForESP32()
|
|||||||
getCalib["counter2"]=VSSCount; /////
|
getCalib["counter2"]=VSSCount; /////
|
||||||
getCalib["counter"]=String(gVSSCountDiff);
|
getCalib["counter"]=String(gVSSCountDiff);
|
||||||
getCalib["curTrip"]=String(Trip[curTrip].sub); /////
|
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);
|
// String curTime = runningtimeforESP32(6,0);
|
||||||
gcurTime = runningtimeforESP32(6,0);
|
gcurTime = runningtimeforESP32(6,0);
|
||||||
getCalib["curTime"]=gcurTime;
|
getCalib["curTime"]=gcurTime;
|
||||||
@ -1651,7 +1652,9 @@ void fillSetTimeJsonForESP32()
|
|||||||
docSetTime["counter2"]=VSSCount; /////
|
docSetTime["counter2"]=VSSCount; /////
|
||||||
docSetTime["counter"]=String(gVSSCountDiff);
|
docSetTime["counter"]=String(gVSSCountDiff);
|
||||||
docSetTime["curTrip"]=String(Trip[curTrip].sub); /////
|
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);
|
// DS3231_get(&t);
|
||||||
struct tm NTPTimeInfo;
|
struct tm NTPTimeInfo;
|
||||||
String NTPTime;
|
String NTPTime;
|
||||||
@ -2155,7 +2158,7 @@ void calculationRally() //calculation only ESP32
|
|||||||
startsavemillis=millis()+2500;
|
startsavemillis=millis()+2500;
|
||||||
}
|
}
|
||||||
// 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);
|
||||||
delay(1);
|
// delay(1);
|
||||||
gcurTime = runningtimeforESP32(6,0);
|
gcurTime = runningtimeforESP32(6,0);
|
||||||
|
|
||||||
sprintf(gcur_speed_str, "%3.01f", speed1);
|
sprintf(gcur_speed_str, "%3.01f", speed1);
|
||||||
@ -2176,6 +2179,7 @@ void calculationRally() //calculation only ESP32
|
|||||||
sprintf(gcur_distance1_str, "%04.01f", distance1);
|
sprintf(gcur_distance1_str, "%04.01f", distance1);
|
||||||
}
|
}
|
||||||
// Serial.print(distance2);Serial.print(";");Serial.println(count2);
|
// Serial.print(distance2);Serial.print(";");Serial.println(count2);
|
||||||
|
Serial.print(gcurTime);Serial.print(";");Serial.println(t.hour);
|
||||||
|
|
||||||
if (distance2<0) {
|
if (distance2<0) {
|
||||||
sprintf(gcur_distance2_str, "%02.02f", distance2);
|
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);
|
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);
|
||||||
}
|
}
|
||||||
delay(1);
|
// delay(1);
|
||||||
// Print Second TIME
|
// Print Second TIME
|
||||||
int secs2, mins2, hours2;
|
int secs2, mins2, hours2;
|
||||||
|
|
||||||
@ -2259,7 +2263,7 @@ delay(1);
|
|||||||
tottime2 = totcurrentsecs - tottime2 ;
|
tottime2 = totcurrentsecs - tottime2 ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delay(1);
|
// delay(1);
|
||||||
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);
|
||||||
@ -2271,6 +2275,7 @@ delay(1);
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
Serial.print(gcurTime);Serial.print(t.min);Serial.println(t.sec);
|
||||||
// Serial.println("ENDCRal");
|
// Serial.println("ENDCRal");
|
||||||
} ///// calculation only for esp32
|
} ///// calculation only for esp32
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user