Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed MODSERIAL FATFileSystem
Diff: ConfigFileIO/ConfigFileIO.cpp
- Revision:
- 52:f207567d3ea4
- Parent:
- 43:891baf306e0a
- Child:
- 54:d4990fb68404
--- a/ConfigFileIO/ConfigFileIO.cpp Mon Jun 04 15:20:21 2018 +0000
+++ b/ConfigFileIO/ConfigFileIO.cpp Wed Jun 06 19:18:47 2018 +0000
@@ -355,24 +355,66 @@
char value[BUFSIZ];
if (cfg.getValue("setMinDeg", &value[0] , sizeof(value))) {
- servo().setMinDeg(atof(value));
+ rudder().setMinDeg(atof(value));
count++;
}
if (cfg.getValue("setMaxDeg", &value[0] ,sizeof(value))) {
- servo().setMaxDeg(atof(value));
+ rudder().setMaxDeg(atof(value));
count++;
}
if (cfg.getValue("setCenterPMW", &value[0] , sizeof(value))) {
- servo().setCenterPWM(atof(value));
+ rudder().setCenterPWM(atof(value));
count++;
}
if (cfg.getValue("setMinPWM", &value[0], sizeof(value))) {
- servo().setMinPWM(atof(value));
+ rudder().setMinPWM(atof(value));
count++;
}
if (cfg.getValue("setMaxPWM", &value[0], sizeof(value))) {
- servo().setMaxPWM(atof(value));
+ rudder().setMaxPWM(atof(value));
count++;
}
return count;
+}
+
+
+
+
+// new from other file 06/06/2018
+//write rudder (servo driver) file rudder.txt
+void ConfigFileIO::saveRudderData(float setMinDeg, float setMaxDeg, float setCenterPWM, float setMinPWM, float setMaxPWM) {
+ ConfigFile rudder_txt;
+
+ char header[128];
+ sprintf(header,"# rudder (servo) inner loop (heading outer loop uses this)");
+
+ char string_min_deg[128];
+ sprintf(string_min_deg, "%f", setMinDeg);
+ rudder_txt.setValue("setMinDeg", string_min_deg);
+
+ char string_max_deg[128];
+ sprintf(string_max_deg, "%f", setMaxDeg);
+ rudder_txt.setValue("setMaxDeg", string_max_deg);
+
+ char string_ctr_pwm[128];
+ sprintf(string_ctr_pwm, "%f", setCenterPWM);
+ rudder_txt.setValue("setCenterPWM", string_ctr_pwm);
+
+ char string_min_pwm[128];
+ sprintf(string_min_pwm, "%f", setMinPWM);
+ rudder_txt.setValue("setMinPWM", string_min_pwm);
+
+ char string_max_pwm[128];
+ sprintf(string_max_pwm, "%f", setMaxPWM);
+ rudder_txt.setValue("setMaxPWM", string_max_pwm);
+
+ //SAVE THE DATA!
+ pc().printf("Saving RUDDER DATA!");
+
+ if (!rudder_txt.write("/local/rudder.txt")) {
+ pc().printf("\n\rERROR: (SAVE)Failure to write rudder.txt file.");
+ }
+ else {
+ pc().printf("\n\rFile rudder.txt successful written.\n\r");
+ }
}
\ No newline at end of file