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:
JamieB
Date:
Thu Aug 25 16:16:31 2022 +0000
Parent:
77:6453dcc202d5
Child:
79:1910ae03cb2e
Child:
80:0b7f1b85b626
Commit message:
Online Compiler messed up, committing in this state to not lose changes

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
--- a/LTCApp.h	Fri May 13 10:48:13 2022 +0000
+++ b/LTCApp.h	Thu Aug 25 16:16:31 2022 +0000
@@ -14,6 +14,7 @@
 #include "frameclock.h"
 #include "FreeD.h"
 #include <stdint.h>
+#include <vector>
 
 extern volatile uint32_t VBOXTicks;
 extern volatile bool ppsActive;
@@ -69,6 +70,12 @@
     float iris_offset;
     float zoom_scale;
     float zoom_offset;
+    vector<int> focus_encoder_map;
+    vector<float> focus_absolute_map;
+    vector<int> iris_encoder_map;
+    vector<float> iris_absolute_map;
+    vector<int> zoom_encoder_map;
+    vector<float> zoom_absolute_map;
 } UserSettings_t;
 
 extern UserSettings_t UserSettings;
--- a/main.cpp	Fri May 13 10:48:13 2022 +0000
+++ b/main.cpp	Thu Aug 25 16:16:31 2022 +0000
@@ -1,4 +1,4 @@
-#define APP_VERSION 0.30
+#define APP_VERSION 0.302
 
 /*
 Settings file options
@@ -648,6 +648,41 @@
     NVIC_SystemReset();
 }
 
+void readLensFile(char* filename)
+{
+    FILE *LensFile = fopen(filename,"r");
+    if (LensFile) {
+        char chunk[64];
+        size_t len = sizeof(chunk);
+        ssize_t read;
+        char *line = new char[len];
+        pc.printf("Opened File %s\r\n", filename);
+
+        while(fgets(chunk, sizeof(chunk), LensFile) != NULL) {
+            size_t len_used = strlen(line);
+            size_t chunk_used = strlen(chunk);
+
+            if(len - len_used < chunk_used) {
+                pc.printf("Line Buffer Exceeded - Failed to read file");
+                free(line);
+                return;
+           }
+
+            strncpy(line + len_used, chunk, len - len_used);
+            len_used += chunk_used;
+            if(line[len_used - 1] == '\n') {
+                printf("Retrieved line of length %u: ", len_used);
+                printf("%s\n", line);
+                line[0] = '\0';
+            }
+        }
+        fclose(LensFile);
+        free(line);
+    }
+    else {
+        pc.printf("Unable to open File %s\r\n", filename);
+    }
+}
 
 void readSettingsFile()
 {
@@ -695,12 +730,15 @@
 
 //    LocalFileSystem localFS("local");
     FILE *LSFile= fopen("/local/settings.txt","r");
-    char lineBuffer[64];
+    char lineBuffer[128];
     int valueIn;
     float floatIn;
+    char lensfile[128] = "/local/";//7 characters for filepath, minus 12 chars of settings string, hence 128 shouldnt cause buffer overflow
+    /*MAXIMUM FILENAME LENGTH IS 8 Characters*/
+
     if (LSFile) {
         while (!feof(LSFile) && !UserSettings.bypassBaud) {
-            if (fgets(lineBuffer, 64, LSFile)) {
+            if (fgets(lineBuffer, 128, LSFile)) {
                 if (sscanf(lineBuffer,"RadioConfigPassthrough=%d",&valueIn) == 1) {
                     pc.printf("Switching to RADIO/USB bypass mode at %d baud\r\n",valueIn);
                     UserSettings.bypassBaud = valueIn;
@@ -864,15 +902,20 @@
                     pc.printf("Got Zoom offset of %f \r\n",floatIn);
                     UserSettings.zoom_offset = floatIn;
                 }
+                if (sscanf(lineBuffer,"LensProfile=%s", &lensfile[7]) == 1) {
+                    pc.printf("Found filename of %s \r\n", lensfile);
+                }
 
             }
         }
         fclose(LSFile);
+        readLensFile(lensfile);
     } else {
         pc.printf("No Settings File Found \r\n");
     }
 }
 
+
 void settingsNetUpdate(void const* netInterface)
 {
     //FILE *LSFile;