mirror of
https://github.com/bcomsugi/VSS_Rally_V3.git
synced 2026-01-09 09:52:38 +07:00
Add ability to fill the missing constanta
This commit is contained in:
parent
15f1aba478
commit
2a9d55de91
@ -82,8 +82,10 @@
|
|||||||
id="%time%" name="%time%" class="form-control time" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)" value="%timeval%"></div>
|
id="%time%" name="%time%" class="form-control time" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)" value="%timeval%"></div>
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<input type="time" id="%stime%" name="%stime%" class="form-control stime" onchange="chback(this)" value="%stimeval%"></div>
|
<input type="time" id="%stime%" name="%stime%" class="form-control stime" onchange="chback(this)" value="%stimeval%"></div>
|
||||||
<div class="col-2">
|
<div class="col-1">
|
||||||
<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 class="col-1">
|
||||||
|
<button class="btn btn-primary fw-bold" id="fillBtn" onclick="setMissingVal(this)">Fill %A%</button></div>
|
||||||
</div>
|
</div>
|
||||||
<!-- )rawliteral"; -->
|
<!-- )rawliteral"; -->
|
||||||
|
|
||||||
@ -138,7 +140,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function setConstanta(e){
|
function setMissingVal(e){
|
||||||
e = e || window.event;
|
e = e || window.event;
|
||||||
var targ1 = e.target || e.srcElement || e;
|
var targ1 = e.target || e.srcElement || e;
|
||||||
if (targ1.nodeType == 3) targ1 = targ1.parentNode; // defeat Safari bug
|
if (targ1.nodeType == 3) targ1 = targ1.parentNode; // defeat Safari bug
|
||||||
@ -147,12 +149,27 @@
|
|||||||
const speed = targ.getElementsByClassName("speed")[0].value;
|
const speed = targ.getElementsByClassName("speed")[0].value;
|
||||||
const dist = targ.getElementsByClassName("dist")[0].value;
|
const dist = targ.getElementsByClassName("dist")[0].value;
|
||||||
const time = targ.getElementsByClassName("time")[0].value;
|
const time = targ.getElementsByClassName("time")[0].value;
|
||||||
if (!(dist<1000)){
|
if (speed==="" && time==="" && dist==="") {
|
||||||
alert ("Trip "+trip+"-> [Dist] cannot exceed 1000 Km");
|
alert ("Trip "+trip+"-> Cannot Empty Cells");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (speed===""){
|
var tempval=0;
|
||||||
alert ("Trip "+trip+"-> [Speed] is required");
|
if (dist && speed==="" && time) {
|
||||||
|
tempval=(dist/(time/60)).toFixed(3);
|
||||||
|
console.log ("empty speed:" + tempval);
|
||||||
|
targ.getElementsByClassName("speed")[0].value=tempval;
|
||||||
|
} else if (dist && speed && time===""){
|
||||||
|
tempval=Math.round((dist/speed)*60);
|
||||||
|
console.log ("empty time:" + tempval);
|
||||||
|
targ.getElementsByClassName("time")[0].value=tempval;
|
||||||
|
} else if (dist==="" && speed && time){
|
||||||
|
tempval=(speed*time/60).toFixed(2);
|
||||||
|
console.log ("empty dist:" + tempval);
|
||||||
|
targ.getElementsByClassName("dist")[0].value=tempval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(dist<1000)){
|
||||||
|
alert ("Trip "+trip+"-> [Dist] cannot exceed 1000 Km");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(speed<100)){
|
if (!(speed<100)){
|
||||||
@ -164,13 +181,8 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const stime = targ.getElementsByClassName("stime")[0].value;
|
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+'"}';
|
var full_data='{"trip":"'+trip+'", "speed":"'+speed+'", "dist":"'+dist+'", "time":"'+time+'", "stime":"'+stime+'"}';
|
||||||
console.log(full_data);
|
console.log(full_data);
|
||||||
// sendjson(full_data);
|
// sendjson(full_data);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -79,8 +79,10 @@ const char HTML_CONSTROW[] PROGMEM = R"rawliteral(
|
|||||||
id="%time%" name="%time%" class="form-control time" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)" value="%timeval%"></div>
|
id="%time%" name="%time%" class="form-control time" onkeypress="return onlyNumberKey(event,this)" onchange="chback(this)" value="%timeval%"></div>
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<input type="time" id="%stime%" name="%stime%" class="form-control stime" onchange="chback(this)" value="%stimeval%"></div>
|
<input type="time" id="%stime%" name="%stime%" class="form-control stime" onchange="chback(this)" value="%stimeval%"></div>
|
||||||
<div class="col-2">
|
<div class="col-1">
|
||||||
<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 class="col-1">
|
||||||
|
<button class="btn btn-primary fw-bold" id="fillBtn" onclick="setMissingVal(this)">Fill %A%</button></div>
|
||||||
</div>
|
</div>
|
||||||
)rawliteral";
|
)rawliteral";
|
||||||
|
|
||||||
@ -131,6 +133,55 @@ const char HTML_CONSTEND[] PROGMEM = R"rawliteral(
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
function setMissingVal(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 (speed==="" && time==="" && dist==="") {
|
||||||
|
alert ("Trip "+trip+"-> Cannot Empty Cells");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var tempval=0;
|
||||||
|
if (dist && speed==="" && time) {
|
||||||
|
tempval=(dist/(time/60)).toFixed(3);
|
||||||
|
console.log ("empty speed:" + tempval);
|
||||||
|
targ.getElementsByClassName("speed")[0].value=tempval;
|
||||||
|
} else if (dist && speed && time===""){
|
||||||
|
tempval=Math.round((dist/speed)*60);
|
||||||
|
console.log ("empty time:" + tempval);
|
||||||
|
targ.getElementsByClassName("time")[0].value=tempval;
|
||||||
|
} else if (dist==="" && speed && time){
|
||||||
|
tempval=(speed*time/60).toFixed(2);
|
||||||
|
console.log ("empty dist:" + tempval);
|
||||||
|
targ.getElementsByClassName("dist")[0].value=tempval;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(dist<1000)){
|
||||||
|
alert ("Trip "+trip+"-> [Dist] cannot exceed 1000 Km");
|
||||||
|
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;
|
||||||
|
|
||||||
|
var full_data='{"trip":"'+trip+'", "speed":"'+speed+'", "dist":"'+dist+'", "time":"'+time+'", "stime":"'+stime+'"}';
|
||||||
|
console.log(full_data);
|
||||||
|
// sendjson(full_data);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
function setConstanta(e){
|
function setConstanta(e){
|
||||||
e = e || window.event;
|
e = e || window.event;
|
||||||
var targ1 = e.target || e.srcElement || e;
|
var targ1 = e.target || e.srcElement || e;
|
||||||
|
|||||||
56
src/main.cpp
56
src/main.cpp
@ -899,19 +899,25 @@ void onWsEventSetTime(AsyncWebSocket * server, AsyncWebSocketClient * client, Aw
|
|||||||
if(type == WS_EVT_CONNECT){
|
if(type == WS_EVT_CONNECT){
|
||||||
globalClientSetTime++;
|
globalClientSetTime++;
|
||||||
gHasSetTimeClient=true;
|
gHasSetTimeClient=true;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.println("wssettime Websocket client connection received");
|
Serial.println("wssettime Websocket client connection received");
|
||||||
Serial.print("SetTime Client=");Serial.println(globalClientSetTime);
|
Serial.print("SetTime Client=");Serial.println(globalClientSetTime);
|
||||||
Serial.print("IPAdd client:");Serial.println(client->remoteIP());
|
Serial.print("IPAdd client:");Serial.println(client->remoteIP());
|
||||||
|
#endif
|
||||||
client->text(strSetTimeJson);
|
client->text(strSetTimeJson);
|
||||||
} else if(type == WS_EVT_DISCONNECT){
|
} else if(type == WS_EVT_DISCONNECT){
|
||||||
globalClientSetTime--;
|
globalClientSetTime--;
|
||||||
if (globalClientSetTime<=0) gHasSetTimeClient=false;
|
if (globalClientSetTime<=0) gHasSetTimeClient=false;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.println("wssettime Client disconnected");
|
Serial.println("wssettime Client disconnected");
|
||||||
Serial.print("SetTime Client=");Serial.println(globalClientSetTime);
|
Serial.print("SetTime Client=");Serial.println(globalClientSetTime);
|
||||||
Serial.print("IPAdd client:"); Serial.println(client->remoteIP());
|
Serial.print("IPAdd client:"); Serial.println(client->remoteIP());
|
||||||
|
#endif
|
||||||
} else if(type == WS_EVT_DATA){
|
} else if(type == WS_EVT_DATA){
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print("wssettime IPAdd client:"); Serial.println(client->remoteIP());
|
Serial.print("wssettime IPAdd client:"); Serial.println(client->remoteIP());
|
||||||
Serial.printf("[%u] get Text: %s\n", len, data);
|
Serial.printf("[%u] get Text: %s\n", len, data);
|
||||||
|
#endif
|
||||||
String message = String((char*)( data));
|
String message = String((char*)( data));
|
||||||
Serial.println(message);
|
Serial.println(message);
|
||||||
|
|
||||||
@ -1060,10 +1066,12 @@ void memretrieveTrip(int pointer, int startaddress)
|
|||||||
if (Trip[pointer].startHour >= 24) Trip[pointer].startHour = 23;
|
if (Trip[pointer].startHour >= 24) Trip[pointer].startHour = 23;
|
||||||
if (Trip[pointer].startMin >= 60) Trip[pointer].startMin = 59;
|
if (Trip[pointer].startMin >= 60) Trip[pointer].startMin = 59;
|
||||||
if (Trip[pointer].startSec >= 60) Trip[pointer].startSec = 59;
|
if (Trip[pointer].startSec >= 60) Trip[pointer].startSec = 59;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print(Trip[pointer].speed);Serial.print(";");
|
Serial.print(Trip[pointer].speed);Serial.print(";");
|
||||||
Serial.print(Trip[pointer].startHour);Serial.print(":");
|
Serial.print(Trip[pointer].startHour);Serial.print(":");
|
||||||
Serial.print(Trip[pointer].startMin);Serial.print(":");
|
Serial.print(Trip[pointer].startMin);Serial.print(":");
|
||||||
Serial.print(Trip[pointer].startSec);Serial.println("");
|
Serial.print(Trip[pointer].startSec);Serial.println("");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void constantatodigit()
|
void constantatodigit()
|
||||||
@ -1081,8 +1089,10 @@ void setSpiffSpeedInConstanta(float mConstanta, uint8_t setSpiffcurTrip){
|
|||||||
char filename[7] = "/tripZ";
|
char filename[7] = "/tripZ";
|
||||||
setSpiffcurTrip+=65;
|
setSpiffcurTrip+=65;
|
||||||
filename[5]=setSpiffcurTrip;
|
filename[5]=setSpiffcurTrip;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.println(filename);
|
Serial.println(filename);
|
||||||
Serial.println(mConstanta);
|
Serial.println(mConstanta);
|
||||||
|
#endif
|
||||||
String result = readFile(SPIFFS, filename);
|
String result = readFile(SPIFFS, filename);
|
||||||
result.reserve(128);
|
result.reserve(128);
|
||||||
DynamicJsonDocument doc(128);
|
DynamicJsonDocument doc(128);
|
||||||
@ -1119,8 +1129,10 @@ void setSpiffStime(unsigned long mvaluesettime, uint8_t setSpiffcurTrip){
|
|||||||
char filename[7] = "/tripZ";
|
char filename[7] = "/tripZ";
|
||||||
setSpiffcurTrip+=65;
|
setSpiffcurTrip+=65;
|
||||||
filename[5]=setSpiffcurTrip;
|
filename[5]=setSpiffcurTrip;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.println(filename);
|
Serial.println(filename);
|
||||||
Serial.println(mvaluesettime);
|
Serial.println(mvaluesettime);
|
||||||
|
#endif
|
||||||
String result = readFile(SPIFFS, filename);
|
String result = readFile(SPIFFS, filename);
|
||||||
result.reserve(128);
|
result.reserve(128);
|
||||||
DynamicJsonDocument doc(128);
|
DynamicJsonDocument doc(128);
|
||||||
@ -1130,7 +1142,9 @@ void setSpiffStime(unsigned long mvaluesettime, uint8_t setSpiffcurTrip){
|
|||||||
sHour = mvaluesettime/65536;
|
sHour = mvaluesettime/65536;
|
||||||
sMin = (mvaluesettime/256)-sHour*256;
|
sMin = (mvaluesettime/256)-sHour*256;
|
||||||
sprintf(msTime, "%02u:%02u", sHour, sMin);
|
sprintf(msTime, "%02u:%02u", sHour, sMin);
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print("dist:");Serial.print(doc["dist"].as<String>());Serial.println(";");
|
Serial.print("dist:");Serial.print(doc["dist"].as<String>());Serial.println(";");
|
||||||
|
#endif
|
||||||
if (doc["trip"].as<String>()=="null") doc["trip"]=String(char(setSpiffcurTrip));
|
if (doc["trip"].as<String>()=="null") doc["trip"]=String(char(setSpiffcurTrip));
|
||||||
if (doc["dist"].as<String>()=="null") doc["dist"]="";
|
if (doc["dist"].as<String>()=="null") doc["dist"]="";
|
||||||
if (doc["speed"].as<String>()=="null") doc["speed"]="";
|
if (doc["speed"].as<String>()=="null") doc["speed"]="";
|
||||||
@ -1139,7 +1153,9 @@ void setSpiffStime(unsigned long mvaluesettime, uint8_t setSpiffcurTrip){
|
|||||||
result="";
|
result="";
|
||||||
serializeJson(doc,result);
|
serializeJson(doc,result);
|
||||||
writeFile(SPIFFS, filename, result.c_str());
|
writeFile(SPIFFS, filename, result.c_str());
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print("Write sTime:");Serial.println(result);
|
Serial.print("Write sTime:");Serial.println(result);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
void setMemStime(unsigned long mvaluesettime, uint8_t setmemssTimecurTrip){
|
void setMemStime(unsigned long mvaluesettime, uint8_t setmemssTimecurTrip){
|
||||||
int pointeradd = ((TRIPADDRESS+setmemssTimecurTrip)*32+4);
|
int pointeradd = ((TRIPADDRESS+setmemssTimecurTrip)*32+4);
|
||||||
@ -1147,9 +1163,12 @@ void setMemStime(unsigned long mvaluesettime, uint8_t setmemssTimecurTrip){
|
|||||||
Trip[setmemssTimecurTrip].startHour = (mvaluesettime/65536); //starttracthour;
|
Trip[setmemssTimecurTrip].startHour = (mvaluesettime/65536); //starttracthour;
|
||||||
Trip[setmemssTimecurTrip].startMin = (mvaluesettime/256)-Trip[setmemssTimecurTrip].startHour*256; // starttractmin;
|
Trip[setmemssTimecurTrip].startMin = (mvaluesettime/256)-Trip[setmemssTimecurTrip].startHour*256; // starttractmin;
|
||||||
Trip[setmemssTimecurTrip].startSec = mvaluesettime-((Trip[setmemssTimecurTrip].startHour*256 + Trip[curTrip].startMin)*256);//starttractsec;
|
Trip[setmemssTimecurTrip].startSec = mvaluesettime-((Trip[setmemssTimecurTrip].startHour*256 + Trip[curTrip].startMin)*256);//starttractsec;
|
||||||
|
#ifdef DEBUG
|
||||||
|
Serial.print("memstime: ");
|
||||||
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);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
unsigned long getMemStime(uint8_t getmemsTimecurTrip){
|
unsigned long getMemStime(uint8_t getmemsTimecurTrip){
|
||||||
int pointeradd = ((TRIPADDRESS+getmemsTimecurTrip)*32+4);
|
int pointeradd = ((TRIPADDRESS+getmemsTimecurTrip)*32+4);
|
||||||
@ -1397,7 +1416,9 @@ String runningtimeforESP32test1(byte x1,byte y1)
|
|||||||
runningTIME[8]='\0';
|
runningTIME[8]='\0';
|
||||||
// Serial.print("t.hour:");Serial.println(t.hour);
|
// Serial.print("t.hour:");Serial.println(t.hour);
|
||||||
// Serial.print("runningtimeforesp:");Serial.println(runningTIME);
|
// Serial.print("runningtimeforesp:");Serial.println(runningTIME);
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print("runningtimeforesp:");Serial.println(runningTIME);
|
Serial.print("runningtimeforesp:");Serial.println(runningTIME);
|
||||||
|
#endif
|
||||||
return String(runningTIME);
|
return String(runningTIME);
|
||||||
}
|
}
|
||||||
void settimeMenu()
|
void settimeMenu()
|
||||||
@ -1445,7 +1466,9 @@ void calibrationMenu()
|
|||||||
//lcd.blink();
|
//lcd.blink();
|
||||||
//blinkON=true;
|
//blinkON=true;
|
||||||
PREVMENU = MENU;
|
PREVMENU = MENU;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print(Calibrationstr);Serial.println("end");
|
Serial.print(Calibrationstr);Serial.println("end");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void constantaMenu()
|
void constantaMenu()
|
||||||
@ -2187,7 +2210,9 @@ void calculationRally() //calculation only ESP32
|
|||||||
sprintf(gcur_distance1_str, "%04.01f", distance1);
|
sprintf(gcur_distance1_str, "%04.01f", distance1);
|
||||||
}
|
}
|
||||||
// Serial.print(distance2);Serial.print(";");Serial.println(count2);
|
// Serial.print(distance2);Serial.print(";");Serial.println(count2);
|
||||||
Serial.print(gcurTime);Serial.print(";");Serial.println(t.hour);
|
#ifdef DEBUG
|
||||||
|
Serial.print(gcurTime);Serial.print(";");Serial.println(t.hour);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (distance2<0) {
|
if (distance2<0) {
|
||||||
sprintf(gcur_distance2_str, "%02.02f", distance2);
|
sprintf(gcur_distance2_str, "%02.02f", distance2);
|
||||||
@ -2283,7 +2308,9 @@ Serial.print(gcurTime);Serial.print(";");Serial.println(t.hour);
|
|||||||
if (hours2<10) sprintf(gcur_time2_str, " %s%01d:%02d:%02d", (negatifsign?"-":" "), hours2, mins2, secs2);
|
if (hours2<10) sprintf(gcur_time2_str, " %s%01d:%02d:%02d", (negatifsign?"-":" "), hours2, mins2, secs2);
|
||||||
else sprintf(gcur_time2_str, "%s%02d:%02d:%02d", (negatifsign?"-":" "), hours2, mins2, secs2);
|
else sprintf(gcur_time2_str, "%s%02d:%02d:%02d", (negatifsign?"-":" "), hours2, mins2, secs2);
|
||||||
}
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print(gcurTime);Serial.print(t.min);Serial.println(t.sec);
|
Serial.print(gcurTime);Serial.print(t.min);Serial.println(t.sec);
|
||||||
|
#endif
|
||||||
// Serial.println("ENDCRal");
|
// Serial.println("ENDCRal");
|
||||||
} ///// calculation only for esp32
|
} ///// calculation only for esp32
|
||||||
|
|
||||||
@ -2477,7 +2504,9 @@ void convertJsonTripToTripStruct(uint8_t iTrip, const char* strJson){ //this als
|
|||||||
char mspeed[7];
|
char mspeed[7];
|
||||||
|
|
||||||
dtostrf(Trip[iTrip].speed, 6, 4, mspeed);
|
dtostrf(Trip[iTrip].speed, 6, 4, mspeed);
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print(String(char(iTrip)));Serial.print(mspeed);Serial.print(" VS ");Serial.println(doc["speed"].as<String>());
|
Serial.print(String(char(iTrip)));Serial.print(mspeed);Serial.print(" VS ");Serial.println(doc["speed"].as<String>());
|
||||||
|
#endif
|
||||||
// if (Trip[iTrip].speed!=doc["speed"])
|
// if (Trip[iTrip].speed!=doc["speed"])
|
||||||
Serial.println("hohoho");
|
Serial.println("hohoho");
|
||||||
// if (strJson=="")
|
// if (strJson=="")
|
||||||
@ -2505,7 +2534,9 @@ void fillTripArray(){ //run by setup()
|
|||||||
tempTrip[5]=i+65;
|
tempTrip[5]=i+65;
|
||||||
// Serial.println(tempTrip);
|
// Serial.println(tempTrip);
|
||||||
tempReadFile = readFile(SPIFFS, tempTrip);
|
tempReadFile = readFile(SPIFFS, tempTrip);
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print(tempTrip); Serial.print(";");Serial.println(tempReadFile);
|
Serial.print(tempTrip); Serial.print(";");Serial.println(tempReadFile);
|
||||||
|
#endif
|
||||||
convertJsonTripToTripStruct(i, tempReadFile.c_str());
|
convertJsonTripToTripStruct(i, tempReadFile.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2607,7 +2638,9 @@ void handleloadConst(AsyncWebServerRequest *request, JsonVariant &json) {
|
|||||||
request->send(200, "text/plain", tripload); // handle data and respond
|
request->send(200, "text/plain", tripload); // handle data and respond
|
||||||
// request->send(tripload);
|
// request->send(tripload);
|
||||||
// isloadingConst=false;
|
// isloadingConst=false;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print("constLoadTime=");Serial.println(millis()-howLongInMillis);
|
Serial.print("constLoadTime=");Serial.println(millis()-howLongInMillis);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
char* unConstChar(const char* s) {
|
char* unConstChar(const char* s) {
|
||||||
@ -2642,7 +2675,9 @@ void getTripFromSPIFF(uint8_t charcurTrip, char *pDist, char *pSpeed, char *pTi
|
|||||||
tempsTime.reserve(10);
|
tempsTime.reserve(10);
|
||||||
|
|
||||||
tempTrip=readFile(SPIFFS, filename);
|
tempTrip=readFile(SPIFFS, filename);
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print(tempTrip.length()); Serial.print(";");Serial.println(tempTrip);
|
Serial.print(tempTrip.length()); Serial.print(";");Serial.println(tempTrip);
|
||||||
|
#endif
|
||||||
deserializeJson(doc, tempTrip);
|
deserializeJson(doc, tempTrip);
|
||||||
|
|
||||||
float speedinconstanta = getMemSpeedInConstanta(charcurTrip-65);
|
float speedinconstanta = getMemSpeedInConstanta(charcurTrip-65);
|
||||||
@ -2692,12 +2727,14 @@ void handleConstantaHTML(AsyncWebServerRequest *request) {
|
|||||||
// Serial.print((uint32_t) xsTime);Serial.print(";");Serial.print((uint32_t) *xsTime);Serial.print(";");Serial.println((uint32_t) &xsTime);
|
// Serial.print((uint32_t) xsTime);Serial.print(";");Serial.print((uint32_t) *xsTime);Serial.print(";");Serial.println((uint32_t) &xsTime);
|
||||||
// getTripFromSPIFF(i, xDist, &xSpeed, &xTime, &xsTime);
|
// getTripFromSPIFF(i, xDist, &xSpeed, &xTime, &xsTime);
|
||||||
getTripFromSPIFF(i, xDist, xSpeed, xTime, xsTime);
|
getTripFromSPIFF(i, xDist, xSpeed, xTime, xsTime);
|
||||||
|
#ifdef DEBUG
|
||||||
// Serial.print((uint32_t) xsTime);Serial.print(";");Serial.print((uint32_t) *xsTime);Serial.print(";");Serial.println((uint32_t) &xsTime);
|
// Serial.print((uint32_t) xsTime);Serial.print(";");Serial.print((uint32_t) *xsTime);Serial.print(";");Serial.println((uint32_t) &xsTime);
|
||||||
Serial.print(String(char(i)));Serial.print(";");
|
Serial.print(String(char(i)));Serial.print(";");
|
||||||
Serial.print(xDist);Serial.print(";");
|
Serial.print(xDist);Serial.print(";");
|
||||||
Serial.print(xSpeed);Serial.print(";");
|
Serial.print(xSpeed);Serial.print(";");
|
||||||
Serial.print(xTime);Serial.print(";");
|
Serial.print(xTime);Serial.print(";");
|
||||||
Serial.print(xsTime);Serial.println(";");
|
Serial.print(xsTime);Serial.println(";");
|
||||||
|
#endif
|
||||||
PAGEROW.replace("%distval%", xDist);
|
PAGEROW.replace("%distval%", xDist);
|
||||||
PAGEROW.replace("%speedval%", xSpeed);
|
PAGEROW.replace("%speedval%", xSpeed);
|
||||||
PAGEROW.replace("%timeval%", xTime);
|
PAGEROW.replace("%timeval%", xTime);
|
||||||
@ -2710,9 +2747,11 @@ void handleConstantaHTML(AsyncWebServerRequest *request) {
|
|||||||
request->send(200, "text/html", PAGE);
|
request->send(200, "text/html", PAGE);
|
||||||
// request->send(SPIFFS, "/constanta.html", String(), false, procConst); // read from spiif straight away
|
// request->send(SPIFFS, "/constanta.html", String(), false, procConst); // read from spiif straight away
|
||||||
// isloadingConst=false;
|
// isloadingConst=false;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.println(millis());
|
Serial.println(millis());
|
||||||
Serial.print("PAGE Size:");Serial.println(pageZise);
|
Serial.print("PAGE Size:");Serial.println(pageZise);
|
||||||
Serial.print("Actual Size:");Serial.println(PAGE.length());
|
Serial.print("Actual Size:");Serial.println(PAGE.length());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2720,7 +2759,7 @@ void handlesetConst(AsyncWebServerRequest *request, JsonVariant &json){
|
|||||||
isloadingConst=true;
|
isloadingConst=true;
|
||||||
// JsonObject& jsonObj = json.as<JsonObject>();
|
// JsonObject& jsonObj = json.as<JsonObject>();
|
||||||
if (not json.is<JsonObject>()) {
|
if (not json.is<JsonObject>()) {
|
||||||
Serial.println("Not JSONG object");
|
Serial.println("Not JSON object");
|
||||||
request->send(400, "text/plain", "Not an object");
|
request->send(400, "text/plain", "Not an object");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2754,16 +2793,19 @@ void handlesetConst(AsyncWebServerRequest *request, JsonVariant &json){
|
|||||||
canSave = false;
|
canSave = false;
|
||||||
}
|
}
|
||||||
constvaluesettime = getValueSetTime(stime);
|
constvaluesettime = getValueSetTime(stime);
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.println(dist);
|
Serial.println(dist);
|
||||||
|
#endif
|
||||||
if (constvaluesettime==-1){
|
if (constvaluesettime==-1){
|
||||||
canSave = false;
|
canSave = false;
|
||||||
}
|
}
|
||||||
if (!(speed<100)) canSave = false;
|
if (!(speed<100)) canSave = false;
|
||||||
if (!(dist<1000)) canSave = false;
|
if (!(dist<1000)) canSave = false;
|
||||||
if (!(time<1000)) canSave = false;
|
if (!(time<1000)) canSave = false;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.print(constconstanta,3); Serial.print(";"); Serial.println(constCurTrip);
|
Serial.print(constconstanta,3); Serial.print(";"); Serial.println(constCurTrip);
|
||||||
Serial.print(constvaluesettime); Serial.print(";"); Serial.println(speed);
|
Serial.print(constvaluesettime); Serial.print(";"); Serial.println(speed);
|
||||||
|
#endif
|
||||||
AsyncResponseStream *response = request->beginResponseStream("application/json");
|
AsyncResponseStream *response = request->beginResponseStream("application/json");
|
||||||
if (canSave){
|
if (canSave){
|
||||||
// String filename = String("/trip"+trip);
|
// String filename = String("/trip"+trip);
|
||||||
@ -2840,7 +2882,9 @@ Trip[9].startSec = 58;
|
|||||||
//Serial.println(Trip[0].distance);
|
//Serial.println(Trip[0].distance);
|
||||||
//Serial.println(Trip[0].subTime);
|
//Serial.println(Trip[0].subTime);
|
||||||
// uint32_t freqhz=400000;
|
// uint32_t freqhz=400000;
|
||||||
|
#ifdef DEBUG
|
||||||
Serial.println("begin wire");
|
Serial.println("begin wire");
|
||||||
|
#endif
|
||||||
Wire.begin(I2C_SDA, I2C_SCL, FREQHZ); //for lolin32lite sda=15; scl=13 //Dont move up or down
|
Wire.begin(I2C_SDA, I2C_SCL, FREQHZ); //for lolin32lite sda=15; scl=13 //Dont move up or down
|
||||||
|
|
||||||
//**************************LCD Setup********************************
|
//**************************LCD Setup********************************
|
||||||
@ -2858,8 +2902,6 @@ Trip[9].startSec = 58;
|
|||||||
|
|
||||||
// lcd2.print("hello rally20");
|
// lcd2.print("hello rally20");
|
||||||
|
|
||||||
|
|
||||||
Serial.println("Start calib");
|
|
||||||
//***************************END LCD Setup********************************
|
//***************************END LCD Setup********************************
|
||||||
strCalibJson.reserve(512);
|
strCalibJson.reserve(512);
|
||||||
strRallyJson.reserve(512);
|
strRallyJson.reserve(512);
|
||||||
@ -2986,7 +3028,7 @@ Serial.println("calibration and constanta");
|
|||||||
#endif
|
#endif
|
||||||
// wifiManager.setAPCallback(configModeCallback);
|
// wifiManager.setAPCallback(configModeCallback);
|
||||||
// wifiManager.autoConnect(soft_ap_ssid);
|
// wifiManager.autoConnect(soft_ap_ssid);
|
||||||
Serial.println("before filltriparray");
|
|
||||||
fillTripArray();
|
fillTripArray();
|
||||||
|
|
||||||
//WiFi.mode(WIFI_STA);
|
//WiFi.mode(WIFI_STA);
|
||||||
@ -3274,7 +3316,7 @@ Serial.println("calibration and constanta");
|
|||||||
});
|
});
|
||||||
|
|
||||||
AsyncCallbackJsonWebHandler* loadconst = new AsyncCallbackJsonWebHandler("/rest/loadconst", [](AsyncWebServerRequest *request, JsonVariant &json) {
|
AsyncCallbackJsonWebHandler* loadconst = new AsyncCallbackJsonWebHandler("/rest/loadconst", [](AsyncWebServerRequest *request, JsonVariant &json) {
|
||||||
Serial.print("loadconst");Serial.println(millis());
|
// Serial.print("loadconst");Serial.println(millis());
|
||||||
while(!semaphoreS){
|
while(!semaphoreS){
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user