From d335f37563575415cf7e2e947195080657405cf6 Mon Sep 17 00:00:00 2001 From: Bluedragon Date: Fri, 14 Apr 2023 02:22:13 +0700 Subject: [PATCH] Speed1 always pos, trip has default value --- data/calibration.html | 109 ++++++++++ data/constanta.html | 5 +- data/tripA | 1 + data/tripB | 1 + data/tripC | 1 + data/tripD | 1 + data/tripE | 1 + data/tripF | 1 + data/tripG | 1 + data/tripH | 1 + data/tripI | 1 + data/tripJ | 1 + data/tripK | 1 + data/tripL | 1 + data/tripM | 1 + data/tripN | 1 + data/tripO | 1 + data/tripP | 1 + src/constanta special/contantasp.html | 275 ++++++++++++++++++++++++++ src/index.h | 4 +- src/main.cpp | 64 +++--- 21 files changed, 446 insertions(+), 27 deletions(-) create mode 100644 data/calibration.html create mode 100644 src/constanta special/contantasp.html diff --git a/data/calibration.html b/data/calibration.html new file mode 100644 index 0000000..9f87cc4 --- /dev/null +++ b/data/calibration.html @@ -0,0 +1,109 @@ + + Rally TerraTrip v1 Calibration + + + + + + + + + +
+
+
12345
+

TRIP A

+

Time: 00:00:00

+

123.4Km/h

+
+
+ +
+

Set Distance (9 Km)->

+

+ + + +

+
+
+

Set Calibration Manually (110000)->

+

+ + + +

+
+
+

+ +

+
+

+ 00.000Km

+
+
+
+

1 meter=123.456

+

123456 Calibration Value

+
+ + +
+ + + \ No newline at end of file diff --git a/data/constanta.html b/data/constanta.html index 189092b..717d6f8 100644 --- a/data/constanta.html +++ b/data/constanta.html @@ -1,3 +1,4 @@ +const char HTML_CONSTHEADER[] PROGMEM = R"rawliteral( Rally TerraTrip v1 Constanta @@ -224,4 +225,6 @@ const char HTML_CONSTEND[] PROGMEM = R"rawliteral( xhr.send(data); } - \ No newline at end of file + + +)rawliteral"; \ No newline at end of file diff --git a/data/tripA b/data/tripA index e69de29..089b207 100644 --- a/data/tripA +++ b/data/tripA @@ -0,0 +1 @@ +{"trip":"A", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripB b/data/tripB index e69de29..236ec41 100644 --- a/data/tripB +++ b/data/tripB @@ -0,0 +1 @@ +{"trip":"B", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripC b/data/tripC index e69de29..e2216e0 100644 --- a/data/tripC +++ b/data/tripC @@ -0,0 +1 @@ +{"trip":"C", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripD b/data/tripD index e69de29..370d54b 100644 --- a/data/tripD +++ b/data/tripD @@ -0,0 +1 @@ +{"trip":"D", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripE b/data/tripE index e69de29..947e97a 100644 --- a/data/tripE +++ b/data/tripE @@ -0,0 +1 @@ +{"trip":"E", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripF b/data/tripF index e69de29..20fb0a6 100644 --- a/data/tripF +++ b/data/tripF @@ -0,0 +1 @@ +{"trip":"F", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripG b/data/tripG index e69de29..9544888 100644 --- a/data/tripG +++ b/data/tripG @@ -0,0 +1 @@ +{"trip":"G", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripH b/data/tripH index e69de29..f753a66 100644 --- a/data/tripH +++ b/data/tripH @@ -0,0 +1 @@ +{"trip":"H", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripI b/data/tripI index e69de29..19ab0a3 100644 --- a/data/tripI +++ b/data/tripI @@ -0,0 +1 @@ +{"trip":"I", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripJ b/data/tripJ index e69de29..5d2271a 100644 --- a/data/tripJ +++ b/data/tripJ @@ -0,0 +1 @@ +{"trip":"J", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripK b/data/tripK index e69de29..e168548 100644 --- a/data/tripK +++ b/data/tripK @@ -0,0 +1 @@ +{"trip":"K", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripL b/data/tripL index e69de29..023d190 100644 --- a/data/tripL +++ b/data/tripL @@ -0,0 +1 @@ +{"trip":"L", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripM b/data/tripM index e69de29..f4afdaf 100644 --- a/data/tripM +++ b/data/tripM @@ -0,0 +1 @@ +{"trip":"M", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripN b/data/tripN index e69de29..dbd6767 100644 --- a/data/tripN +++ b/data/tripN @@ -0,0 +1 @@ +{"trip":"N", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripO b/data/tripO index e69de29..13437c4 100644 --- a/data/tripO +++ b/data/tripO @@ -0,0 +1 @@ +{"trip":"O", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/data/tripP b/data/tripP index e69de29..7365431 100644 --- a/data/tripP +++ b/data/tripP @@ -0,0 +1 @@ +{"trip":"P", "speed":"", "time":"", "dist":"", "stime":""} \ No newline at end of file diff --git a/src/constanta special/contantasp.html b/src/constanta special/contantasp.html new file mode 100644 index 0000000..4afbd81 --- /dev/null +++ b/src/constanta special/contantasp.html @@ -0,0 +1,275 @@ + + + Rally TerraTrip v1 Constanta + + + + + + + + + +
+ + +
+
+
+
=
+
+
X
+
+
+
+
+ + + + + + +
+
+
+
+
+
+
+
+
+
+
+
+
+ + + + + + + +
+ + + + + \ No newline at end of file diff --git a/src/index.h b/src/index.h index 34fa3d8..9479106 100644 --- a/src/index.h +++ b/src/index.h @@ -195,7 +195,7 @@ const char HTML_startrally[] PROGMEM = R"rawliteral(

