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
System/config_functions.cpp
- Committer:
- mkelly10
- Date:
- 2017-10-20
- Revision:
- 9:d5fcdcb3c89d
- Child:
- 10:085ab7328054
File content as of revision 9:d5fcdcb3c89d:
#include "config_functions.h"
#include "StaticDefs.hpp"
int load_BCE_config()
{
ConfigFile cfg;
int count = 0;
if (!cfg.read("/local/bce.txt")){
error("File Read Error");
}
char value[BUFSIZ];
if (cfg.getValue("PGain", &value[0] , sizeof(value))) {
bce().setControllerP(atof(value));
count++;
}
if (cfg.getValue("IGain", &value[0] ,sizeof(value))) {
bce().setControllerI(atof(value));
count++;
}
if (cfg.getValue("DGain", &value[0] , sizeof(value))) {
bce().setControllerD(atof(value));
count++;
}
if (cfg.getValue("zeroCounts", &value[0],sizeof(value))) {
bce().setZeroCounts(atoi(value));
count++;
}
if (cfg.getValue("PistonTravelLimit", &value[0], sizeof(value))) {
bce().setTravelLimit(atof(value));
count++;
}
if (cfg.getValue("slope", &value[0], sizeof(value))) {
bce().setPotSlope(atof(value));
count++;
}
if (cfg.getValue("filterWn", &value[0], sizeof(value))) {
bce().setFilterFrequency(atof(value));
count++;
}
if (cfg.getValue("deadband", &value[0], sizeof(value))) {
bce().setDeadband(atof(value));
count++;
}
return count;
}
int load_BATT_config()
{
ConfigFile cfg;
int count = 0;
if (!cfg.read("/local/batt.txt")){
error("File Read Error");
}
char value[BUFSIZ];
if (cfg.getValue("PGain", &value[0] , sizeof(value))) {
batt().setControllerP(atof(value));
count++;
}
if (cfg.getValue("IGain", &value[0] ,sizeof(value))) {
batt().setControllerI(atof(value));
count++;
}
if (cfg.getValue("DGain", &value[0] , sizeof(value))) {
batt().setControllerD(atof(value));
count++;
}
if (cfg.getValue("zeroCounts", &value[0],sizeof(value))) {
batt().setZeroCounts(atoi(value));
count++;
}
if (cfg.getValue("PistonTravelLimit", &value[0], sizeof(value))) {
batt().setTravelLimit(atof(value));
count++;
}
if (cfg.getValue("slope", &value[0], sizeof(value))) {
batt().setPotSlope(atof(value));
count++;
}
if (cfg.getValue("filterWn", &value[0], sizeof(value))) {
batt().setFilterFrequency(atof(value));
count++;
}
if (cfg.getValue("deadband", &value[0], sizeof(value))) {
batt().setDeadband(atof(value));
count++;
}
return count;
}