diff options
Diffstat (limited to 'src/survive_data.c')
-rw-r--r-- | src/survive_data.c | 102 |
1 files changed, 11 insertions, 91 deletions
diff --git a/src/survive_data.c b/src/survive_data.c index cb6340b..32c5a7d 100644 --- a/src/survive_data.c +++ b/src/survive_data.c @@ -7,82 +7,8 @@ #include <math.h> /* for sqrt */ //#define USE_TURVEYBIGUATOR -#define CHARLES_STATIBUATOR -#if defined(USE_CHARLESSTATIBGUATOR) - -/* - The operating principle of - -*/ - - - -typedef struct -{ - uint32_t next_expected_time; -} statbiguator_beamtracker; - -typedef struct -{ - statbiguator_beamtracker * beams; - - //NUM_LIGHTHOUSES first, then so->nr_locations - -} statbiguator_data; - -void handle_lightcap2( SurviveObject * so, LightcapElement * le ) -{ - SurviveContext * ctx = so->ctx; - - if (so->disambiguator_data == NULL) - { - fprintf(stderr, "Initializing Disambiguator Data\n"); - so->disambiguator_data = malloc(sizeof(lightcap2_data)); - memset(so->disambiguator_data, 0, sizeof(lightcap2_data)); - } - - - if( disambiguator_data -} - -/* - - ctx->lightproc( so, le->sensor_id, acode, offset_from, le->timestamp, le->length, whichlh ); - // 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); - } - } -*/ - - - - -// handle_lightcap2(so,le); - - -#elif defined( USE_TURVEYBIGUATOR ) +#ifdef USE_TURVEYBIGUATOR static const float tau_table[33] = { 0, 0, 0, 1.151140982, 1.425, 1.5712213707, 1.656266074, 1.7110275587, 1.7490784054, 1.7770229476, 1.798410005, 1.8153056661, 1.8289916275, 1.8403044103, 1.8498129961, 1.8579178211, @@ -543,11 +469,6 @@ void handle_lightcap2( SurviveObject * so, LightcapElement * le ) #endif - - - - - int32_t decode_acode(uint32_t length, int32_t main_divisor) { //+50 adds a small offset and seems to help always get it right. //Check the +50 in the future to see how well this works on a variety of hardware. @@ -591,8 +512,11 @@ void HandleOOTX( SurviveContext * ctx, SurviveObject * so ) void handle_lightcap( SurviveObject * so, LightcapElement * le ) { SurviveContext * ctx = so->ctx; +// static int32_t last; +// printf( "%d %lu %d %d\n", le->timestamp-last, le->timestamp, le->length, le->sensor_id ); +// last = le->timestamp; -#if defined (USE_TURVEYBIGUATOR) || defined(USE_CHARLESSTATIBGUATOR) +#ifdef USE_TURVEYBIGUATOR handle_lightcap2(so,le); return; @@ -684,10 +608,7 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le ) { so->last_sync_length[1] = 0; } - - //This is triggered on the first full sync pulse. so->last_sync_time[ssn] = le->timestamp; - //printf( "A: %d\n", so->last_sync_time[ssn] ); so->last_sync_length[ssn] = le->length; } else if( so->sync_set_number == -1 ) @@ -705,9 +626,7 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le ) } else { - //This is triggered on the slave base station's sync pulse. so->last_sync_time[ssn] = le->timestamp; - //printf( "B: %d\n", so->last_sync_time[ssn] ); so->last_sync_length[ssn] = le->length; } } @@ -719,7 +638,6 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le ) { if( so->last_sync_time[ssn] > le->timestamp ) { - //printf( "C: %d\n", so->last_sync_time[ssn] ); so->last_sync_time[ssn] = le->timestamp; so->last_sync_length[ssn] = le->length; } @@ -743,7 +661,6 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le ) //See if this is a valid actual pulse. else if( le->length < so->pulse_max_for_sweep && delta > so->pulse_in_clear_time && ssn >= 0 ) { - int32_t dl = so->last_sync_time[0]; int32_t tpco = so->last_sync_length[0]; @@ -757,6 +674,11 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le ) int32_t main_divisor = so->timebase_hz / 384000; //125 @ 48 MHz. int acode = decode_acode(so->last_sync_length[0],main_divisor); + int whichlh; + if( acode < 0 ) whichlh = 1; + else whichlh = (acode>>2); + int32_t dl = so->last_sync_time[whichlh]; + if( !so->did_handle_ootx ) HandleOOTX( ctx, so ); @@ -766,9 +688,6 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le ) //Make sure pulse is in valid window if( offset_from < so->timecenter_ticks*2-so->pulse_in_clear_time && offset_from > so->pulse_in_clear_time ) { - int whichlh; - if( acode < 0 ) whichlh = 1; - else whichlh = (acode>>2); ctx->lightproc( so, le->sensor_id, acode, offset_from, le->timestamp, le->length, whichlh ); } } @@ -781,3 +700,4 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le ) } + |