- +

@@ -222,7 +222,7 @@ const char HTML_startrally[] PROGMEM = R"rawliteral(
- +
diff --git a/src/main.cpp b/src/main.cpp index fb7269a..0d86e49 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -340,7 +340,8 @@ String readFile(fs::FS &fs, const char * path){ if (!file.size()){ Serial.println("File is empty"); file.close(); - return String(); + // return String(); + return ""; } Serial.print("- read from file:"); String fileContent; @@ -1049,6 +1050,7 @@ void memretrieveTrip(int pointer, int startaddress) //Serial.print (pointer); Serial.println(startaddress); int pointeradd; Trip[pointer].speed = mem.readFloat(startaddress); + pointeradd = (startaddress + 6); Trip[pointer].startHour = mem.read(pointeradd); pointeradd = (startaddress + 5); @@ -1154,14 +1156,14 @@ unsigned long getMemStime(uint8_t getmemsTimecurTrip){ return mem.readLong(pointeradd); } -void blink() { -// #ifndef ATMEGA328 - ledstate = !ledstate; -// #else -// PORTB ^= B00100000; -// #endif - VSSCount++; -} +// void interruptblink() { +// // #ifndef ATMEGA328 +// ledstate = !ledstate; +// // #else +// // PORTB ^= B00100000; +// // #endif +// VSSCount++; +// } @@ -1494,21 +1496,26 @@ void constantaMenu() } void updateCount() { + unsigned long tempvsscount; + tempvsscount = VSSCount; if (dircount1 == FORWARD) { - count1 = count1 + (VSSCount-time1); + count1 = count1 + (tempvsscount-time1); } else if (dircount1 == BACKWARD) { - count1 = count1 - (VSSCount-time1); + count1 = count1 - (tempvsscount-time1); } if (dircount2 == FORWARD) { - count2 = count2 + (VSSCount-time2); + count2 = count2 + (tempvsscount-time2); } else if (dircount2 == BACKWARD) { - count2 = count2 - (VSSCount-time2); + count2 = count2 - (tempvsscount-time2); } - time1 = VSSCount; - time2 = VSSCount; + time1 = tempvsscount; + time2 = tempvsscount; + // time1 = VSSCount; + // time2 = VSSCount; + } void saveCount() { @@ -2142,7 +2149,8 @@ void calculationRally() //calculation only ESP32 } startspeed = millis(); //startspeed is only one no startspeed2 // startdistance = distance1; - if(speed1 > 200 || speed1 < -200) speed1 = 0; + if(speed1 > 300 || speed1 < -300) speed1 = 0; + if(speed1 < 0) speed1 = speed1*-1; if ((millis()-startsavemillis)>0) { @@ -2457,7 +2465,7 @@ void set_cursor_pos(int new_pos) } -void IRAM_ATTR isr() { //esp32 only +void IRAM_ATTR interruptblink() { //esp32 only VSSCount++; ledstate=!ledstate; } @@ -2471,6 +2479,8 @@ void convertJsonTripToTripStruct(uint8_t iTrip, const char* strJson){ //this als dtostrf(Trip[iTrip].speed, 6, 4, mspeed); Serial.print(String(char(iTrip)));Serial.print(mspeed);Serial.print(" VS ");Serial.println(doc["speed"].as()); // if (Trip[iTrip].speed!=doc["speed"]) + Serial.println("hohoho"); + // if (strJson=="") if (strcmp(mspeed, doc["speed"].as()) != 0) { Serial.print(String(char(iTrip)));Serial.println(" speed is different"); @@ -2482,6 +2492,7 @@ void convertJsonTripToTripStruct(uint8_t iTrip, const char* strJson){ //this als // Serial.print(String(iTrip));Serial.print(Trip[iTrip].subTime);Serial.print(" VS ");Serial.println(doc["time"].as()); // Trip[iTrip].subTime = doc["time"]; // } + Trip[iTrip].distance = doc["dist"]; Trip[iTrip].subTime = doc["time"]; } @@ -2492,8 +2503,9 @@ void fillTripArray(){ //run by setup() tempReadFile.reserve(100); for (uint8_t i=0; i