I messed up the merge, so pushing it over to another repo so I don't lose it. Will tidy up and remove later

Dependencies:   BufferedSerial FatFileSystemCpp mbed

Files at this revision

API Documentation at this revision

Comitter:
AndyA
Date:
Tue Aug 17 16:38:39 2021 +0000
Parent:
50:d6c56eccf56a
Child:
52:adbbaadca0a9
Commit message:
Added orientation invert controls

Changed in this revision

LTCApp.h 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
settings.txt Show annotated file Show diff for this revision Revisions of this file
--- a/LTCApp.h	Tue Aug 17 15:59:20 2021 +0000
+++ b/LTCApp.h	Tue Aug 17 16:38:39 2021 +0000
@@ -48,7 +48,9 @@
     float UDPTxDelayMS;
     float SerialTxDelayFrame;
     float UDPTxDelayFrame;
-
+    bool InvertRoll;
+    bool InvertPitch;
+    bool InvertYaw;
 } UserSettings_t;
 
 #endif
--- a/main.cpp	Tue Aug 17 15:59:20 2021 +0000
+++ b/main.cpp	Tue Aug 17 16:38:39 2021 +0000
@@ -470,6 +470,15 @@
     } else
         NoDataWarn= true;
 
+    if (posPtr) {
+        if(UserSettings.InvertRoll)
+            posPtr->roll = 360-posPtr->roll;
+        if(UserSettings.InvertPitch)
+            posPtr->pitch = 360-posPtr->pitch;
+        if(UserSettings.InvertYaw)
+            posPtr->yaw = 360-posPtr->yaw;
+    }
+
 
 // FreeD could be output by two different methods so calculate first if needed rather than at Tx.
     if ((UserSettings.SerialOutMode==mode_FreeD) || UserSettings.FreeDPort)
@@ -482,9 +491,9 @@
 // Network is faster so send that first.
     if (UserSettings.FreeDPort || UserSettings.VipsUDPPort) {
         if (UserSettings.UDPTxDelayMS > 0) {
-            UDPOutputDelayTimer.attach_us(&UDP_Tx_Now,UserSettings.UDPTxDelayMS*1000);           
+            UDPOutputDelayTimer.attach_us(&UDP_Tx_Now,UserSettings.UDPTxDelayMS*1000);
         } else
-        UDP_Tx_Now();
+            UDP_Tx_Now();
     }
 
     switch (UserSettings.SerialOutMode) {
@@ -619,6 +628,10 @@
     UserSettings.UDPTxDelayMS = 0;
     UserSettings.SerialTxDelayFrame = 0;
     UserSettings.UDPTxDelayFrame = 0;
+    UserSettings.InvertRoll = false;
+    UserSettings.InvertPitch = false;
+    UserSettings.InvertYaw = false;
+
 
     LocalFileSystem localFS("local");
     FILE *LSFile= fopen("/local/settings.txt","r");
@@ -705,7 +718,18 @@
                     pc.printf("Got UDP delay value from file of %.2f frames\r\n",floatIn);
                     UserSettings.UDPTxDelayFrame = floatIn;
                 }
-
+                if (sscanf(lineBuffer,"InvertRoll=%d",&valueIn) == 1) {
+                    pc.printf("Got InvertRoll value from file of %d\r\n",valueIn);
+                    UserSettings.InvertRoll = (valueIn==1);
+                }
+                if (sscanf(lineBuffer,"InvertPitch=%d",&valueIn) == 1) {
+                    pc.printf("Got InvertPitch value from file of %d\r\n",valueIn);
+                    UserSettings.InvertPitch = (valueIn==1);
+                }
+                if (sscanf(lineBuffer,"InvertYaw=%d",&valueIn) == 1) {
+                    pc.printf("Got InvertYaw value from file of %d\r\n",valueIn);
+                    UserSettings.InvertYaw = (valueIn==1);
+                }
             }
         }
         fclose(LSFile);
--- a/settings.txt	Tue Aug 17 15:59:20 2021 +0000
+++ b/settings.txt	Tue Aug 17 16:38:39 2021 +0000
@@ -64,6 +64,7 @@
 #   Used Beacon List (mask value 0x1000)
 //ExtendedOutput=1
 
+
 # By default the FIZ output is sent as soon as possible after the sync pulse.
 # An optional delay can be added to this to either as time or as a proportion of a frame 
 # If both ms and frame delays are set then the frame one will be used.
@@ -79,6 +80,13 @@
 //DelayUDP=5.2
 #   Delay the serial by a fraction of a frame
 //DelayUDPFrame=0.3
+
+
+# Orientation control 
+#   These options allow the direction of the orientation channels to be inverted.
+//InvertRoll=1 
+//InvertPitch=1 
+//InvertYaw=1 
  
 [NOTES]
 - All settings are case sensitive.