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
Diff: main.cpp
- Revision:
- 85:0cc5931bb9ef
- Parent:
- 79:1910ae03cb2e
- Parent:
- 81:aee60dcce61b
diff -r 1910ae03cb2e -r 0cc5931bb9ef main.cpp --- a/main.cpp Thu Dec 15 05:53:28 2022 +0000 +++ b/main.cpp Thu Dec 15 06:05:30 2022 +0000 @@ -1,4 +1,4 @@ -#define APP_VERSION 0.302 +#define APP_VERSION 0.32 /* Settings file options @@ -189,6 +189,9 @@ bool TXFrame = true; +// int pos_lower = 0; +// int pos_upper = 0; +// int pos_value = 0; void filterOff(void) { @@ -674,8 +677,13 @@ size_t len = sizeof(chunk); char *line = new char[len]; pc.printf("Opened File %s\r\n", filename); +<<<<<<< working copy vector<int> *encoder; vector<float> *absolute; +======= + vector<unsigned int> *encoder; + vector<unsigned int> *absolute; +>>>>>>> merge rev int focus_datapoints; int iris_datapoints; int zoom_datapoints; @@ -693,6 +701,7 @@ strncpy(line + len_used, chunk, len - len_used); len_used += chunk_used; if(line[len_used - 1] == '\n') { +<<<<<<< working copy pc.printf("Retrieved line of length %u: ", len_used); pc.printf("%s\n", line); if (sscanf(line,"FOCUS:%d", &focus_datapoints) == 1) { @@ -729,9 +738,61 @@ } else { printf("\tNot Valid matching line\n"); } +======= + // pc.printf("Retrieved line of length %u: ", len_used); + // pc.printf("%s", line); + // Thread::wait(10); + if (sscanf(line,"FOCUS:%d", &focus_datapoints) == 1) { + encoder = &UserSettings.focus_encoder_map; + absolute = &UserSettings.focus_absolute_map; + UserSettings.absolute_focus = true; + // pc.printf(" - Set Focus\r\n"); + // Thread::wait(10); + } else if (sscanf(line,"IRIS:%d", &iris_datapoints) == 1) { + encoder = &UserSettings.iris_encoder_map; + absolute = &UserSettings.iris_absolute_map; + UserSettings.absolute_iris = true; + // pc.printf(" - Set Iris\r\n"); + // Thread::wait(10); + } else if (sscanf(line,"ZOOM:%d", &zoom_datapoints) == 1) { + encoder = &UserSettings.zoom_encoder_map; + absolute = &UserSettings.zoom_absolute_map; + UserSettings.absolute_zoom = true; + // pc.printf(" - Set Zoom\r\n"); + // Thread::wait(10); + } else if (strchr(line,',') != NULL) { + // pc.printf("\tProbably some data in this line\n"); + unsigned int encoder_val; + unsigned int absolute_val; + if (sscanf(line, "%d,%d", &encoder_val, &absolute_val) == 2) { + encoder->push_back(encoder_val); + absolute->push_back(absolute_val); + // pc.printf(" - ADDED Datapoint\r\n"); + // Thread::wait(10); + } + } // else { pc.printf(" - Not Valid matching line\r\n"); } +>>>>>>> merge rev line[0] = '\0'; } } + pc.printf("FOCUS: "); + for(int i = 0; i < UserSettings.focus_encoder_map.size(); i++) { + pc.printf("(%d, ", UserSettings.focus_encoder_map[i]); + pc.printf("%d)", UserSettings.focus_absolute_map[i]); + } + pc.printf("\r\n"); + pc.printf("IRIS: "); + for(int i = 0; i < UserSettings.iris_encoder_map.size(); i++) { + pc.printf("(%d, ", UserSettings.iris_encoder_map[i]); + pc.printf("%d)", UserSettings.iris_absolute_map[i]); + } + pc.printf("\r\n"); + pc.printf("ZOOM: "); + for(int i = 0; i < UserSettings.zoom_encoder_map.size(); i++) { + pc.printf("(%d, ", UserSettings.zoom_encoder_map[i]); + pc.printf("%d)", UserSettings.zoom_absolute_map[i]); + } + pc.printf("\r\n"); fclose(LensFile); free(line); } else { @@ -782,6 +843,10 @@ UserSettings.iris_offset = 0; UserSettings.zoom_scale = 1; UserSettings.zoom_offset= 0; + UserSettings.low_zoom_precision = false; //TODO: Get zoom range from lens file, if over 327mm, set this flag (and set top bit in zoom output) + UserSettings.absolute_focus = false; + UserSettings.absolute_iris = false; + UserSettings.absolute_zoom = false; // LocalFileSystem localFS("local"); FILE *LSFile= fopen("/local/settings.txt","r"); @@ -1245,7 +1310,7 @@ int main() { pc.baud(115200); - pc.printf("\r\n\r\nStartup - v%.2f\r\n", APP_VERSION); //Change via Line 1 + pc.printf("\r\n\r\nStartup - v%.3f\r\n", APP_VERSION); //Change via Line 1 setRED(); readSettingsFile(); @@ -1405,6 +1470,11 @@ } VIPS.sendQueued(); // should ideally be called on 100Hz PPS edge but we don't have that in this code... + // if (pos_value) { + // pc.printf("Z: %d - (%d, %d)\r\n", pos_value, pos_lower, pos_upper); + // pos_value = 0; + // } + if (logButtonLastState != logButton) { logButtonLastState = logButton; if (logButtonLastState) { // pressed