aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormwturvey <michael.w.turvey@intel.com>2017-03-23 09:47:38 -0700
committermwturvey <michael.w.turvey@intel.com>2017-03-23 09:47:38 -0700
commit280a6599fea76a7d2c16cfe0fcc5c8f37fde66de (patch)
tree7b0f7447a74c651c72cfc56e9ca71766b3aa5fbe
parent7701d14440d5d005b1ec3513ff8646e2f6b101ef (diff)
downloadlibsurvive-280a6599fea76a7d2c16cfe0fcc5c8f37fde66de.tar.gz
libsurvive-280a6599fea76a7d2c16cfe0fcc5c8f37fde66de.tar.bz2
More cleanup
-rw-r--r--calibrate.c2
-rw-r--r--data_recorder.c2
-rw-r--r--include/libsurvive/survive.h2
-rw-r--r--include/libsurvive/survive_types.h2
-rwxr-xr-xsrc/survive_cal.c2
-rw-r--r--src/survive_cal.h2
-rw-r--r--src/survive_data.c96
-rw-r--r--src/survive_process.c2
-rwxr-xr-xsrc/survive_vive.c2
9 files changed, 57 insertions, 55 deletions
diff --git a/calibrate.c b/calibrate.c
index 0f2d6ac..82869e0 100644
--- a/calibrate.c
+++ b/calibrate.c
@@ -51,7 +51,7 @@ int bufferpts[32*2*3][2];
char buffermts[32*128*3];
int buffertimeto[32*3][2];
-void my_light_process( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, int lh)
+void my_light_process( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, uint32_t lh)
{
// if( timeinsweep < 0 ) return;
survive_default_light_process( so, sensor_id, acode, timeinsweep, timecode, length, lh);
diff --git a/data_recorder.c b/data_recorder.c
index 6432f4f..04a219a 100644
--- a/data_recorder.c
+++ b/data_recorder.c
@@ -43,7 +43,7 @@ int bufferpts[32*2*3];
char buffermts[32*128*3];
int buffertimeto[32*3];
-void my_light_process( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, int lh)
+void my_light_process( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, uint32_t lh)
{
survive_default_light_process( so, sensor_id, acode, timeinsweep, timecode, length, lh);
diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h
index c3b6a03..1165e9d 100644
--- a/include/libsurvive/survive.h
+++ b/include/libsurvive/survive.h
@@ -130,7 +130,7 @@ void survive_cal_install( SurviveContext * ctx ); //XXX This will be removed if
//Call these from your callback if overridden.
//Accept higher-level data.
-void survive_default_light_process( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length , int lh);
+void survive_default_light_process( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length , uint32_t lh);
void survive_default_imu_process( SurviveObject * so, int mode, FLT * accelgyro, uint32_t timecode, int id );
void survive_default_angle_process( SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle );
diff --git a/include/libsurvive/survive_types.h b/include/libsurvive/survive_types.h
index 1600e11..def30b8 100644
--- a/include/libsurvive/survive_types.h
+++ b/include/libsurvive/survive_types.h
@@ -28,7 +28,7 @@ typedef struct BaseStationData BaseStationData;
typedef struct SurviveCalData SurviveCalData; //XXX Warning: This may be removed. Check at a later time for its defunctness.
typedef void (*text_feedback_func)( SurviveContext * ctx, const char * fault );
-typedef void (*light_process_func)( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length );
+typedef void (*light_process_func)( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, uint32_t lighthouse);
typedef void (*imu_process_func)( SurviveObject * so, int mask, FLT * accelgyro, uint32_t timecode, int id );
typedef void (*angle_process_func)( SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle );
diff --git a/src/survive_cal.c b/src/survive_cal.c
index 51d12dd..dfa2e85 100755
--- a/src/survive_cal.c
+++ b/src/survive_cal.c
@@ -190,7 +190,7 @@ void survive_cal_install( struct SurviveContext * ctx )
}
-void survive_cal_light( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, int lh)
+void survive_cal_light( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, uint32_t lh)
{
struct SurviveContext * ctx = so->ctx;
struct SurviveCalData * cd = ctx->calptr;
diff --git a/src/survive_cal.h b/src/survive_cal.h
index 8c488bd..9d7b3a9 100644
--- a/src/survive_cal.h
+++ b/src/survive_cal.h
@@ -29,7 +29,7 @@ int survive_cal_get_status( SurviveContext * ctx, char * description, int descri
//void survive_cal_teardown( struct SurviveContext * ctx );
//Called from survive_default_light_process
-void survive_cal_light( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length );
+void survive_cal_light( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, uint32_t lighthouse);
void survive_cal_angle( SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle );
#define MAX_SENSORS_TO_CAL 96
diff --git a/src/survive_data.c b/src/survive_data.c
index d92db36..00e66f0 100644
--- a/src/survive_data.c
+++ b/src/survive_data.c
@@ -12,11 +12,6 @@ typedef struct
} lightcaps_sweep_data;
typedef struct
{
- lightcaps_sweep_data sweep;
-} lightcap2_data;
-
-typedef struct
-{
int recent_sync_time;
int activeLighthouse;
int activeSweepStartTime;
@@ -28,7 +23,14 @@ typedef struct
} lightcap2_global_data;
-static lightcap2_global_data lcgd = { 0 };
+typedef struct
+{
+ lightcaps_sweep_data sweep;
+ lightcap2_global_data global;
+} lightcap2_data;
+
+
+//static lightcap2_global_data lcgd = { 0 };
int handle_lightcap2_getAcodeFromSyncPulse(int pulseLen)
{
@@ -65,13 +67,13 @@ void handle_lightcap2_process_sweep_data(SurviveObject *so)
{
if (lcd->sweep.sweep_len[i] != 0) // if the sensor was hit, process it
{
- int offset_from = lcd->sweep.sweep_time[i] - lcgd.activeSweepStartTime + lcd->sweep.sweep_len[i] / 2;
+ int offset_from = lcd->sweep.sweep_time[i] - lcd->global.activeSweepStartTime + lcd->sweep.sweep_len[i] / 2;
if (offset_from < 380000 && offset_from > 70000)
{
- if (longest_pulse *10 / 8 < -lcd->sweep.sweep_len[i])
+ if (longest_pulse *10 / 8 < lcd->sweep.sweep_len[i])
{
- so->ctx->lightproc(so, i, lcgd.activeAcode, offset_from, lcd->sweep.sweep_time[i], lcd->sweep.sweep_len[i], lcgd.activeLighthouse);
+ so->ctx->lightproc(so, i, lcd->global.activeAcode, offset_from, lcd->sweep.sweep_time[i], lcd->sweep.sweep_len[i], lcd->global.activeLighthouse);
}
}
}
@@ -94,54 +96,54 @@ void handle_lightcap2_sync(SurviveObject * so, LightcapElement * le )
// Process any sweep data we have
handle_lightcap2_process_sweep_data(so);
- int time_since_last_sync = (le->timestamp - lcgd.recent_sync_time);
+ int time_since_last_sync = (le->timestamp - lcd->global.recent_sync_time);
//fprintf(stderr, " %2d %8d %d\n", le->sensor_id, time_since_last_sync, le->length);
// need to store up sync pulses, so we can take the earliest starting time for all sensors.
if (time_since_last_sync < 2400)
{
- lcgd.recent_sync_time = le->timestamp;
+ lcd->global.recent_sync_time = le->timestamp;
// it's the same sync pulse;
so->sync_set_number = 1;
so->recent_sync_time = le->timestamp;
- lcgd.lh_pulse_len[lcgd.current_lh] = le->length;
- lcgd.lh_start_time[lcgd.current_lh] = le->timestamp;
+ lcd->global.lh_pulse_len[lcd->global.current_lh] = le->length;
+ lcd->global.lh_start_time[lcd->global.current_lh] = le->timestamp;
int acode = handle_lightcap2_getAcodeFromSyncPulse(le->length);
if (!(acode >> 2 & 1)) // if the skip bit is not set
{
- lcgd.activeLighthouse = lcgd.current_lh;
- lcgd.activeSweepStartTime = le->timestamp;
- lcgd.activeAcode = acode;
+ lcd->global.activeLighthouse = lcd->global.current_lh;
+ lcd->global.activeSweepStartTime = le->timestamp;
+ lcd->global.activeAcode = acode;
}
else
{
- lcgd.activeLighthouse = -1;
- lcgd.activeSweepStartTime = 0;
- lcgd.activeAcode = 0;
+ lcd->global.activeLighthouse = -1;
+ lcd->global.activeSweepStartTime = 0;
+ lcd->global.activeAcode = 0;
}
}
else if (time_since_last_sync < 24000)
{
- lcgd.recent_sync_time = le->timestamp;
+ lcd->global.recent_sync_time = le->timestamp;
// I do believe we are lighthouse B
- lcgd.current_lh = 1;
- lcgd.lh_pulse_len[lcgd.current_lh] = le->length;
- lcgd.lh_start_time[lcgd.current_lh] = le->timestamp;
+ lcd->global.current_lh = 1;
+ lcd->global.lh_pulse_len[lcd->global.current_lh] = le->length;
+ lcd->global.lh_start_time[lcd->global.current_lh] = le->timestamp;
int acode = handle_lightcap2_getAcodeFromSyncPulse(le->length);
if (!(acode >> 2 & 1)) // if the skip bit is not set
{
- if (lcgd.activeLighthouse != -1)
+ if (lcd->global.activeLighthouse != -1)
{
// hmm, it appears we got two non-skip pulses at the same time. That should never happen
fprintf(stderr, "WARNING: Two non-skip pulses received on the same cycle!\n");
}
- lcgd.activeLighthouse = 1;
- lcgd.activeSweepStartTime = le->timestamp;
- lcgd.activeAcode = acode;
+ lcd->global.activeLighthouse = 1;
+ lcd->global.activeSweepStartTime = le->timestamp;
+ lcd->global.activeAcode = acode;
}
}
@@ -151,49 +153,49 @@ void handle_lightcap2_sync(SurviveObject * so, LightcapElement * le )
// first, send out the sync pulse data for the last round (for OOTX decoding
{
- if (lcgd.lh_pulse_len[0] != 0)
+ if (lcd->global.lh_pulse_len[0] != 0)
{
so->ctx->lightproc(
so,
-1,
- handle_lightcap2_getAcodeFromSyncPulse(lcgd.lh_pulse_len[0]),
- lcgd.lh_pulse_len[0],
- lcgd.lh_start_time[0],
+ handle_lightcap2_getAcodeFromSyncPulse(lcd->global.lh_pulse_len[0]),
+ lcd->global.lh_pulse_len[0],
+ lcd->global.lh_start_time[0],
0,
0);
}
- if (lcgd.lh_pulse_len[1] != 0)
+ if (lcd->global.lh_pulse_len[1] != 0)
{
so->ctx->lightproc(
so,
-2,
- handle_lightcap2_getAcodeFromSyncPulse(lcgd.lh_pulse_len[1]),
- lcgd.lh_pulse_len[1],
- lcgd.lh_start_time[1],
+ handle_lightcap2_getAcodeFromSyncPulse(lcd->global.lh_pulse_len[1]),
+ lcd->global.lh_pulse_len[1],
+ lcd->global.lh_start_time[1],
0,
1);
}
}
// initialize here.
- memset(&lcgd, 0, sizeof(lcgd));
- lcgd.activeLighthouse = -1;
+ memset(&lcd->global, 0, sizeof(lcd->global));
+ lcd->global.activeLighthouse = -1;
- lcgd.recent_sync_time = le->timestamp;
+ lcd->global.recent_sync_time = le->timestamp;
// I do believe we are lighthouse A
- lcgd.current_lh = 0;
- lcgd.lh_pulse_len[lcgd.current_lh] = le->length;
- lcgd.lh_start_time[lcgd.current_lh] = le->timestamp;
+ lcd->global.current_lh = 0;
+ lcd->global.lh_pulse_len[lcd->global.current_lh] = le->length;
+ lcd->global.lh_start_time[lcd->global.current_lh] = le->timestamp;
int acode = handle_lightcap2_getAcodeFromSyncPulse(le->length);
if (!(acode >> 2 & 1)) // if the skip bit is not set
{
- lcgd.activeLighthouse = 0;
- lcgd.activeSweepStartTime = le->timestamp;
- lcgd.activeAcode = acode;
+ lcd->global.activeLighthouse = 0;
+ lcd->global.activeSweepStartTime = le->timestamp;
+ lcd->global.activeAcode = acode;
}
}
}
@@ -383,8 +385,8 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le )
int32_t delta1 = so->last_sync_time[0] - so->recent_sync_time;
int32_t delta2 = so->last_sync_time[1] - so->last_sync_time[0];
- ctx->lightproc( so, -1, acode_array[0], delta1, so->last_sync_time[0], so->last_sync_length[0] );
- ctx->lightproc( so, -2, acode_array[1], delta2, so->last_sync_time[1], so->last_sync_length[1] );
+ ctx->lightproc( so, -1, acode_array[0], delta1, so->last_sync_time[0], so->last_sync_length[0], 0 );
+ ctx->lightproc( so, -2, acode_array[1], delta2, so->last_sync_time[1], so->last_sync_length[1], 1 );
so->recent_sync_time = so->last_sync_time[1];
@@ -427,7 +429,7 @@ void handle_lightcap( SurviveObject * so, LightcapElement * le )
//Make sure pulse is in valid window
if( offset_from < 380000 && offset_from > 70000 )
{
- ctx->lightproc( so, le->sensor_id, acode, offset_from, le->timestamp, le->length );
+ ctx->lightproc( so, le->sensor_id, acode, offset_from, le->timestamp, le->length, so->sync_set_number );
}
}
else
diff --git a/src/survive_process.c b/src/survive_process.c
index 6735f10..463481a 100644
--- a/src/survive_process.c
+++ b/src/survive_process.c
@@ -6,7 +6,7 @@
//XXX TODO: Once data is avialble in the context, use the stuff here to handle converting from time codes to
//proper angles, then from there perform the rest of the solution.
-void survive_default_light_process( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, int lh)
+void survive_default_light_process( SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length, uint32_t lh)
{
SurviveContext * ctx = so->ctx;
int base_station = lh;
diff --git a/src/survive_vive.c b/src/survive_vive.c
index a9b295f..c04fc03 100755
--- a/src/survive_vive.c
+++ b/src/survive_vive.c
@@ -141,7 +141,7 @@ void survive_data_cb( SurviveUSBInterface * si );
//USB Subsystem
void survive_usb_close( SurviveContext * t );
-int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject *wm0, SurviveObject * wm1, SurviveObject * tr0 );
+int survive_usb_init( SurviveViveData * sv, SurviveObject * hmd, SurviveObject *wm0, SurviveObject * wm1, SurviveObject * tr0, struct SurviveObject * ww0 );
int survive_usb_poll( SurviveContext * ctx );
int survive_get_config( char ** config, SurviveViveData * ctx, int devno, int iface, int send_extra_magic );
int survive_vive_send_magic(struct SurviveContext * ctx, void * drv, int magic_code, void * data, int datalen );