Racelogic / Mbed 2 deprecated VIPS_LTC_RAW_IMU

Dependencies:   BufferedSerial FatFileSystemCpp mbed

Files at this revision

API Documentation at this revision

Comitter:
JamieB
Date:
Tue Aug 17 15:55:40 2021 +0000
Parent:
42:9653486372a6
Child:
49:df05784d9a5c
Commit message:
Auto Hyper-Smooth Function added with Settings Toggle

Changed in this revision

LTCApp.h Show annotated file Show diff for this revision Revisions of this file
VIPSSerialProtocol.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/LTCApp.h	Thu Aug 12 15:51:43 2021 +0000
+++ b/LTCApp.h	Tue Aug 17 15:55:40 2021 +0000
@@ -43,6 +43,9 @@
     bool FilterRoll;
     bool FilterPitch;
     bool FilterYaw;
+    bool AutoHyperSmooth;
 } UserSettings_t;
 
+extern UserSettings_t UserSettings;
+
 #endif
--- a/VIPSSerialProtocol.cpp	Thu Aug 12 15:51:43 2021 +0000
+++ b/VIPSSerialProtocol.cpp	Tue Aug 17 15:55:40 2021 +0000
@@ -340,13 +340,18 @@
         offset+=4;
     }
 
-    /*if ( ( ( lastPositions[nextPosition].pos.KFStatus & 0xE634) == 0x0400) && (!hyperSmoothEnabled)) {
-        EnableSmoothing(true);
-        pc.write("Auto HS On\r\n", 12);
-    } else if (hyperSmoothEnabled) {
-        EnableSmoothing(false);
-        pc.write("Auto HS Off\r\n", 13);
-    }*/ //Auto Hypersmooth, test in later commit after Ethernet Thread tested
+    if (UserSettings.AutoHyperSmooth) {
+        int testValue = (lastPositions[nextPosition].pos.KFStatus & 0xE634);
+
+        if ( ( ( testValue & 0x400) == 0x400) && (!hyperSmoothEnabled)) {
+            EnableSmoothing(true);
+            pc.write("Auto HS On\r\n", 12);
+        } else if ( ( ( testValue & 0x400) != 0x400) && (hyperSmoothEnabled)) {
+            EnableSmoothing(false);
+            pc.write("Auto HS Off\r\n", 13);
+        } //Auto Hypersmooth
+    }
+
 
     smoothOutputPacket(&(lastPositions[nextPosition].pos));
 
@@ -420,7 +425,7 @@
             YSmoothTotal = posPtr->Y * (SmoothBy - 1);
             ZSmoothTotal = posPtr->Height * (SmoothBy - 1);
             SmoothRunning = true;
-            pc.write("Seeded Filter\r\n",11);
+            //pc.write("Seeded Filter\r\n",11);
         }
         //smooth the KF_X and KF_Y positions
         XSmoothTotal += posPtr->X;
@@ -436,7 +441,7 @@
         ZSmoothTotal -= posPtr->Height;
     } else {
         SmoothRunning = false;
- //       pc.printf("filterX = %f\r\n",xFilter.lastValue());
+//       pc.printf("filterX = %f\r\n",xFilter.lastValue());
         posPtr->X = xFilter.lastValue();
         posPtr->Y = yFilter.lastValue();
         posPtr->Height = zFilter.lastValue();
--- a/main.cpp	Thu Aug 12 15:51:43 2021 +0000
+++ b/main.cpp	Tue Aug 17 15:55:40 2021 +0000
@@ -596,6 +596,7 @@
     UserSettings.FilterRoll = false;
     UserSettings.FilterPitch = false;
     UserSettings.FilterYaw = false;
+    UserSettings.AutoHyperSmooth = true;
 
     LocalFileSystem localFS("local");
     FILE *LSFile= fopen("/local/settings.txt","r");
@@ -662,6 +663,10 @@
                     pc.printf("Got FilterYaw value from file of %d\r\n",valueIn);
                     UserSettings.FilterYaw = (valueIn==1);
                 }
+                if (sscanf(lineBuffer,"AutoHyperSmooth=%d",&valueIn) == 1) {
+                    pc.printf("Got AutoHyperSmooth value from file of %d\r\n",valueIn);
+                    UserSettings.AutoHyperSmooth = valueIn;
+                }
             }
         }
         fclose(LSFile);