aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2018-03-21 02:30:12 -0400
committercnlohr <lohr85@gmail.com>2018-03-21 02:30:12 -0400
commit805b5961274a50a171d0facd791429f6b8e04d63 (patch)
tree3fe9313efd4941c1ec118dd397bfdaad324f20e7
parenta6d5a843a2cdd87d63e9a3d2a199cf02a6f20833 (diff)
downloadlibsurvive-805b5961274a50a171d0facd791429f6b8e04d63.tar.gz
libsurvive-805b5961274a50a171d0facd791429f6b8e04d63.tar.bz2
Make turvey's disambiguator send out sync pulses before all sweep happens.
-rw-r--r--src/survive_data.c53
1 files changed, 27 insertions, 26 deletions
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 );
}