mirror of
https://github.com/bcomsugi/VSS_Rally_V3.git
synced 2026-01-09 09:52:38 +07:00
add set spiff when edit using lcd
This commit is contained in:
parent
cc2cdedf7b
commit
05c8b38e21
7
backup/bootstrap.min.js
vendored
Normal file
7
backup/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,196 +0,0 @@
|
|||||||
<!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;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
function chback(e){ //change background to yellow
|
|
||||||
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)"></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)"></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)"></div>
|
|
||||||
<div class="col-2">
|
|
||||||
<input type="time" id="%stime%" name="%stime%" class="form-control stime" onchange="chback(this)"></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;
|
|
||||||
if (speed===""){
|
|
||||||
alert ("Trip "+trip+"-> [Speed] is required");
|
|
||||||
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"
|
|
||||||
const dist = targ.getElementsByClassName("dist")[0].value;
|
|
||||||
const time = targ.getElementsByClassName("time")[0].value;
|
|
||||||
|
|
||||||
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>
|
|
||||||
@ -1,177 +1,227 @@
|
|||||||
|
|
||||||
<!DOCTYPE HTML><html><head>
|
<!DOCTYPE HTML><html><head>
|
||||||
<title>Rally TerraTrip v1 Constanta</title>
|
<title>Rally TerraTrip v1 Constanta</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">
|
<!--
|
||||||
<script type = "text/javascript">
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
|
||||||
const ws = new WebSocket("ws://%serveripaddress%/wscal");
|
-->
|
||||||
ws.onopen = function() {console.log("WebSocket Connected");};
|
<link href="bootstrap.css" rel="stylesheet">
|
||||||
ws.onclose = function() {alert("WS Connection Closed");};
|
<script>
|
||||||
ws.onmessage = function(event) {
|
function onlyNumberKey(evt,e) {
|
||||||
console.log(event.data);
|
// Only ASCII character in that range allowed
|
||||||
var data = JSON.parse(event.data);
|
var ASCIICode = (evt.which) ? evt.which : evt.keyCode
|
||||||
const elemen = document.getElementsByClassName(data.trip)[0];
|
if (ASCIICode > 31 && (ASCIICode < 48 || ASCIICode > 57) && ASCIICode !=46)
|
||||||
console.log(elemen);
|
return false;
|
||||||
element.getElementsByClassName("speed")[0].value = data.speed;
|
}
|
||||||
element.getElementsByClassName("dist")[0].value = data.dist;
|
function chback(e){ //change background to yellow
|
||||||
element.getElementsByClassName("time")[0].value = data.time;
|
var val = e.value;
|
||||||
element.getElementsByClassName("stime")[0].value = data.stime;
|
var okColor = "yellow"
|
||||||
document.getElementById("currenttime").innerHTML = data.curTime;
|
var Warning = "red"
|
||||||
document.getElementById("currenttrack").innerHTML = data.curTrip;
|
console.log(val);
|
||||||
document.getElementById("counter").innerHTML = data.counter;
|
console.log(e);
|
||||||
document.getElementById("speed").innerHTML = data.curTripSpeed;
|
console.log(e.classList);
|
||||||
};
|
if(e.classList.contains("speed")) {
|
||||||
</script>
|
if(val<100) e.style.backgroundColor = okColor;
|
||||||
<script>
|
else e.style.backgroundColor = Warning;
|
||||||
function onlyNumberKey(evt,e) {
|
} else if(e.classList.contains("time")) {
|
||||||
// Only ASCII character in that range allowed
|
if(val<1000) e.style.backgroundColor = okColor;
|
||||||
var ASCIICode = (evt.which) ? evt.which : evt.keyCode
|
else e.style.backgroundColor = Warning;
|
||||||
if (ASCIICode > 31 && (ASCIICode < 48 || ASCIICode > 57) && ASCIICode !=46)
|
} else if(e.classList.contains("dist")) {
|
||||||
return false;
|
if(val<1000) e.style.backgroundColor = okColor;
|
||||||
return true;
|
else e.style.backgroundColor = Warning;
|
||||||
}
|
} else e.style.backgroundColor = okColor;
|
||||||
function chback(e){ //change background to yellow
|
// if(val<100) e.style.backgroundColor = "yellow";
|
||||||
e.style.backgroundColor = "yellow";
|
// console.log(e);
|
||||||
}
|
// if(e.classList.contains("speed")) e.style.backgroundColor = "red";
|
||||||
</script>
|
// e.style.backgroundColor = "yellow";
|
||||||
</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>
|
||||||
<div class=" bg-success text-white">
|
</head><body onload="loaded();">
|
||||||
<div class="row">
|
<!--
|
||||||
<div class="col-2 mt-1"><h2><span id="counter">12345</span></h2></div>
|
<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>
|
||||||
<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>
|
<script src="bootstrap.bundle.min.js"></script>
|
||||||
<div class="col-3 mt-1 text-end"><h2><span id="speed">123.4</span>Km/h</h2></div>
|
<div class="bg-info text-white">
|
||||||
<hr>
|
<!-- <div class="row">
|
||||||
</div>
|
<div class="col-2 mt-1"><h2><span id="counter">12345</span></h2></div>
|
||||||
<!--//Constanta Menu-->
|
<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="row g-2 align-items-center">
|
||||||
<div class="col-1"></div>
|
<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 "><label class="col-form-label fs-6 fw-bold">Speed</label></div>
|
||||||
<div class="col-1"></div>
|
<div class="col-1 text-center">X</div>
|
||||||
<div class="col-1 text-center "><label class="col-form-label fs-6 fw-bold">Distance(Km)</label></div>
|
|
||||||
<div class="col-1"></div>
|
|
||||||
<div class="col-1 text-center "><label class="col-form-label fs-6 fw-bold">Time(min)</label></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-1"></div>
|
||||||
<div class="col-2 text-center "><label class="col-form-label fs-6 fw-bold">Start Time</label></div>
|
<div class="col-2 text-center "><label class="col-form-label fs-6 fw-bold">Start Time</label></div>
|
||||||
</div>
|
</div>
|
||||||
|
)rawliteral";
|
||||||
|
|
||||||
|
const char HTML_CONSTROW[] PROGMEM = R"rawliteral(
|
||||||
<div class="row g-2 align-items-center" id="tripA">
|
<div class="row g-2 align-items-center" id="trip%A%">
|
||||||
<div class="col-1 "><label for="speedA" class="col-form-label fs-4 ms-2 trip">A-></label></div>
|
<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="text" step="any" maxlength="6" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
|
||||||
id="speedA" name="speedA" class="form-control speed" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></div>
|
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<input type="text" step="any" maxlength="6" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
<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="distA" name="distA" class="form-control dist" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></div>
|
id="%dist%" name="%dist%" class="form-control dist" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></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)"></div>
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<input type="text" maxlength="5" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
<input type="number" maxlength="5" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
||||||
id="timeA" name="timeA" class="form-control time" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></div>
|
id="%time%" name="%time%" class="form-control time" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></div>
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<input type="time" id="stimeA" name="stimeA" class="form-control stime" onchange="chback(this)" required></div>
|
<input type="time" id="%stime%" name="%stime%" class="form-control stime" onchange="chback(this)"></div>
|
||||||
<div class="col-auto">
|
<div class="col-2">
|
||||||
<button class="btn btn-primary fw-bold" id="myBtn" onclick="setConstanta(this)">SET A</button></div>
|
<button class="btn btn-primary fw-bold" id="myBtn" onclick="setConstanta(this)">SET %A%</button></div>
|
||||||
</div>
|
|
||||||
<div class="row g-2 align-items-center" id="tripB">
|
|
||||||
<div class="col-1 "><label for="speedB" class="col-form-label fs-4 trip">B-></label></div>
|
|
||||||
<div class="col-2 ">
|
|
||||||
<input type="text" step="any" maxlength="6" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
|
||||||
id="SpeedB" name="speedB" class="form-control speed" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></div>
|
|
||||||
<div class="col-2">
|
|
||||||
<input type="text" step="any" maxlength="6" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
|
||||||
id="distB" name="distB" class="form-control dist" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></div>
|
|
||||||
<div class="col-2">
|
|
||||||
<input type="text" maxlength="5" required oninput="javascript: if (this.value.length > this.maxLength) this.value = this.value.slice(0, this.maxLength);"
|
|
||||||
id="timeB" name="timeB" class="form-control time" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></div>
|
|
||||||
<div class="col-2">
|
|
||||||
<input type="time" id="stimeB" name="stimeB" class="form-control stime" onchange="chback(this)"></div>
|
|
||||||
<div class="col-auto">
|
|
||||||
<button class="btn btn-primary fw-bold" id="myBtn" onclick="setConstanta(this)">SET B</button></div>
|
|
||||||
</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";
|
||||||
<button ondblclick="location.href='/menu';" class="btn btn-primary fw-bold btn-sm mt-2 mb-2 ms-3">Back to Menu</button>
|
console.log("before open");
|
||||||
</div>
|
// for (var i=65; i<81; i++){
|
||||||
|
xhr.open("POST", url, true);
|
||||||
<script>
|
console.log("before setrequest");
|
||||||
function setConstanta(e){
|
xhr.setRequestHeader("Content-Type", "application/json");
|
||||||
e = e || window.event;
|
xhr.onreadystatechange = function () {
|
||||||
var targ1 = e.target || e.srcElement || e;
|
console.log(xhr.responseText);
|
||||||
if (targ1.nodeType == 3) targ1 = targ1.parentNode; // defeat Safari bug
|
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||||
const targ = targ1.closest(".row");
|
var jsonAllTrip = JSON.parse(xhr.responseText);
|
||||||
const trip = targ.getElementsByClassName("trip")[0].textContent.split("-")[0];
|
const jsonlen = Object.keys(jsonAllTrip.alltrip).length;
|
||||||
const speed = targ.getElementsByClassName("speed")[0].value;
|
console.log(jsonAllTrip.alltrip[0]);
|
||||||
if (speed===""){
|
console.log("jsondlen="+jsonlen);
|
||||||
alert ("Trip "+trip+"-> [Speed] is required");
|
var jsontemp;
|
||||||
return;
|
for (var i=0; i<jsonlen; i++){
|
||||||
}
|
jsontemp = jsonAllTrip.alltrip[i];
|
||||||
const stime = targ.getElementsByClassName("stime")[0].value;
|
console.log(jsontemp);
|
||||||
if (stime===""){
|
var json = JSON.parse(JSON.stringify(jsontemp));
|
||||||
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 dist = targ.getElementsByClassName("dist")[0].value;
|
|
||||||
const time = targ.getElementsByClassName("time")[0].value;
|
|
||||||
|
|
||||||
var full_data='{"trip":"'+trip+'", "speed":"'+speed+'", "dist":"'+dist+'", "time":"'+time+'", "stime":"'+stime+'"}';
|
|
||||||
console.log(full_data);
|
|
||||||
sendjson(full_data);
|
|
||||||
};
|
|
||||||
|
|
||||||
function compare(name){
|
|
||||||
let name1=name || "";
|
|
||||||
console.log(name, name1)
|
|
||||||
return name1;
|
|
||||||
};
|
|
||||||
|
|
||||||
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) {
|
|
||||||
var tripID = document.getElementById("trip"+json.trip);
|
|
||||||
const speed = tripID.getElementsByClassName("speed"+json.trip);
|
|
||||||
const dist = tripID.getElementsByClassName("dist"+json.trip);
|
|
||||||
const time = tripID.getElementsByClassName("time"+json.trip);
|
|
||||||
const stime = tripID.getElementsByClassName("stime"+json.trip);
|
|
||||||
speed.value = json.speed;
|
|
||||||
dist.value = json.dist;
|
|
||||||
time.value = json.time;
|
|
||||||
stime.value = json.stime;
|
|
||||||
speed.style.backgroundColor = "green"
|
|
||||||
dist.style.backgroundColor = "green"
|
|
||||||
time.style.backgroundColor = "green"
|
|
||||||
stime.style.backgroundColor = "green"
|
|
||||||
console.log("result:"+json.trip + ", " + speed.value + ", " + dist.value + ", " + time.value + ", " + stime.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log(json);
|
console.log(json);
|
||||||
}
|
|
||||||
};
|
// if (json.ok) {
|
||||||
console.log(data);
|
parsingjson(json);
|
||||||
var datajson = JSON.stringify(data);
|
}
|
||||||
console.log(datajson);
|
//console.log(json.trip + ", " + json.speed + ", " + json.dist + ", " + json.time + ", " + json.stime);
|
||||||
xhr.send(data);
|
console.log(json);
|
||||||
}
|
}
|
||||||
</script>
|
};
|
||||||
</body></html>
|
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;
|
||||||
|
}
|
||||||
|
// 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>
|
||||||
@ -17,7 +17,7 @@
|
|||||||
<div class="card-header"><h1>MENU</h1></div>
|
<div class="card-header"><h1>MENU</h1></div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row align-self-end g-1">
|
<div class="row align-self-end g-1">
|
||||||
<div class="col text-center "><button onclick="location.href='/startrally1';" id="startrally" name="startrally" class="btn btn-primary btn-lg me-2 mb-2">RALLY</button></div>
|
<div class="col text-center "><button onclick="location.href='/startrally';" id="startrally" name="startrally" class="btn btn-primary btn-lg me-2 mb-2">RALLY</button></div>
|
||||||
<div class="col text-center"><button onclick="location.href='/calibration';" id="calibration" name="calibration" class="btn btn-primary me-2 mb-2">CALIBRATION</button></div>
|
<div class="col text-center"><button onclick="location.href='/calibration';" id="calibration" name="calibration" class="btn btn-primary me-2 mb-2">CALIBRATION</button></div>
|
||||||
<div class="col text-center"><button onclick="location.href='/constanta';" id="constanta" name="constanta" class="btn btn-primary me-2 mb-2">CONSTANTA</button></div>
|
<div class="col text-center"><button onclick="location.href='/constanta';" id="constanta" name="constanta" class="btn btn-primary me-2 mb-2">CONSTANTA</button></div>
|
||||||
<div class="col text-center"><button onclick="location.href='/settime';" id="constanta" name="constanta" class="btn btn-primary me-2 mb-2">Set TIME</button></div>
|
<div class="col text-center"><button onclick="location.href='/settime';" id="constanta" name="constanta" class="btn btn-primary me-2 mb-2">Set TIME</button></div>
|
||||||
|
|||||||
387
src/constanta.h
387
src/constanta.h
@ -1,199 +1,230 @@
|
|||||||
const char HTML_CONSTHEADER[] PROGMEM = R"rawliteral(
|
const char HTML_CONSTHEADER[] PROGMEM = R"rawliteral(
|
||||||
<!DOCTYPE HTML><html><head>
|
<!DOCTYPE HTML><html><head>
|
||||||
<title>Rally TerraTrip v1 Constanta</title>
|
<title>Rally TerraTrip v1 Constanta</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>
|
<script>
|
||||||
function onlyNumberKey(evt,e) {
|
function onlyNumberKey(evt,e) {
|
||||||
// Only ASCII character in that range allowed
|
// Only ASCII character in that range allowed
|
||||||
var ASCIICode = (evt.which) ? evt.which : evt.keyCode
|
var ASCIICode = (evt.which) ? evt.which : evt.keyCode
|
||||||
if (ASCIICode > 31 && (ASCIICode < 48 || ASCIICode > 57) && ASCIICode !=46)
|
if (ASCIICode > 31 && (ASCIICode < 48 || ASCIICode > 57) && ASCIICode !=46)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
function chback(e){ //change background to yellow
|
||||||
function chback(e){ //change background to yellow
|
var val = e.value;
|
||||||
e.style.backgroundColor = "yellow";
|
var okColor = "yellow"
|
||||||
}
|
var Warning = "red"
|
||||||
</script>
|
console.log(val);
|
||||||
</head><body onload="loaded();">
|
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="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>
|
<script src="bootstrap.bundle.min.js"></script>
|
||||||
<div class="bg-info text-white">
|
<div class="bg-info text-white">
|
||||||
<!-- <div class="row">
|
<!-- <div class="row">
|
||||||
<div class="col-2 mt-1"><h2><span id="counter">12345</span></h2></div>
|
<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-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 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>
|
<div class="col-3 mt-1 text-end"><h2><span id="speed">123.4</span>Km/h</h2></div>
|
||||||
<hr>
|
<hr>
|
||||||
</div>
|
</div>
|
||||||
-->
|
-->
|
||||||
<!--//Constanta Menu-->
|
<!--//Constanta Menu-->
|
||||||
<div class="row g-2 align-items-center">
|
<div class="row g-2 align-items-center">
|
||||||
<div class="col-1"></div>
|
<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-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-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 "><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">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 text-center "><label class="col-form-label fs-6 fw-bold">Time(min)</label></div>
|
||||||
<div class="col-1"></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 class="col-2 text-center "><label class="col-form-label fs-6 fw-bold">Start Time</label></div>
|
||||||
</div>
|
</div>
|
||||||
)rawliteral";
|
)rawliteral";
|
||||||
|
|
||||||
const char HTML_CONSTROW[] PROGMEM = R"rawliteral(
|
const char HTML_CONSTROW[] PROGMEM = R"rawliteral(
|
||||||
<div class="row g-2 align-items-center" id="trip%A%">
|
<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-1 "><label for="%dist%" class="col-form-label fs-4 ms-1 trip">%A%></label></div>
|
||||||
<div class="col-2">
|
<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);"
|
<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)"></div>
|
id="%dist%" name="%dist%" class="form-control dist" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></div>
|
||||||
<div class="col-2 ">
|
<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);"
|
<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)"></div>
|
id="%speed%" name="%speed%" class="form-control speed" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></div>
|
||||||
<div class="col-2">
|
<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);"
|
<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)"></div>
|
id="%time%" name="%time%" class="form-control time" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)"></div>
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<input type="time" id="%stime%" name="%stime%" class="form-control stime" onchange="chback(this)"></div>
|
<input type="time" id="%stime%" name="%stime%" class="form-control stime" onchange="chback(this)"></div>
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<button class="btn btn-primary fw-bold" id="myBtn" onclick="setConstanta(this)">SET %A%</button></div>
|
<button class="btn btn-primary fw-bold" id="myBtn" onclick="setConstanta(this)">SET %A%</button></div>
|
||||||
</div>
|
</div>
|
||||||
)rawliteral";
|
)rawliteral";
|
||||||
|
|
||||||
const char HTML_CONSTEND[] PROGMEM = R"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>
|
<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>
|
|
||||||
// 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){
|
<script>
|
||||||
e = e || window.event;
|
// document.addEventListener("DOMContentLoaded", function() {
|
||||||
var targ1 = e.target || e.srcElement || e;
|
function loaded(){
|
||||||
if (targ1.nodeType == 3) targ1 = targ1.parentNode; // defeat Safari bug
|
var xhr = new XMLHttpRequest();
|
||||||
const targ = targ1.closest(".row");
|
var url = "/rest/loadconst";
|
||||||
const trip = targ.getElementsByClassName("trip")[0].textContent[0];
|
console.log("before open");
|
||||||
const speed = targ.getElementsByClassName("speed")[0].value;
|
// for (var i=65; i<81; i++){
|
||||||
if (speed===""){
|
xhr.open("POST", url, true);
|
||||||
alert ("Trip "+trip+"-> [Speed] is required");
|
console.log("before setrequest");
|
||||||
return;
|
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);
|
||||||
}
|
}
|
||||||
const stime = targ.getElementsByClassName("stime")[0].value;
|
};
|
||||||
if (stime===""){
|
let data = '{"req":"B"}'
|
||||||
alert ("Trip "+trip+"-> [Start Time] is required");
|
console.log(data);
|
||||||
return;
|
var datajson = JSON.stringify(data);
|
||||||
}
|
console.log(datajson);
|
||||||
// targ.getElementsByClassName("speed")[0].value = "345" //trial change backColor
|
|
||||||
// targ.getElementsByClassName("speed")[0].style.backgroundColor = "white"
|
|
||||||
const dist = targ.getElementsByClassName("dist")[0].value;
|
|
||||||
const time = targ.getElementsByClassName("time")[0].value;
|
|
||||||
|
|
||||||
var full_data='{"trip":"'+trip+'", "speed":"'+speed+'", "dist":"'+dist+'", "time":"'+time+'", "stime":"'+stime+'"}';
|
// console.log(String.fromCharCode(i));
|
||||||
console.log(full_data);
|
// data = '{"req":"'+String.fromCharCode(i)+'"}'
|
||||||
sendjson(full_data);
|
xhr.send(data);
|
||||||
};
|
// }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
function parsingjson(json){
|
function setConstanta(e){
|
||||||
console.log(json);
|
e = e || window.event;
|
||||||
var tripID = document.getElementById("trip"+json.trip);
|
var targ1 = e.target || e.srcElement || e;
|
||||||
console.log(tripID);
|
if (targ1.nodeType == 3) targ1 = targ1.parentNode; // defeat Safari bug
|
||||||
const speed = tripID.getElementsByClassName("speed")[0];
|
const targ = targ1.closest(".row");
|
||||||
const dist = tripID.getElementsByClassName("dist")[0];
|
const trip = targ.getElementsByClassName("trip")[0].textContent[0];
|
||||||
const time = tripID.getElementsByClassName("time")[0];
|
const speed = targ.getElementsByClassName("speed")[0].value;
|
||||||
const stime = tripID.getElementsByClassName("stime")[0];
|
const dist = targ.getElementsByClassName("dist")[0].value;
|
||||||
setValBackColor(speed, json.speed);
|
const time = targ.getElementsByClassName("time")[0].value;
|
||||||
setValBackColor(dist, json.dist);
|
if (!(dist<1000)){
|
||||||
setValBackColor(time, json.time);
|
alert ("Trip "+trip+"-> [Dist] cannot exceed 1000 Km");
|
||||||
setValBackColor(stime, json.stime);
|
return;
|
||||||
// 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>
|
if (speed===""){
|
||||||
</body></html>
|
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";
|
)rawliteral";
|
||||||
551
src/main.cpp
551
src/main.cpp
@ -152,6 +152,7 @@ const int lcdRows = 4;
|
|||||||
///lolin esp32 lite i2c pin
|
///lolin esp32 lite i2c pin
|
||||||
#define I2C_SDA 15
|
#define I2C_SDA 15
|
||||||
#define I2C_SCL 13
|
#define I2C_SCL 13
|
||||||
|
#define FREQHZ 400000U
|
||||||
#define LED_BUILTIN 22 // LED built in pada ESP32 Lolin32 Lite
|
#define LED_BUILTIN 22 // LED built in pada ESP32 Lolin32 Lite
|
||||||
// set LCD address, number of columns and rows
|
// set LCD address, number of columns and rows
|
||||||
// if you don't know your display address, run an I2C scanner sketch
|
// if you don't know your display address, run an I2C scanner sketch
|
||||||
@ -981,6 +982,30 @@ void constantatodigit()
|
|||||||
//digit6=(int)((constanta*10000 - (int)(constanta*10000))*10);
|
//digit6=(int)((constanta*10000 - (int)(constanta*10000))*10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setSpiffSpeedInConstanta(float mConstanta, uint8_t setSpiffcurTrip){
|
||||||
|
char filename[7] = "/tripZ";
|
||||||
|
setSpiffcurTrip+=65;
|
||||||
|
filename[5]=setSpiffcurTrip;
|
||||||
|
Serial.println(filename);
|
||||||
|
Serial.println(mConstanta);
|
||||||
|
String result = readFile(SPIFFS, filename);
|
||||||
|
result.reserve(128);
|
||||||
|
DynamicJsonDocument doc(128);
|
||||||
|
deserializeJson(doc, result);
|
||||||
|
if (doc["trip"].as<String>()=="null") doc["trip"]=String(char(setSpiffcurTrip));
|
||||||
|
if (doc["dist"].as<String>()=="null") doc["dist"]="";
|
||||||
|
if (doc["time"].as<String>()=="null") doc["time"]="";
|
||||||
|
if (doc["stime"].as<String>()=="null") doc["stime"]="";
|
||||||
|
String strConstanta = String(mConstanta,4);
|
||||||
|
Serial.println(strConstanta);
|
||||||
|
doc["speed"] = strConstanta;
|
||||||
|
result="";
|
||||||
|
serializeJson(doc,result);
|
||||||
|
writeFile(SPIFFS, filename, result.c_str());
|
||||||
|
Serial.print("Write speed:");Serial.println(result);
|
||||||
|
Trip[setSpiffcurTrip].speed = mConstanta;
|
||||||
|
}
|
||||||
|
|
||||||
void setMemSpeedInConstanta(float constanta, uint8_t setmemcurTrip){
|
void setMemSpeedInConstanta(float constanta, uint8_t setmemcurTrip){
|
||||||
int pointeradd = ((TRIPADDRESS+setmemcurTrip)*32);
|
int pointeradd = ((TRIPADDRESS+setmemcurTrip)*32);
|
||||||
mem.writeFloat(pointeradd, constanta);
|
mem.writeFloat(pointeradd, constanta);
|
||||||
@ -995,12 +1020,38 @@ float getMemSpeedInConstanta(uint8_t getmemSpeedcurTrip){
|
|||||||
}
|
}
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
void setMemStime(unsigned long valuesettime, uint8_t setmemssTimecurTrip){
|
void setSpiffStime(unsigned long mvaluesettime, uint8_t setSpiffcurTrip){
|
||||||
|
char filename[7] = "/tripZ";
|
||||||
|
setSpiffcurTrip+=65;
|
||||||
|
filename[5]=setSpiffcurTrip;
|
||||||
|
Serial.println(filename);
|
||||||
|
Serial.println(mvaluesettime);
|
||||||
|
String result = readFile(SPIFFS, filename);
|
||||||
|
result.reserve(128);
|
||||||
|
DynamicJsonDocument doc(128);
|
||||||
|
deserializeJson(doc, result);
|
||||||
|
char msTime[6];
|
||||||
|
byte sHour, sMin;
|
||||||
|
sHour = mvaluesettime/65536;
|
||||||
|
sMin = (mvaluesettime/256)-sHour*256;
|
||||||
|
sprintf(msTime, "%02u:%02u", sHour, sMin);
|
||||||
|
Serial.print("dist:");Serial.print(doc["dist"].as<String>());Serial.println(";");
|
||||||
|
if (doc["trip"].as<String>()=="null") doc["trip"]=String(char(setSpiffcurTrip));
|
||||||
|
if (doc["dist"].as<String>()=="null") doc["dist"]="";
|
||||||
|
if (doc["speed"].as<String>()=="null") doc["speed"]="";
|
||||||
|
if (doc["time"].as<String>()=="null") doc["time"]="";
|
||||||
|
doc["stime"]=msTime;
|
||||||
|
result="";
|
||||||
|
serializeJson(doc,result);
|
||||||
|
writeFile(SPIFFS, filename, result.c_str());
|
||||||
|
Serial.print("Write sTime:");Serial.println(result);
|
||||||
|
}
|
||||||
|
void setMemStime(unsigned long mvaluesettime, uint8_t setmemssTimecurTrip){
|
||||||
int pointeradd = ((TRIPADDRESS+setmemssTimecurTrip)*32+4);
|
int pointeradd = ((TRIPADDRESS+setmemssTimecurTrip)*32+4);
|
||||||
mem.writeLong(pointeradd, valuesettime);
|
mem.writeLong(pointeradd, mvaluesettime);
|
||||||
Trip[setmemssTimecurTrip].startHour = (valuesettime/65536); //starttracthour;
|
Trip[setmemssTimecurTrip].startHour = (mvaluesettime/65536); //starttracthour;
|
||||||
Trip[setmemssTimecurTrip].startMin = (valuesettime/256)-Trip[setmemssTimecurTrip].startHour*256; // starttractmin;
|
Trip[setmemssTimecurTrip].startMin = (mvaluesettime/256)-Trip[setmemssTimecurTrip].startHour*256; // starttractmin;
|
||||||
Trip[setmemssTimecurTrip].startSec = valuesettime-((Trip[setmemssTimecurTrip].startHour*256 + Trip[curTrip].startMin)*256);//starttractsec;
|
Trip[setmemssTimecurTrip].startSec = mvaluesettime-((Trip[setmemssTimecurTrip].startHour*256 + Trip[curTrip].startMin)*256);//starttractsec;
|
||||||
Serial.print(Trip[setmemssTimecurTrip].startHour);Serial.print(";");
|
Serial.print(Trip[setmemssTimecurTrip].startHour);Serial.print(";");
|
||||||
Serial.print(Trip[setmemssTimecurTrip].startMin);Serial.print(";");
|
Serial.print(Trip[setmemssTimecurTrip].startMin);Serial.print(";");
|
||||||
Serial.println(Trip[setmemssTimecurTrip].startSec);
|
Serial.println(Trip[setmemssTimecurTrip].startSec);
|
||||||
@ -2228,6 +2279,42 @@ void fillTripArray(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handelSetWifi(AsyncWebServerRequest *request){
|
||||||
|
String inputMessage;
|
||||||
|
boolean bolrestart=false;
|
||||||
|
boolean POST=true;
|
||||||
|
Serial.print("/setwifi:");
|
||||||
|
// GET inputString value on <ESP_IP>/get?inputString=<inputMessage>
|
||||||
|
if (request->hasParam(PARAM_SSID, POST)) {
|
||||||
|
inputMessage = request->getParam(PARAM_SSID, POST )->value();
|
||||||
|
Serial.print(inputMessage);Serial.print(";");
|
||||||
|
if (inputMessage!=""){
|
||||||
|
Serial.print(inputMessage);
|
||||||
|
writeFile(SPIFFS, "/ssidString.txt", inputMessage.c_str());
|
||||||
|
delay(50);
|
||||||
|
bolrestart=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// GET inputPwd value on <ESP_IP>/wifi/get?inputPwd=<inputMessage>
|
||||||
|
if (request->hasParam(PARAM_PWD, POST)) {
|
||||||
|
inputMessage = request->getParam(PARAM_PWD, POST)->value();
|
||||||
|
Serial.print(inputMessage);Serial.print(";");
|
||||||
|
if (inputMessage!=""){
|
||||||
|
writeFile(SPIFFS, "/inputPwd.txt", inputMessage.c_str());
|
||||||
|
delay(50);
|
||||||
|
bolrestart=true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inputMessage = "No message sent";
|
||||||
|
}
|
||||||
|
Serial.println("");
|
||||||
|
if (bolrestart) {
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
// Serial.println("ini /setwifi aja");Serial.println(inputMessage);
|
||||||
|
request->send(200, "text/text", inputMessage);
|
||||||
|
}
|
||||||
void handleConstantaHTML(AsyncWebServerRequest *request) {
|
void handleConstantaHTML(AsyncWebServerRequest *request) {
|
||||||
//PAGE.replace("%serveripaddress%", WiFi.localIP().toString());
|
//PAGE.replace("%serveripaddress%", WiFi.localIP().toString());
|
||||||
//request->send_P(200, "text/html", HTML_CALIBRATION, processor);
|
//request->send_P(200, "text/html", HTML_CALIBRATION, processor);
|
||||||
@ -2335,7 +2422,6 @@ void handlesetConst(AsyncWebServerRequest *request, JsonVariant &json){
|
|||||||
// request->send(200, "text/plain", hasil); // handle data and respond
|
// request->send(200, "text/plain", hasil); // handle data and respond
|
||||||
serializeJson(data, *response);
|
serializeJson(data, *response);
|
||||||
request->send(response);
|
request->send(response);
|
||||||
|
|
||||||
// request->send(200, "text/plain", hasil);
|
// request->send(200, "text/plain", hasil);
|
||||||
isloadingConst=false;
|
isloadingConst=false;
|
||||||
}
|
}
|
||||||
@ -2412,39 +2498,26 @@ void setup() {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
//#ifdef DEBUG
|
//#ifdef DEBUG
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
Serial.println("Starting Rally");
|
Serial.println("Starting Rally");
|
||||||
//#endif
|
//#endif
|
||||||
// pinMode(ledPin, OUTPUT);
|
pinMode(simulatorPWMPin,OUTPUT);
|
||||||
uint32_t freqhz=400000;
|
pinMode(LED_BUILTIN, OUTPUT);
|
||||||
// Wire.begin(15, 13, freqhx); //for lolin32lite sda=15; scl=13
|
pinMode(interruptPin, INPUT); //Pull down using resistor to ground
|
||||||
pinMode(simulatorPWMPin,OUTPUT);
|
attachInterrupt(digitalPinToInterrupt(interruptPin), blink, FALLING);
|
||||||
pinMode(LED_BUILTIN, OUTPUT);
|
|
||||||
pinMode(interruptPin, INPUT); //Pull down using resistor to ground
|
|
||||||
attachInterrupt(digitalPinToInterrupt(interruptPin), blink, FALLING);
|
|
||||||
|
|
||||||
|
|
||||||
// attachInterrupt(digitalPinToInterrupt(interruptPin), blink, FALLING);
|
btnUP.begin(); /// using JC_BUTTON harus ada begin
|
||||||
// attachInterrupt(interruptPin, isr, FALLING);
|
btnDN.begin();
|
||||||
// Wire.begin(I2C_SDA, I2C_SCL); //for lolin32lite sda=15; scl=13
|
btnLF.begin();
|
||||||
// Wire.begin(15, 13); //for lolin32lite sda=15; scl=13
|
btnRF.begin();
|
||||||
// pinMode(UP_pin, INPUT_PULLUP); ///
|
btnOK.begin();
|
||||||
// pinMode(DOWN_pin, INPUT_PULLUP); ///
|
btnESC.begin();
|
||||||
// pinMode(LEFT_pin, INPUT_PULLUP); ///
|
//DS3231_init(DS3231_INTCN);
|
||||||
// pinMode(RIGHT_pin, INPUT_PULLUP); ///
|
|
||||||
// pinMode(OK_pin, INPUT_PULLUP); ///
|
// //memset(recv, 0, BUFF_MAX);
|
||||||
|
|
||||||
btnUP.begin(); /// using JC_BUTTON harus ada begin
|
|
||||||
btnDN.begin();
|
|
||||||
btnLF.begin();
|
|
||||||
btnRF.begin();
|
|
||||||
btnOK.begin();
|
|
||||||
btnESC.begin();
|
|
||||||
//DS3231_init(DS3231_INTCN);
|
|
||||||
|
|
||||||
// //memset(recv, 0, BUFF_MAX);
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("GET time");
|
Serial.println("GET time");
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
Trip[0].sub = "A";
|
Trip[0].sub = "A";
|
||||||
@ -2461,75 +2534,53 @@ Trip[9].startSec = 58;
|
|||||||
//Serial.println(Trip[0].sub);Serial.println(Trip[0].speed);Serial.println(Trip[0].startHour);Serial.println(Trip[0].startMin);Serial.println(Trip[0].startSec);
|
//Serial.println(Trip[0].sub);Serial.println(Trip[0].speed);Serial.println(Trip[0].startHour);Serial.println(Trip[0].startMin);Serial.println(Trip[0].startSec);
|
||||||
//Serial.println(Trip[0].distance);
|
//Serial.println(Trip[0].distance);
|
||||||
//Serial.println(Trip[0].subTime);
|
//Serial.println(Trip[0].subTime);
|
||||||
|
// uint32_t freqhz=400000;
|
||||||
|
Wire.begin(I2C_SDA, I2C_SCL, FREQHZ); //for lolin32lite sda=15; scl=13 //Dont move up or down
|
||||||
|
|
||||||
|
//**************************LCD Setup********************************
|
||||||
// lcd.init();
|
|
||||||
// lcd.backlight();
|
|
||||||
|
|
||||||
// lcd.begin(20, 4);
|
|
||||||
// // if(lcd.begin(20, 4))
|
|
||||||
// // {
|
|
||||||
// // // begin() failed so blink the onboard LED if possible
|
|
||||||
// // return; // this never returns
|
|
||||||
// // }
|
|
||||||
// lcd.setBacklight(0xff);
|
|
||||||
// // Wire.setClock(100000L); // set i2c clock bit rate, if asked
|
|
||||||
|
|
||||||
// lcd.print("i2c clock:");
|
|
||||||
// lcd.setCursor(0,1);
|
|
||||||
// lcd.print(Wire.getClock());
|
|
||||||
// lcd.print(" Hz");
|
|
||||||
// delay(3000);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Wire.begin(I2C_SDA, I2C_SCL, freqhz); //for lolin32lite sda=15; scl=13
|
|
||||||
|
|
||||||
//**************************LCD Setup********************************
|
|
||||||
delay(100);
|
delay(100);
|
||||||
// lcd.begin (20,4); // initialize the lcd
|
// lcd.begin (20,4); // initialize the lcd
|
||||||
// lcd.init();
|
// lcd.init();
|
||||||
lcd.begin();
|
lcd.begin();
|
||||||
// lcd2.begin();
|
// lcd2.begin();
|
||||||
// Wire.begin(I2C_SDA, I2C_SCL); //for lolin32lite sda=15; scl=13
|
|
||||||
// Switch on the backlight
|
// Switch on the backlight
|
||||||
/// lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
|
/// lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
|
||||||
// lcd.backlight();
|
// lcd.backlight();
|
||||||
// lcd2.backlight();
|
// lcd2.backlight();
|
||||||
/// lcd.setBacklight(LED_ON);
|
/// lcd.setBacklight(LED_ON);
|
||||||
|
|
||||||
// lcd2.print("hello rally20");
|
// lcd2.print("hello rally20");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//***************************END LCD Setup********************************
|
//***************************END LCD Setup********************************
|
||||||
getCalibJson.reserve(512);
|
getCalibJson.reserve(512);
|
||||||
getRallyJson.reserve(512);
|
getRallyJson.reserve(512);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.println("Setting time");
|
Serial.println("Setting time");
|
||||||
#endif
|
#endif
|
||||||
//char a[]="304022129022016";
|
DS3231_init(DS3231_CONTROL_INTCN);
|
||||||
DS3231_init(DS3231_CONTROL_INTCN);
|
DS3231_get(&t); //Get time
|
||||||
DS3231_get(&t); //Get time
|
|
||||||
|
|
||||||
blinkON=false;
|
blinkON=false;
|
||||||
sec60=t.sec;
|
sec60=t.sec;
|
||||||
min60=t.min;
|
min60=t.min;
|
||||||
hour24=t.hour;
|
hour24=t.hour;
|
||||||
|
|
||||||
delay(100); // delay for reading mem.read
|
delay(100); // delay for reading mem.read
|
||||||
//mainMenu();
|
//mainMenu();
|
||||||
printUPchar();
|
printUPchar();
|
||||||
printDOWNchar();
|
printDOWNchar();
|
||||||
count1 = memretrieveLong(count1Address, RRcountSIZE, count1Seq); //(int startaddress, byte RRsize, unsigned long seq)
|
count1 = memretrieveLong(count1Address, RRcountSIZE, count1Seq); //(int startaddress, byte RRsize, unsigned long seq)
|
||||||
Serial.println(count1Seq);
|
Serial.println(count1Seq);
|
||||||
int countaddresspointer = count1count2diffAddress*32;
|
int countaddresspointer = count1count2diffAddress*32;
|
||||||
Serial.print(countaddresspointer);
|
Serial.print(countaddresspointer);
|
||||||
count1count2diff = mem.readLong(countaddresspointer);
|
count1count2diff = mem.readLong(countaddresspointer);
|
||||||
//count1count2diff = mem.readLong((count1count2diffAddress*32));
|
//count1count2diff = mem.readLong((count1count2diffAddress*32));
|
||||||
count2 = count1 - count1count2diff;
|
count2 = count1 - count1count2diff;
|
||||||
//printmemLong(0,20); //startaddress, size
|
//printmemLong(0,20); //startaddress, size
|
||||||
Serial.print("count1=");Serial.print(count1);Serial.print(";count2=");Serial.print(count2);Serial.print("countdiff=");Serial.println(count1count2diff);
|
Serial.print("count1=");Serial.print(count1);Serial.print(";count2=");Serial.print(count2);Serial.print("countdiff=");Serial.println(count1count2diff);
|
||||||
|
|
||||||
// // TESTING MEM AT24cx EEPROM check the address in the library #define ..... 0x57
|
// // TESTING MEM AT24cx EEPROM check the address in the library #define ..... 0x57
|
||||||
// Serial.println("Write 42 to address 12");
|
// Serial.println("Write 42 to address 12");
|
||||||
@ -2539,70 +2590,70 @@ DS3231_init(DS3231_CONTROL_INTCN);
|
|||||||
// Serial.print("... read: ");
|
// Serial.print("... read: ");
|
||||||
// Serial.println(b, DEC);
|
// Serial.println(b, DEC);
|
||||||
// Serial.println();
|
// Serial.println();
|
||||||
|
|
||||||
//count1Seq = 4294967290;
|
//count1Seq = 4294967290;
|
||||||
/*
|
/*
|
||||||
for (int i=0; i<25 ; i++){
|
for (int i=0; i<25 ; i++){
|
||||||
count1Seq++;
|
count1Seq++;
|
||||||
//Serial.println(count1Seq);
|
//Serial.println(count1Seq);
|
||||||
//memwritingLong(rrcountpointer1, count1Seq, count1+1, RRcountSIZE );
|
//memwritingLong(rrcountpointer1, count1Seq, count1+1, RRcountSIZE );
|
||||||
memwritingLong(count1Address, RRcountSIZE, count1Seq, count1);//(int startaddress, byte RRsize, unsigned long seq, unsigned long Data)
|
memwritingLong(count1Address, RRcountSIZE, count1Seq, count1);//(int startaddress, byte RRsize, unsigned long seq, unsigned long Data)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//mem.writeLong(896, 110025); to reset CALIBRATION value to CRV
|
//mem.writeLong(896, 110025); to reset CALIBRATION value to CRV
|
||||||
/*
|
/*
|
||||||
starttracthour=mem.read(770);
|
starttracthour=mem.read(770);
|
||||||
starttractmin=mem.read(769);
|
starttractmin=mem.read(769);
|
||||||
starttractsec=mem.read(768);
|
starttractsec=mem.read(768);
|
||||||
*/
|
*/
|
||||||
// for (int i = 0; i<TRIPSIZE; i++) {
|
// for (int i = 0; i<TRIPSIZE; i++) {
|
||||||
|
|
||||||
// }
|
// }
|
||||||
for (int i = 0; i<TRIPSIZE; i++) { //reading Trip
|
for (int i = 0; i<TRIPSIZE; i++) { //reading Trip
|
||||||
Trip[i].sub = char(i+65);
|
Trip[i].sub = char(i+65);
|
||||||
memretrieveTrip(i, (TRIPADDRESS+i)*32);
|
memretrieveTrip(i, (TRIPADDRESS+i)*32);
|
||||||
// Serial.print(Trip[i].sub);Serial.print(Trip[i].speed,5); Serial.print(";"); Serial.print(Trip[i].startHour); Serial.print(":");
|
// Serial.print(Trip[i].sub);Serial.print(Trip[i].speed,5); Serial.print(";"); Serial.print(Trip[i].startHour); Serial.print(":");
|
||||||
// Serial.print(Trip[i].startMin); Serial.print(":");Serial.print(Trip[i].startSec); Serial.println(";");
|
// Serial.print(Trip[i].startMin); Serial.print(":");Serial.print(Trip[i].startSec); Serial.println(";");
|
||||||
}
|
}
|
||||||
starttracthour=Trip[curTrip].startHour;
|
starttracthour=Trip[curTrip].startHour;
|
||||||
starttractmin=Trip[curTrip].startMin;
|
starttractmin=Trip[curTrip].startMin;
|
||||||
starttractsec=Trip[curTrip].startSec;
|
starttractsec=Trip[curTrip].startSec;
|
||||||
|
|
||||||
if (starttracthour>23) starttracthour = 23;
|
if (starttracthour>23) starttracthour = 23;
|
||||||
if (starttractmin>59) starttractmin = 59;
|
if (starttractmin>59) starttractmin = 59;
|
||||||
if (starttractsec>59) starttractsec = 59;
|
if (starttractsec>59) starttractsec = 59;
|
||||||
//constanta=mem.readFloat(800);
|
//constanta=mem.readFloat(800);
|
||||||
constanta = Trip[curTrip].speed;
|
constanta = Trip[curTrip].speed;
|
||||||
if ((constanta > 150) || (constanta < 0)) constanta = 60; /// aslinya if ((constanta > 150) || (constanta < 0)) constanta = 60;
|
if ((constanta > 150) || (constanta < 0)) constanta = 60; /// aslinya if ((constanta > 150) || (constanta < 0)) constanta = 60;
|
||||||
long m = mem.readLong(896); //read calibration value;
|
long m = mem.readLong(896); //read calibration value;
|
||||||
if (m > 0) {
|
if (m > 0) {
|
||||||
Calibration = m;
|
Calibration = m;
|
||||||
} else Calibration = 110025;
|
} else Calibration = 110025;
|
||||||
// Calibration = 100000;
|
// Calibration = 100000;
|
||||||
|
|
||||||
//#ifdef DEBUG
|
//#ifdef DEBUG
|
||||||
Serial.println("calibration and constanta");
|
Serial.println("calibration and constanta");
|
||||||
Serial.println(m);
|
Serial.println(m);
|
||||||
Serial.println(Calibration);
|
Serial.println(Calibration);
|
||||||
Serial.println(constanta);
|
Serial.println(constanta);
|
||||||
//#endif
|
//#endif
|
||||||
constantatodigit();
|
constantatodigit();
|
||||||
|
|
||||||
// Serial.print(digit1);Serial.print(digit2); Serial.print(digit3); Serial.print(digit4);Serial.print(digit5);Serial.println(digit6);
|
// Serial.print(digit1);Serial.print(digit2); Serial.print(digit3); Serial.print(digit4);Serial.print(digit5);Serial.println(digit6);
|
||||||
// Serial.println(constanta,5);
|
// Serial.println(constanta,5);
|
||||||
//Serial.print(digitalRead(UP_pin));Serial.print(digitalRead(DOWN_pin));Serial.print(digitalRead(LEFT_pin));Serial.print(digitalRead(RIGHT_pin));Serial.println(digitalRead(OK_pin));
|
//Serial.print(digitalRead(UP_pin));Serial.print(digitalRead(DOWN_pin));Serial.print(digitalRead(LEFT_pin));Serial.print(digitalRead(RIGHT_pin));Serial.println(digitalRead(OK_pin));
|
||||||
|
|
||||||
prevcount1 = count1;
|
prevcount1 = count1;
|
||||||
prevcount2 = count2;
|
prevcount2 = count2;
|
||||||
|
|
||||||
prevcalibrationtime+=calibrationtimeinterval;
|
prevcalibrationtime+=calibrationtimeinterval;
|
||||||
prevtempint+=tempinterval;
|
prevtempint+=tempinterval;
|
||||||
prevtemprally+=tempintervalrally;
|
prevtemprally+=tempintervalrally;
|
||||||
prevsettime += intervalsettime;
|
prevsettime += intervalsettime;
|
||||||
startmillis+=1000;
|
startmillis+=1000;
|
||||||
|
|
||||||
|
|
||||||
mainMenu();
|
mainMenu();
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -2649,7 +2700,7 @@ DS3231_init(DS3231_CONTROL_INTCN);
|
|||||||
strncpy(password, yourInputPwd.c_str() , (sizeof password)-1);
|
strncpy(password, yourInputPwd.c_str() , (sizeof password)-1);
|
||||||
// strncpy(password, yourInputPwd.c_str() , (sizeof yourInputPwd)-1);
|
// strncpy(password, yourInputPwd.c_str() , (sizeof yourInputPwd)-1);
|
||||||
}
|
}
|
||||||
Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with pwd:");Serial.println(password);
|
Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with pwd:");Serial.println(password);
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
|
||||||
Serial.println("WiFi Failed!");
|
Serial.println("WiFi Failed!");
|
||||||
@ -2692,58 +2743,22 @@ Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with
|
|||||||
});
|
});
|
||||||
|
|
||||||
server.on("/wifi", HTTP_GET, [](AsyncWebServerRequest * request) {
|
server.on("/wifi", HTTP_GET, [](AsyncWebServerRequest * request) {
|
||||||
|
|
||||||
if (ON_STA_FILTER(request)) {
|
if (ON_STA_FILTER(request)) {
|
||||||
//request->send(200, "text/plain", "Hello from STA");
|
//request->send(200, "text/plain", "Hello from STA");
|
||||||
request->send_P(200, "text/html", wifi_html, processor);
|
request->send_P(200, "text/html", wifi_html, processor);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
} else if (ON_AP_FILTER(request)) {
|
} else if (ON_AP_FILTER(request)) {
|
||||||
//request->send(200, "text/plain", "Hello from AP");
|
//request->send(200, "text/plain", "Hello from AP");
|
||||||
Serial.println("on apfilter /wifi");
|
Serial.println("on apfilter /wifi");
|
||||||
request->send_P(200, "text/html", wifi_html, processor);
|
request->send_P(200, "text/html", wifi_html, processor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
request->send(200, "text/plain", "Hello from undefined");
|
||||||
request->send(200, "text/plain", "Hello from undefined");
|
});
|
||||||
});
|
|
||||||
|
|
||||||
// Send a GET request to <ESP_IP>/get?inputString=<inputMessage>
|
// Send a GET request to <ESP_IP>/get?inputString=<inputMessage>
|
||||||
server.on("/setwifi", HTTP_POST, [] (AsyncWebServerRequest *request) {
|
server.on("/setwifi", HTTP_POST, [] (AsyncWebServerRequest *request) {
|
||||||
String inputMessage;
|
handelSetWifi(request);
|
||||||
boolean bolrestart=false;
|
|
||||||
boolean POST=true;
|
|
||||||
Serial.print("/setwifi:");
|
|
||||||
// GET inputString value on <ESP_IP>/get?inputString=<inputMessage>
|
|
||||||
if (request->hasParam(PARAM_SSID, POST)) {
|
|
||||||
inputMessage = request->getParam(PARAM_SSID, POST )->value();
|
|
||||||
Serial.print(inputMessage);Serial.print(";");
|
|
||||||
if (inputMessage!=""){
|
|
||||||
Serial.print(inputMessage);
|
|
||||||
writeFile(SPIFFS, "/ssidString.txt", inputMessage.c_str());
|
|
||||||
delay(50);
|
|
||||||
bolrestart=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// GET inputPwd value on <ESP_IP>/wifi/get?inputPwd=<inputMessage>
|
|
||||||
if (request->hasParam(PARAM_PWD, POST)) {
|
|
||||||
inputMessage = request->getParam(PARAM_PWD, POST)->value();
|
|
||||||
Serial.print(inputMessage);Serial.print(";");
|
|
||||||
if (inputMessage!=""){
|
|
||||||
writeFile(SPIFFS, "/inputPwd.txt", inputMessage.c_str());
|
|
||||||
delay(50);
|
|
||||||
bolrestart=true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
inputMessage = "No message sent";
|
|
||||||
}
|
|
||||||
Serial.println("");
|
|
||||||
if (bolrestart) {
|
|
||||||
ESP.restart();
|
|
||||||
}
|
|
||||||
// Serial.println("ini /setwifi aja");Serial.println(inputMessage);
|
|
||||||
request->send(200, "text/text", inputMessage);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/menu", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
server.on("/menu", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
@ -2752,21 +2767,21 @@ Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with
|
|||||||
request->send_P(200, "text/html", main_menu);
|
request->send_P(200, "text/html", main_menu);
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/startrallytest", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
// server.on("/startrallytest", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
//String s = MAIN_page; //Read HTML contents
|
// //String s = MAIN_page; //Read HTML contents
|
||||||
//request->send_P(200, "text/html", s); //Send web page
|
// //request->send_P(200, "text/html", s); //Send web page
|
||||||
String PAGE;
|
// String PAGE;
|
||||||
PAGE += FPSTR(HTML_PAGEHEADER);
|
// PAGE += FPSTR(HTML_PAGEHEADER);
|
||||||
PAGE.replace("%serveripaddress%", WiFi.localIP().toString());
|
// PAGE.replace("%serveripaddress%", WiFi.localIP().toString());
|
||||||
PAGE += FPSTR(HTML_DIVSTARTRALLY);
|
// PAGE += FPSTR(HTML_DIVSTARTRALLY);
|
||||||
//PAGE += FPSTR(HTML_SCRIPTSETINTERVAL);
|
// //PAGE += FPSTR(HTML_SCRIPTSETINTERVAL);
|
||||||
//PAGE += FPSTR(HTML_SCRIPTGETDATA);
|
// //PAGE += FPSTR(HTML_SCRIPTGETDATA);
|
||||||
PAGE += FPSTR(HTML_END);
|
// PAGE += FPSTR(HTML_END);
|
||||||
//Serial.println(PAGE);
|
// //Serial.println(PAGE);
|
||||||
Serial.print("PAGE Size:");
|
// Serial.print("PAGE Size:");
|
||||||
Serial.println(PAGE.length());
|
// Serial.println(PAGE.length());
|
||||||
request->send(200, "text/html", PAGE);
|
// request->send(200, "text/html", PAGE);
|
||||||
});
|
// });
|
||||||
|
|
||||||
server.on("/startrally", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
server.on("/startrally", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
request->send_P(200, "text/html", HTML_startrally, processor);
|
request->send_P(200, "text/html", HTML_startrally, processor);
|
||||||
@ -2790,75 +2805,75 @@ Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with
|
|||||||
request->send(SPIFFS, "/bootstrap.min.js", "text/javascript");
|
request->send(SPIFFS, "/bootstrap.min.js", "text/javascript");
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on("/resetodo1", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
// server.on("/resetodo1", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
Serial.println("ODORESET 1");
|
// Serial.println("ODORESET 1");
|
||||||
request->redirect("/startrally1");
|
// request->redirect("/startrally1");
|
||||||
});
|
// });
|
||||||
|
|
||||||
server.on("/resetodo2", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
// server.on("/resetodo2", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
Serial.println("ODORESET 22222");
|
// Serial.println("ODORESET 22222");
|
||||||
request->redirect("/startrally1");
|
// request->redirect("/startrally1");
|
||||||
});
|
// });
|
||||||
|
|
||||||
server.on("/copytoodo2", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
// server.on("/copytoodo2", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
Serial.println("COPY ODO 1 to 2");
|
// Serial.println("COPY ODO 1 to 2");
|
||||||
request->redirect("/startrally1");
|
// request->redirect("/startrally1");
|
||||||
});
|
// });
|
||||||
|
|
||||||
server.on("/copytoodo1", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
// server.on("/copytoodo1", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
Serial.println("COPY ODO 2 to 1");
|
// Serial.println("COPY ODO 2 to 1");
|
||||||
request->redirect("/startrally1");
|
// request->redirect("/startrally1");
|
||||||
});
|
// });
|
||||||
server.on("/DIR", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
|
||||||
String inputMessage;
|
|
||||||
String inputParam;
|
|
||||||
if (request->hasParam("DIR1")){
|
|
||||||
inputMessage=request->getParam("DIR1")->value();
|
|
||||||
Serial.print("DIR 1->");Serial.println(inputMessage);
|
|
||||||
switch(inputMessage[0]){
|
|
||||||
case 'F':
|
|
||||||
Serial.println("FW1");
|
|
||||||
break;
|
|
||||||
case 'S':
|
|
||||||
Serial.println("ST1");
|
|
||||||
break;
|
|
||||||
case 'B':
|
|
||||||
Serial.println("BACK1");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Serial.println("Default VAL1");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (request->hasParam("DIR2")){
|
|
||||||
inputMessage=request->getParam("DIR2")->value();
|
|
||||||
Serial.print("DIR 2->");Serial.println(inputMessage);
|
|
||||||
switch(inputMessage[0]){
|
|
||||||
case 'F':
|
|
||||||
Serial.println("FW2");
|
|
||||||
break;
|
|
||||||
case 'S':
|
|
||||||
Serial.println("ST2");
|
|
||||||
break;
|
|
||||||
case 'B':
|
|
||||||
Serial.println("BACK2");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Serial.println("Default VAL2");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
request->redirect("/startrally1");
|
|
||||||
});
|
|
||||||
|
|
||||||
|
// server.on("/DIR", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
|
// String inputMessage;
|
||||||
|
// String inputParam;
|
||||||
|
// if (request->hasParam("DIR1")){
|
||||||
|
// inputMessage=request->getParam("DIR1")->value();
|
||||||
|
// Serial.print("DIR 1->");Serial.println(inputMessage);
|
||||||
|
// switch(inputMessage[0]){
|
||||||
|
// case 'F':
|
||||||
|
// Serial.println("FW1");
|
||||||
|
// break;
|
||||||
|
// case 'S':
|
||||||
|
// Serial.println("ST1");
|
||||||
|
// break;
|
||||||
|
// case 'B':
|
||||||
|
// Serial.println("BACK1");
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// Serial.println("Default VAL1");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else if (request->hasParam("DIR2")){
|
||||||
|
// inputMessage=request->getParam("DIR2")->value();
|
||||||
|
// Serial.print("DIR 2->");Serial.println(inputMessage);
|
||||||
|
// switch(inputMessage[0]){
|
||||||
|
// case 'F':
|
||||||
|
// Serial.println("FW2");
|
||||||
|
// break;
|
||||||
|
// case 'S':
|
||||||
|
// Serial.println("ST2");
|
||||||
|
// break;
|
||||||
|
// case 'B':
|
||||||
|
// Serial.println("BACK2");
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// Serial.println("Default VAL2");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// request->redirect("/startrally1");
|
||||||
|
// });
|
||||||
|
|
||||||
server.on("/TG1", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
// server.on("/TG1", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
Serial.println("TOGGLE 1");
|
// Serial.println("TOGGLE 1");
|
||||||
request->redirect("/startrally1");
|
// request->redirect("/startrally1");
|
||||||
});
|
// });
|
||||||
|
|
||||||
server.on("/TG2", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
// server.on("/TG2", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
Serial.println("TOGGLE 2");
|
// Serial.println("TOGGLE 2");
|
||||||
request->redirect("/startrally1");
|
// request->redirect("/startrally1");
|
||||||
});
|
// });
|
||||||
|
|
||||||
server.on("/calibration", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
server.on("/calibration", HTTP_GET, [] (AsyncWebServerRequest *request) {
|
||||||
int params = request->params(); //showing all params
|
int params = request->params(); //showing all params
|
||||||
@ -2921,20 +2936,16 @@ Serial.print("try to connect to ssid:");Serial.print(ssid);Serial.print("; with
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleloadConst(request, json);
|
|
||||||
// auto&& data = json.as<JsonObject>();
|
|
||||||
|
|
||||||
});
|
});
|
||||||
server.addHandler(setconst);
|
server.addHandler(setconst);
|
||||||
server.addHandler(loadconst);
|
server.addHandler(loadconst);
|
||||||
|
|
||||||
Serial.println("before onevent");
|
Serial.println("before onevent");
|
||||||
ws.onEvent(onWsEvent); //add ws event
|
ws.onEvent(onWsEvent); //add ws event
|
||||||
wscal.onEvent(onWsEvent2); //add ws event
|
wscal.onEvent(onWsEvent2); //add ws event
|
||||||
server.addHandler(&ws);
|
server.addHandler(&ws);
|
||||||
server.addHandler(&wscal);
|
server.addHandler(&wscal);
|
||||||
Serial.println("after onevent");
|
Serial.println("after onevent");
|
||||||
server.onNotFound(notFound);
|
server.onNotFound(notFound);
|
||||||
Serial.println("onnotfound");
|
Serial.println("onnotfound");
|
||||||
|
|
||||||
@ -3495,6 +3506,7 @@ void loop() //loop from VSS RALLY V2
|
|||||||
//mem.writeFloat(800, constanta);
|
//mem.writeFloat(800, constanta);
|
||||||
|
|
||||||
setMemSpeedInConstanta(constanta, curTrip);
|
setMemSpeedInConstanta(constanta, curTrip);
|
||||||
|
setSpiffSpeedInConstanta(constanta, curTrip);
|
||||||
// int pointeradd = ((TRIPADDRESS+curTrip)*32);
|
// int pointeradd = ((TRIPADDRESS+curTrip)*32);
|
||||||
// mem.writeFloat(pointeradd, constanta);
|
// mem.writeFloat(pointeradd, constanta);
|
||||||
// Trip[curTrip].speed = constanta;
|
// Trip[curTrip].speed = constanta;
|
||||||
@ -3512,6 +3524,7 @@ void loop() //loop from VSS RALLY V2
|
|||||||
//mem.writeLong(768,valuesettime);
|
//mem.writeLong(768,valuesettime);
|
||||||
|
|
||||||
setMemStime(valuesettime, curTrip); ///added for esp32
|
setMemStime(valuesettime, curTrip); ///added for esp32
|
||||||
|
setSpiffStime(valuesettime, curTrip);
|
||||||
// int pointeradd = ((TRIPADDRESS+curTrip)*32+4);
|
// int pointeradd = ((TRIPADDRESS+curTrip)*32+4);
|
||||||
// mem.writeLong(pointeradd, valuesettime);
|
// mem.writeLong(pointeradd, valuesettime);
|
||||||
// Trip[curTrip].startHour = starttracthour;
|
// Trip[curTrip].startHour = starttracthour;
|
||||||
|
|||||||
@ -212,7 +212,7 @@ const char main_menu[] PROGMEM = R"rawliteral(
|
|||||||
<div class="card-header"><h1>MENU</h1></div>
|
<div class="card-header"><h1>MENU</h1></div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row align-self-end g-1">
|
<div class="row align-self-end g-1">
|
||||||
<div class="col text-center "><button onclick="location.href='/startrally1';" id="startrally" name="startrally" class="btn btn-primary btn-lg me-2 mb-2">RALLY</button></div>
|
<div class="col text-center "><button onclick="location.href='/startrally';" id="startrally" name="startrally" class="btn btn-primary btn-lg me-2 mb-2">RALLY</button></div>
|
||||||
<div class="col text-center"><button onclick="location.href='/calibration';" id="calibration" name="calibration" class="btn btn-primary me-2 mb-2">CALIBRATION</button></div>
|
<div class="col text-center"><button onclick="location.href='/calibration';" id="calibration" name="calibration" class="btn btn-primary me-2 mb-2">CALIBRATION</button></div>
|
||||||
<div class="col text-center"><button onclick="location.href='/constanta';" id="constanta" name="constanta" class="btn btn-primary me-2 mb-2">CONSTANTA</button></div>
|
<div class="col text-center"><button onclick="location.href='/constanta';" id="constanta" name="constanta" class="btn btn-primary me-2 mb-2">CONSTANTA</button></div>
|
||||||
<div class="col text-center"><button onclick="location.href='/settime';" id="constanta" name="constanta" class="btn btn-primary me-2 mb-2">Set TIME</button></div>
|
<div class="col text-center"><button onclick="location.href='/settime';" id="constanta" name="constanta" class="btn btn-primary me-2 mb-2">Set TIME</button></div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user