mirror of
https://github.com/bcomsugi/VSS_Rally_V3.git
synced 2026-01-08 17:32:38 +07:00
Speed1 always pos, trip has default value
This commit is contained in:
parent
51a6c30794
commit
d335f37563
109
data/calibration.html
Normal file
109
data/calibration.html
Normal file
@ -0,0 +1,109 @@
|
||||
<!DOCTYPE HTML><html><head>
|
||||
<title>Rally TerraTrip v1 Calibration</title>
|
||||
<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%/wscal");
|
||||
ws.onopen = function() {
|
||||
console.log("WebSocket Connected");
|
||||
if(document.getElementById("mainTime").classList.contains("bg-danger")){
|
||||
document.getElementById("mainTime").classList.remove("bg-danger")
|
||||
}
|
||||
};
|
||||
ws.onclose = function() {
|
||||
// alert("WS Connection Closed");
|
||||
if(!document.getElementById("mainTime").classList.contains("bg-danger")){
|
||||
document.getElementById("mainTime").classList.add("bg-danger")
|
||||
}
|
||||
};
|
||||
ws.onmessage = function(event) {
|
||||
console.log(event.data);
|
||||
var data = JSON.parse(event.data);
|
||||
document.getElementById("currenttime").innerHTML = data.curTime;
|
||||
document.getElementById("currenttrack").innerHTML = data.curTrip;
|
||||
document.getElementById("counter").innerHTML = data.counter+";"+data.counter2;
|
||||
document.getElementById("speed").innerHTML = data.curTripSpeed;
|
||||
document.getElementById("caldist").innerHTML = data.caldist;
|
||||
document.getElementById("calman").innerHTML = data.calman;
|
||||
document.getElementById("calkm").innerHTML = data.calkm;
|
||||
document.getElementById("calmeter").innerHTML = data.calmeter;
|
||||
document.getElementById("calval").innerHTML = data.calval;
|
||||
};
|
||||
</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"><h5><span id="counter">12345</span></h5></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 Distance (<span id="caldist">9</span> Km)-></h3></div>
|
||||
<div class="col text-start"><h3>
|
||||
|
||||
<input type="number" step="any" maxlength="2" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
||||
id="setdistance" name="setdistance" size="4">
|
||||
<button class="btn btn-primary mb-2 fw-bold" onclick="setDistance()">SET</button>
|
||||
</h3></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col text-end"><h3>Set Calibration Manually (<span id="calman">110000</span>)-></h3></div>
|
||||
<div class="col text-start"><h3>
|
||||
|
||||
<input type="number" step="any" maxlength="6" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
||||
size="3" id="setcalibration" name="setcalibration">
|
||||
<button class="btn btn-primary mb-2 fw-bold" onclick="setCalibration()">SET</button>
|
||||
</h3></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col text-end"><h4>
|
||||
<button ondblclick="startCalibration()" type="button" class="btn btn-primary mb-2 me-md-4">Start Calibration</button>
|
||||
<button ondblclick="stopCalibration()" type="button" class="btn btn-primary mb-2 me-md-4">Stop Calibration</button></h4>
|
||||
</div>
|
||||
<div class="col"><h3>
|
||||
<span id="calkm">00.000</span>Km</h3>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col text-end me-md-4"><h3>1 meter=<span id="calmeter">123.456</span></h3></div>
|
||||
<div class="col"><h3><span id="calval">123456</span> Calibration Value</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 setDistance(e){
|
||||
const setDis = document.getElementById("setdistance").value;
|
||||
var full_data='{"setcaldis":'+setDis+'}';
|
||||
console.log(full_data);
|
||||
ws.send(full_data);
|
||||
}
|
||||
function setCalibration(e){
|
||||
const setCal = document.getElementById("setcalibration").value;
|
||||
var full_data='{"setcaldisman":'+setCal+'}';
|
||||
console.log(full_data);
|
||||
ws.send(full_data);
|
||||
}
|
||||
function startCalibration(e){
|
||||
ws.send('{"calstart":1}');
|
||||
console.log("calstart->1");
|
||||
}
|
||||
function stopCalibration(e){
|
||||
ws.send('{"calstart":0}');
|
||||
console.log("calstart->0");
|
||||
}
|
||||
</script>
|
||||
</body></html>
|
||||
@ -1,3 +1,4 @@
|
||||
const char HTML_CONSTHEADER[] PROGMEM = R"rawliteral(
|
||||
<!DOCTYPE HTML><html><head>
|
||||
<title>Rally TerraTrip v1 Constanta</title>
|
||||
<meta charset="utf-8">
|
||||
@ -224,4 +225,6 @@ const char HTML_CONSTEND[] PROGMEM = R"rawliteral(
|
||||
xhr.send(data);
|
||||
}
|
||||
</script>
|
||||
</body></html>
|
||||
</body></html>
|
||||
|
||||
)rawliteral";
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"A", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"B", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"C", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"D", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"E", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"F", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"G", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"H", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"I", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"J", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"K", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"L", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"M", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"N", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"O", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
@ -0,0 +1 @@
|
||||
{"trip":"P", "speed":"", "time":"", "dist":"", "stime":""}
|
||||
275
src/constanta special/contantasp.html
Normal file
275
src/constanta special/contantasp.html
Normal file
@ -0,0 +1,275 @@
|
||||
<!-- const char HTML_CONSTHEADER[] PROGMEM = R"rawliteral( -->
|
||||
<!DOCTYPE HTML><html><head>
|
||||
<title>Rally TerraTrip v1 Constanta</title>
|
||||
<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>
|
||||
function onlyNumberKey(evt,e) {
|
||||
// Only ASCII character in that range allowed
|
||||
var ASCIICode = (evt.which) ? evt.which : evt.keyCode
|
||||
if (ASCIICode > 31 && (ASCIICode < 48 || ASCIICode > 57) && ASCIICode !=46)
|
||||
return false;
|
||||
}
|
||||
function chback(e){ //change background to yellow
|
||||
var val = e.value;
|
||||
var okColor = "yellow"
|
||||
var Warning = "red"
|
||||
console.log(val);
|
||||
console.log(e);
|
||||
console.log(e.classList);
|
||||
if(e.classList.contains("speed")) {
|
||||
if(val<100) e.style.backgroundColor = okColor;
|
||||
else e.style.backgroundColor = Warning;
|
||||
} else if(e.classList.contains("time")) {
|
||||
if(val<1000) e.style.backgroundColor = okColor;
|
||||
else e.style.backgroundColor = Warning;
|
||||
} else if(e.classList.contains("dist")) {
|
||||
if(val<1000) e.style.backgroundColor = okColor;
|
||||
else e.style.backgroundColor = Warning;
|
||||
} else e.style.backgroundColor = okColor;
|
||||
// if(val<100) e.style.backgroundColor = "yellow";
|
||||
// console.log(e);
|
||||
// if(e.classList.contains("speed")) e.style.backgroundColor = "red";
|
||||
// e.style.backgroundColor = "yellow";
|
||||
}
|
||||
</script>
|
||||
</head><body onload="loaded();">
|
||||
<!--
|
||||
<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-info text-white">
|
||||
<!-- <div class="row">
|
||||
<div class="col-2 mt-1"><h2><span id="counter">12345</span></h2></div>
|
||||
<div class="col-3 mt-1"><h2>TRACK <span id="currenttrack">A</span></h2></div>
|
||||
<div class="col mt-1"><h2 class="text-center">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>
|
||||
-->
|
||||
<!--//Constanta Menu-->
|
||||
<div class="row g-2 align-items-center">
|
||||
<div class="col-1"></div>
|
||||
<div class="col-1 text-center "><label class="col-form-label fs-6 fw-bold">Dist(Km)</label></div>
|
||||
<div class="col-1 text-end">= </div>
|
||||
<div class="col-1 text-center "><label class="col-form-label fs-6 fw-bold">Speed</label></div>
|
||||
<div class="col-1 text-center">X</div>
|
||||
<div class="col-1 text-center "><label class="col-form-label fs-6 fw-bold">Time(min)</label></div>
|
||||
<div class="col-1"></div>
|
||||
<div class="col-2 text-center "><label class="col-form-label fs-6 fw-bold">Start Time</label></div>
|
||||
</div>
|
||||
<!-- )rawliteral"; -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- const char HTML_CONSTROW[] PROGMEM = R"rawliteral( -->
|
||||
<div class="row g-2 align-items-center" id="trip%A%">
|
||||
<div class="col-1 "><label for="%dist%" class="col-form-label fs-4 ms-1 trip">%A%></label></div>
|
||||
<div class="col-2">
|
||||
<input type="number" step="any" maxlength="6" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
||||
id="%dist%" name="%dist%" class="form-control dist" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)" value="%distval%"></div>
|
||||
<div class="col-2 ">
|
||||
<input type="number" step="any" maxlength="6" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
||||
id="%speed%" name="%speed%" class="form-control speed" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)" value="%speedval%"></div>
|
||||
<div class="col-2">
|
||||
<input type="number" maxlength="5" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
||||
id="%time%" name="%time%" class="form-control time" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)" value="%timeval%"></div>
|
||||
<div class="col-2">
|
||||
<input type="time" id="%stime%" name="%stime%" class="form-control stime" onchange="chback(this)" value="%stimeval%"></div>
|
||||
<div class="col-2">
|
||||
<button class="btn btn-primary fw-bold" id="myBtn" onclick="setConstanta(this)">SET %A%</button></div>
|
||||
</div>
|
||||
<!-- )rawliteral"; -->
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- const char HTML_CONSTEND[] PROGMEM = R"rawliteral( -->
|
||||
<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>
|
||||
// document.addEventListener("DOMContentLoaded", function() {
|
||||
function loaded(){
|
||||
var xhr = new XMLHttpRequest();
|
||||
var url = "/rest/loadconst";
|
||||
console.log("before open");
|
||||
// for (var i=65; i<81; i++){
|
||||
xhr.open("POST", url, true);
|
||||
console.log("before setrequest");
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.onreadystatechange = function () {
|
||||
console.log(xhr.responseText);
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
var jsonAllTrip = JSON.parse(xhr.responseText);
|
||||
const jsonlen = Object.keys(jsonAllTrip.alltrip).length;
|
||||
console.log(jsonAllTrip.alltrip[0]);
|
||||
console.log("jsondlen="+jsonlen);
|
||||
var jsontemp;
|
||||
for (var i=0; i<jsonlen; i++){
|
||||
jsontemp = jsonAllTrip.alltrip[i];
|
||||
console.log(jsontemp);
|
||||
var json = JSON.parse(JSON.stringify(jsontemp));
|
||||
console.log(json);
|
||||
|
||||
// if (json.ok) {
|
||||
parsingjson(json);
|
||||
}
|
||||
//console.log(json.trip + ", " + json.speed + ", " + json.dist + ", " + json.time + ", " + json.stime);
|
||||
console.log(json);
|
||||
}
|
||||
};
|
||||
let data = '{"req":"B"}'
|
||||
console.log(data);
|
||||
var datajson = JSON.stringify(data);
|
||||
console.log(datajson);
|
||||
|
||||
// console.log(String.fromCharCode(i));
|
||||
// data = '{"req":"'+String.fromCharCode(i)+'"}'
|
||||
// xhr.send(data);
|
||||
// }
|
||||
|
||||
};
|
||||
|
||||
|
||||
function setConstanta(e){
|
||||
e = e || window.event;
|
||||
var targ1 = e.target || e.srcElement || e;
|
||||
if (targ1.nodeType == 3) targ1 = targ1.parentNode; // defeat Safari bug
|
||||
const targ = targ1.closest(".row");
|
||||
const trip = targ.getElementsByClassName("trip")[0].textContent[0];
|
||||
const speed = targ.getElementsByClassName("speed")[0].value;
|
||||
const dist = targ.getElementsByClassName("dist")[0].value;
|
||||
const time = targ.getElementsByClassName("time")[0].value;
|
||||
if (!(dist<1000)){
|
||||
alert ("Trip "+trip+"-> [Dist] cannot exceed 1000 Km");
|
||||
return;
|
||||
}
|
||||
if (speed===""){
|
||||
alert ("Trip "+trip+"-> [Speed] is required");
|
||||
return;
|
||||
}
|
||||
if (!(speed<100)){
|
||||
alert ("Trip "+trip+"-> [Speed] cannot exceed 100 Km/h");
|
||||
return;
|
||||
}
|
||||
if (!(time<1000)){
|
||||
alert ("Trip "+trip+"-> [Time] cannot exceed 1000 minutes");
|
||||
return;
|
||||
}
|
||||
const stime = targ.getElementsByClassName("stime")[0].value;
|
||||
if (stime===""){
|
||||
alert ("Trip "+trip+"-> [Start Time] is required");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// var full_data='{"trip":"'+trip+'", "speed":"'+speed+'", "dist":"'+dist+'", "time":"'+time+'", "stime":"'+stime+'"}';
|
||||
console.log(full_data);
|
||||
// sendjson(full_data);
|
||||
};
|
||||
|
||||
|
||||
function setConstanta(e){
|
||||
e = e || window.event;
|
||||
var targ1 = e.target || e.srcElement || e;
|
||||
if (targ1.nodeType == 3) targ1 = targ1.parentNode; // defeat Safari bug
|
||||
const targ = targ1.closest(".row");
|
||||
const trip = targ.getElementsByClassName("trip")[0].textContent[0];
|
||||
const speed = targ.getElementsByClassName("speed")[0].value;
|
||||
const dist = targ.getElementsByClassName("dist")[0].value;
|
||||
const time = targ.getElementsByClassName("time")[0].value;
|
||||
if (!(dist<1000)){
|
||||
alert ("Trip "+trip+"-> [Dist] cannot exceed 1000 Km");
|
||||
return;
|
||||
}
|
||||
if (speed===""){
|
||||
alert ("Trip "+trip+"-> [Speed] is required");
|
||||
return;
|
||||
}
|
||||
if (!(speed<100)){
|
||||
alert ("Trip "+trip+"-> [Speed] cannot exceed 100 Km/h");
|
||||
return;
|
||||
}
|
||||
if (!(time<1000)){
|
||||
alert ("Trip "+trip+"-> [Time] cannot exceed 1000 minutes");
|
||||
return;
|
||||
}
|
||||
const stime = targ.getElementsByClassName("stime")[0].value;
|
||||
if (stime===""){
|
||||
alert ("Trip "+trip+"-> [Start Time] is required");
|
||||
return;
|
||||
}
|
||||
// targ.getElementsByClassName("speed")[0].value = "345" //trial change backColor
|
||||
// targ.getElementsByClassName("speed")[0].style.backgroundColor = "white"
|
||||
|
||||
|
||||
var full_data='{"trip":"'+trip+'", "speed":"'+speed+'", "dist":"'+dist+'", "time":"'+time+'", "stime":"'+stime+'"}';
|
||||
console.log(full_data);
|
||||
sendjson(full_data);
|
||||
};
|
||||
|
||||
function parsingjson(json){
|
||||
console.log(json);
|
||||
var tripID = document.getElementById("trip"+json.trip);
|
||||
console.log(tripID);
|
||||
const speed = tripID.getElementsByClassName("speed")[0];
|
||||
const dist = tripID.getElementsByClassName("dist")[0];
|
||||
const time = tripID.getElementsByClassName("time")[0];
|
||||
const stime = tripID.getElementsByClassName("stime")[0];
|
||||
setValBackColor(speed, json.speed);
|
||||
setValBackColor(dist, json.dist);
|
||||
setValBackColor(time, json.time);
|
||||
setValBackColor(stime, json.stime);
|
||||
// speed.value = json.speed;
|
||||
// dist.value = json.dist;
|
||||
// time.value = json.time;
|
||||
// stime.value = json.stime;
|
||||
// speed.style.backgroundColor = "#94C4E2"// #6495ED
|
||||
// dist.style.backgroundColor = "#94C4E2"
|
||||
// time.style.backgroundColor = "#94C4E2"
|
||||
// stime.style.backgroundColor = "#94C4E2"
|
||||
console.log("result ok:"+json.trip + ", " + speed.value + ", " + dist.value + ", " + time.value + ", " + stime.value);
|
||||
};
|
||||
|
||||
function setValBackColor(elem, jsonval){
|
||||
if (jsonval) {
|
||||
elem.value = jsonval;
|
||||
elem.style.backgroundColor = "#ABEBC6";//"#E5E7E9";//"#C0C0C0";//"#94C4E2";
|
||||
} else {
|
||||
elem.style.backgroundColor = "white";
|
||||
}
|
||||
};
|
||||
|
||||
function sendjson(data){
|
||||
var xhr = new XMLHttpRequest();
|
||||
var url = "/rest/endpoint";
|
||||
xhr.open("POST", url, true);
|
||||
xhr.setRequestHeader("Content-Type", "application/json");
|
||||
xhr.onreadystatechange = function () {
|
||||
console.log(xhr.responseText);
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
var json = JSON.parse(xhr.responseText);
|
||||
console.log(json.trip + ", " + json.speed + ", " + json.dist + ", " + json.time + ", " + json.stime);
|
||||
if (json.ok) {
|
||||
parsingjson(json);
|
||||
}
|
||||
//console.log(json.trip + ", " + json.speed + ", " + json.dist + ", " + json.time + ", " + json.stime);
|
||||
console.log(json);
|
||||
}
|
||||
};
|
||||
console.log(data);
|
||||
var datajson = JSON.stringify(data);
|
||||
console.log(datajson);
|
||||
xhr.send(data);
|
||||
}
|
||||
</script>
|
||||
</body></html>
|
||||
|
||||
<!-- )rawliteral"; -->
|
||||
@ -195,7 +195,7 @@ const char HTML_startrally[] PROGMEM = R"rawliteral(
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-5"><h4>
|
||||
<button ondblclick="resetOdo(1)" type="button" class="btn btn-primary btn-sm mb-2">Reset ODO1</button>
|
||||
<button ondblclick="resetOdo(1)" type="button" class="btn btn-primary btn-sm mb-2">Rst ODO1</button>
|
||||
<button ondblclick="copyToOdo(2,1)" type="button" class="btn btn-primary btn-sm mb-2">↓ to ODO2</button>
|
||||
<button ondblclick="editOdo(1)" type="button" class="btn btn-primary btn-sm mb-2">Edit</button></h4>
|
||||
</div>
|
||||
@ -222,7 +222,7 @@ const char HTML_startrally[] PROGMEM = R"rawliteral(
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-5"><h5>
|
||||
<button ondblclick="resetOdo(2)" type="button" class="btn btn-primary btn-sm mb-1">Reset ODO2</button>
|
||||
<button ondblclick="resetOdo(2)" type="button" class="btn btn-primary btn-sm mb-1">Rst ODO2</button>
|
||||
<button ondblclick="copyToOdo(1,2)" type="button" class="btn btn-primary btn-sm mb-1 arrow-up down-arrow">↑ to ODO1</button>
|
||||
<button ondblclick="editOdo(2)" type="button" class="btn btn-primary btn-sm mb-2">Edit</button></h4>
|
||||
</div>
|
||||
|
||||
64
src/main.cpp
64
src/main.cpp
@ -340,7 +340,8 @@ String readFile(fs::FS &fs, const char * path){
|
||||
if (!file.size()){
|
||||
Serial.println("File is empty");
|
||||
file.close();
|
||||
return String();
|
||||
// return String();
|
||||
return "";
|
||||
}
|
||||
Serial.print("- read from file:");
|
||||
String fileContent;
|
||||
@ -1049,6 +1050,7 @@ void memretrieveTrip(int pointer, int startaddress)
|
||||
//Serial.print (pointer); Serial.println(startaddress);
|
||||
int pointeradd;
|
||||
Trip[pointer].speed = mem.readFloat(startaddress);
|
||||
|
||||
pointeradd = (startaddress + 6);
|
||||
Trip[pointer].startHour = mem.read(pointeradd);
|
||||
pointeradd = (startaddress + 5);
|
||||
@ -1154,14 +1156,14 @@ unsigned long getMemStime(uint8_t getmemsTimecurTrip){
|
||||
return mem.readLong(pointeradd);
|
||||
}
|
||||
|
||||
void blink() {
|
||||
// #ifndef ATMEGA328
|
||||
ledstate = !ledstate;
|
||||
// #else
|
||||
// PORTB ^= B00100000;
|
||||
// #endif
|
||||
VSSCount++;
|
||||
}
|
||||
// void interruptblink() {
|
||||
// // #ifndef ATMEGA328
|
||||
// ledstate = !ledstate;
|
||||
// // #else
|
||||
// // PORTB ^= B00100000;
|
||||
// // #endif
|
||||
// VSSCount++;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ -1494,21 +1496,26 @@ void constantaMenu()
|
||||
}
|
||||
void updateCount()
|
||||
{
|
||||
unsigned long tempvsscount;
|
||||
tempvsscount = VSSCount;
|
||||
if (dircount1 == FORWARD) {
|
||||
count1 = count1 + (VSSCount-time1);
|
||||
count1 = count1 + (tempvsscount-time1);
|
||||
}
|
||||
else if (dircount1 == BACKWARD) {
|
||||
count1 = count1 - (VSSCount-time1);
|
||||
count1 = count1 - (tempvsscount-time1);
|
||||
}
|
||||
|
||||
if (dircount2 == FORWARD) {
|
||||
count2 = count2 + (VSSCount-time2);
|
||||
count2 = count2 + (tempvsscount-time2);
|
||||
}
|
||||
else if (dircount2 == BACKWARD) {
|
||||
count2 = count2 - (VSSCount-time2);
|
||||
count2 = count2 - (tempvsscount-time2);
|
||||
}
|
||||
time1 = VSSCount;
|
||||
time2 = VSSCount;
|
||||
time1 = tempvsscount;
|
||||
time2 = tempvsscount;
|
||||
// time1 = VSSCount;
|
||||
// time2 = VSSCount;
|
||||
|
||||
}
|
||||
void saveCount()
|
||||
{
|
||||
@ -2142,7 +2149,8 @@ void calculationRally() //calculation only ESP32
|
||||
}
|
||||
startspeed = millis(); //startspeed is only one no startspeed2
|
||||
// startdistance = distance1;
|
||||
if(speed1 > 200 || speed1 < -200) speed1 = 0;
|
||||
if(speed1 > 300 || speed1 < -300) speed1 = 0;
|
||||
if(speed1 < 0) speed1 = speed1*-1;
|
||||
|
||||
if ((millis()-startsavemillis)>0) {
|
||||
|
||||
@ -2457,7 +2465,7 @@ void set_cursor_pos(int new_pos)
|
||||
}
|
||||
|
||||
|
||||
void IRAM_ATTR isr() { //esp32 only
|
||||
void IRAM_ATTR interruptblink() { //esp32 only
|
||||
VSSCount++;
|
||||
ledstate=!ledstate;
|
||||
}
|
||||
@ -2471,6 +2479,8 @@ void convertJsonTripToTripStruct(uint8_t iTrip, const char* strJson){ //this als
|
||||
dtostrf(Trip[iTrip].speed, 6, 4, mspeed);
|
||||
Serial.print(String(char(iTrip)));Serial.print(mspeed);Serial.print(" VS ");Serial.println(doc["speed"].as<String>());
|
||||
// if (Trip[iTrip].speed!=doc["speed"])
|
||||
Serial.println("hohoho");
|
||||
// if (strJson=="")
|
||||
if (strcmp(mspeed, doc["speed"].as<const char*>()) != 0)
|
||||
{
|
||||
Serial.print(String(char(iTrip)));Serial.println(" speed is different");
|
||||
@ -2482,6 +2492,7 @@ void convertJsonTripToTripStruct(uint8_t iTrip, const char* strJson){ //this als
|
||||
// Serial.print(String(iTrip));Serial.print(Trip[iTrip].subTime);Serial.print(" VS ");Serial.println(doc["time"].as<String>());
|
||||
// Trip[iTrip].subTime = doc["time"];
|
||||
// }
|
||||
|
||||
Trip[iTrip].distance = doc["dist"];
|
||||
Trip[iTrip].subTime = doc["time"];
|
||||
}
|
||||
@ -2492,8 +2503,9 @@ void fillTripArray(){ //run by setup()
|
||||
tempReadFile.reserve(100);
|
||||
for (uint8_t i=0; i<TRIPSIZE; i++){
|
||||
tempTrip[5]=i+65;
|
||||
// Serial.println(tempTrip);
|
||||
tempReadFile = readFile(SPIFFS, tempTrip);
|
||||
// Serial.print(tempTrip); Serial.print(";");Serial.println(tempReadFile);
|
||||
Serial.print(tempTrip); Serial.print(";");Serial.println(tempReadFile);
|
||||
convertJsonTripToTripStruct(i, tempReadFile.c_str());
|
||||
}
|
||||
}
|
||||
@ -2630,7 +2642,7 @@ void getTripFromSPIFF(uint8_t charcurTrip, char *pDist, char *pSpeed, char *pTi
|
||||
tempsTime.reserve(10);
|
||||
|
||||
tempTrip=readFile(SPIFFS, filename);
|
||||
// Serial.print(tempTrip.length()); Serial.print(";");Serial.println(tempTrip);
|
||||
Serial.print(tempTrip.length()); Serial.print(";");Serial.println(tempTrip);
|
||||
deserializeJson(doc, tempTrip);
|
||||
|
||||
float speedinconstanta = getMemSpeedInConstanta(charcurTrip-65);
|
||||
@ -2797,7 +2809,7 @@ void setup() {
|
||||
pinMode(simulatorPWMPin,OUTPUT);
|
||||
pinMode(LED_BUILTIN, OUTPUT);
|
||||
pinMode(interruptPin, INPUT); //Pull down using resistor to ground
|
||||
attachInterrupt(digitalPinToInterrupt(interruptPin), blink, FALLING);
|
||||
attachInterrupt(digitalPinToInterrupt(interruptPin), interruptblink, FALLING);
|
||||
|
||||
|
||||
btnUP.begin(); /// using JC_BUTTON harus ada begin
|
||||
@ -2828,6 +2840,7 @@ Trip[9].startSec = 58;
|
||||
//Serial.println(Trip[0].distance);
|
||||
//Serial.println(Trip[0].subTime);
|
||||
// uint32_t freqhz=400000;
|
||||
Serial.println("begin wire");
|
||||
Wire.begin(I2C_SDA, I2C_SCL, FREQHZ); //for lolin32lite sda=15; scl=13 //Dont move up or down
|
||||
|
||||
//**************************LCD Setup********************************
|
||||
@ -2846,7 +2859,7 @@ Trip[9].startSec = 58;
|
||||
// lcd2.print("hello rally20");
|
||||
|
||||
|
||||
|
||||
Serial.println("Start calib");
|
||||
//***************************END LCD Setup********************************
|
||||
strCalibJson.reserve(512);
|
||||
strRallyJson.reserve(512);
|
||||
@ -2904,6 +2917,8 @@ Trip[9].startSec = 58;
|
||||
// for (int i = 0; i<TRIPSIZE; i++) {
|
||||
|
||||
// }
|
||||
// setMemSpeedInConstanta(12.58, 1); //1=tripB
|
||||
// setMemStime( getValueSetTime("01:02"), 1);
|
||||
for (int i = 0; i<TRIPSIZE; i++) { //reading Trip
|
||||
Trip[i].sub = char(i+65);
|
||||
memretrieveTrip(i, (TRIPADDRESS+i)*32);
|
||||
@ -2971,8 +2986,9 @@ Serial.println("calibration and constanta");
|
||||
#endif
|
||||
// wifiManager.setAPCallback(configModeCallback);
|
||||
// wifiManager.autoConnect(soft_ap_ssid);
|
||||
Serial.println("before filltriparray");
|
||||
fillTripArray();
|
||||
WiFi.onEvent(OnWiFiEvent);
|
||||
|
||||
//WiFi.mode(WIFI_STA);
|
||||
WiFi.mode(WIFI_MODE_APSTA);
|
||||
|
||||
@ -2986,7 +3002,7 @@ Serial.println("calibration and constanta");
|
||||
strncpy(ssid, yourSSIDString.c_str() , (sizeof ssid)-1);
|
||||
// strncpy(ssid, yourSSIDString.c_str() , (sizeof yourSSIDString)-1); //dont show the old password for security reason
|
||||
}
|
||||
|
||||
WiFi.onEvent(OnWiFiEvent);
|
||||
Serial.println(ssid);
|
||||
String yourInputPwd = readFile(SPIFFS, "/inputPwd.txt");
|
||||
Serial.print("*** Your inputPwd: ");
|
||||
@ -4417,7 +4433,7 @@ void loop() //loop from VSS RALLY V2
|
||||
grequestIsFull=false;
|
||||
grequestConstHTMLIsFull=false;
|
||||
}
|
||||
VSSCount=millis(); //VSSCount Simulator
|
||||
// VSSCount=millis(); //VSSCount Simulator
|
||||
#ifdef DEBUG
|
||||
Serial.print(micros()-prevtimemicros); Serial.println("**");
|
||||
#endif
|
||||
|
||||
Loading…
Reference in New Issue
Block a user