From 805b5961274a50a171d0facd791429f6b8e04d63 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Wed, 21 Mar 2018 02:30:12 -0400 Subject: Make turvey's disambiguator send out sync pulses before all sweep happens. --- src/survive_data.c | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'src/survive_data.c') diff --git a/src/survive_data.c b/src/survive_data.c index befcbe7..d8a26af 100644 --- a/src/survive_data.c +++ b/src/survive_data.c @@ -41,6 +41,7 @@ typedef struct typedef struct { double acode_offset; + int sent_out_ootx_bits; } lightcap2_global_data; typedef struct @@ -162,6 +163,7 @@ void handle_lightcap2_process_sweep_data(SurviveObject *so) { lightcap2_data *lcd = so->disambiguator_data; + while(remove_outliers(so)); // look at all of the sensors we found, and process the ones that were hit. @@ -218,6 +220,30 @@ void handle_lightcap2_process_sweep_data(SurviveObject *so) //printf("%4d\n", lcd->sweep.sweep_len[i]); int offset_from = lcd->sweep.sweep_time[i] - lcd->per_sweep.activeSweepStartTime + lcd->sweep.sweep_len[i] / 2; + + // first, send out the sync pulse data for the last round (for OOTX decoding + if( !lcd->global.sent_out_ootx_bits ) { + if (lcd->per_sweep.lh_max_pulse_length[0] != 0) + { + so->ctx->lightproc( so, -1, + handle_lightcap2_getAcodeFromSyncPulse(so, lcd->per_sweep.lh_max_pulse_length[0]), + lcd->per_sweep.lh_max_pulse_length[0], + lcd->per_sweep.lh_start_time[0], + 0, + 0); + } + if (lcd->per_sweep.lh_max_pulse_length[1] != 0) + { + so->ctx->lightproc( so, -2, + handle_lightcap2_getAcodeFromSyncPulse(so, lcd->per_sweep.lh_max_pulse_length[1]), + lcd->per_sweep.lh_max_pulse_length[1], + lcd->per_sweep.lh_start_time[1], + 0, + 1); + } + lcd->global.sent_out_ootx_bits = 1; + } + // if (offset_from < 380000 && offset_from > 70000) { //if (longest_pulse *10 / 8 < lcd->sweep.sweep_len[i]) @@ -329,32 +355,8 @@ void handle_lightcap2_sync(SurviveObject * so, LightcapElement * le ) //this should probably be fixed. Maybe some kind of timing based guess at which lighthouse. // looks like this is the first sync pulse. Cool! + lcd->global.sent_out_ootx_bits = 0; - // first, send out the sync pulse data for the last round (for OOTX decoding - { - if (lcd->per_sweep.lh_max_pulse_length[0] != 0) - { - so->ctx->lightproc( - so, - -1, - handle_lightcap2_getAcodeFromSyncPulse(so, lcd->per_sweep.lh_max_pulse_length[0]), - lcd->per_sweep.lh_max_pulse_length[0], - lcd->per_sweep.lh_start_time[0], - 0, - 0); - } - if (lcd->per_sweep.lh_max_pulse_length[1] != 0) - { - so->ctx->lightproc( - so, - -2, - handle_lightcap2_getAcodeFromSyncPulse(so, lcd->per_sweep.lh_max_pulse_length[1]), - lcd->per_sweep.lh_max_pulse_length[1], - lcd->per_sweep.lh_start_time[1], - 0, - 1); - } - } //fprintf(stderr, "************************************ Reinitializing Disambiguator!!!\n"); // initialize here. @@ -384,7 +386,6 @@ void handle_lightcap2_sync(SurviveObject * so, LightcapElement * le ) } */ } - // printf("%d %d\n", acode, lcd->per_sweep.activeLighthouse ); } -- cgit v1.2.3