aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Berger <jdavidberger@gmail.com>2018-03-23 14:43:32 +0000
committerJustin Berger <jdavidberger@gmail.com>2018-03-23 14:43:32 +0000
commitd475a433ec40f335fa0bffdf774bac4c69d7fc10 (patch)
treeeb59da712588959d681944d3c83607f97003bf43
parent17e06b4822e60ccca865e77b45bf2b52a26852f2 (diff)
downloadlibsurvive-d475a433ec40f335fa0bffdf774bac4c69d7fc10.tar.gz
libsurvive-d475a433ec40f335fa0bffdf774bac4c69d7fc10.tar.bz2
Made calibration installation driveable from the command line; also turns on if there is no calibration
-rw-r--r--data_recorder.c4
-rw-r--r--src/survive.c25
-rwxr-xr-xsrc/survive_cal.c3
3 files changed, 28 insertions, 4 deletions
diff --git a/data_recorder.c b/data_recorder.c
index eef233d..427a953 100644
--- a/data_recorder.c
+++ b/data_recorder.c
@@ -17,10 +17,6 @@ int main(int argc, char **argv) {
}
survive_startup(ctx);
- if (survive_configi(ctx, "calibrate", SC_GET, 1)) {
- SV_INFO("Installing calibration");
- survive_cal_install(ctx);
- }
while (survive_poll(ctx) == 0) {
}
diff --git a/src/survive.c b/src/survive.c
index a8e7b94..3f3b844 100644
--- a/src/survive.c
+++ b/src/survive.c
@@ -269,6 +269,31 @@ int survive_startup(SurviveContext *ctx) {
ctx->state = SURVIVE_RUNNING;
+ int calibrateMandatory = survive_configi(ctx, "calibrate", SC_GET, 0);
+ int calibrateForbidden = survive_configi(ctx, "no-calibrate", SC_GET, 0);
+ if (calibrateMandatory && calibrateForbidden) {
+ SV_INFO("Contradictory settings --calibrate and --no-calibrate specified. Switching to normal behavior.");
+ calibrateMandatory = calibrateForbidden = 0;
+ }
+
+ if (!calibrateForbidden) {
+ bool isCalibrated = true;
+ for (int i = 0; i < ctx->activeLighthouses; i++) {
+ isCalibrated &= ctx->bsd[i].PositionSet;
+ }
+
+ if (!isCalibrated) {
+ SV_INFO("Uncalibrated configuration detected. Attaching calibration. Please don't move tracked objects for "
+ "the duration of calibration. Pass '--no-calibrate' to skip calibration");
+ }
+
+ bool doCalibrate = isCalibrated == false || calibrateMandatory;
+
+ if (doCalibrate) {
+ survive_cal_install(ctx);
+ }
+ }
+
return 0;
}
diff --git a/src/survive_cal.c b/src/survive_cal.c
index c94bd0d..218f5c1 100755
--- a/src/survive_cal.c
+++ b/src/survive_cal.c
@@ -116,6 +116,9 @@ int survive_cal_get_status( struct SurviveContext * ctx, char * description, int
void survive_cal_install( struct SurviveContext * ctx )
{
+ if (ctx->calptr)
+ return;
+
int i;
struct SurviveCalData * cd = ctx->calptr = calloc( 1, sizeof( struct SurviveCalData ) );