From 35e08aaa24bd01e6ace453f89ddb73a6bb0508b0 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Tue, 14 Feb 2017 01:00:33 -0500 Subject: Still not working, but getting closer to dynamic OOTX decoding. --- calibrate.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 calibrate.c (limited to 'calibrate.c') diff --git a/calibrate.c b/calibrate.c new file mode 100644 index 0000000..4db2ed0 --- /dev/null +++ b/calibrate.c @@ -0,0 +1,124 @@ +//Data recorder mod with GUI showing light positions. + +#include +#include +#include +#include +#include +#include +#include +#include + +struct SurviveContext * ctx; + +void HandleKey( int keycode, int bDown ) +{ + if( !bDown ) return; + + if( keycode == 'O' || keycode == 'o' ) + { + survive_usb_send_magic(ctx,1); + } + if( keycode == 'F' || keycode == 'f' ) + { + survive_usb_send_magic(ctx,0); + } +} + +void HandleButton( int x, int y, int button, int bDown ) +{ +} + +void HandleMotion( int x, int y, int mask ) +{ +} + +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 ) +{ + survive_default_light_process( so, sensor_id, acode, timeinsweep, timecode, length ); +} + +void my_imu_process( struct SurviveObject * so, int16_t * accelgyro, uint32_t timecode, int id ) +{ + survive_default_imu_process( so, accelgyro, timecode, id ); + +return; + //if( so->codename[0] == 'H' ) + if( 1 ) + { + printf( "I %s %d %d %d %d %d %d %d %d\n", so->codename, timecode, accelgyro[0], accelgyro[1], accelgyro[2], accelgyro[3], accelgyro[4], accelgyro[5], id ); + } +} + + + + +void * GuiThread( void * v ) +{ + short screenx, screeny; + while(1) + { + CNFGHandleInput(); + CNFGClearFrame(); + CNFGColor( 0xFFFFFF ); + CNFGGetDimensions( &screenx, &screeny ); + + int i; + for( i = 0; i < 32*3; i++ ) + { + if( buffertimeto[i] < 50 ) + { + uint32_t color = i * 3231349; + uint8_t r = color & 0xff; + uint8_t g = (color>>8) & 0xff; + uint8_t b = (color>>16) & 0xff; + r = (r * (5-buffertimeto[i])) / 5 ; + g = (g * (5-buffertimeto[i])) / 5 ; + b = (b * (5-buffertimeto[i])) / 5 ; + CNFGColor( (b<<16) | (g<<8) | r ); + CNFGTackRectangle( bufferpts[i*2+0], bufferpts[i*2+1], bufferpts[i*2+0] + 5, bufferpts[i*2+1] + 5 ); + CNFGPenX = bufferpts[i*2+0]; CNFGPenY = bufferpts[i*2+1]; + CNFGDrawText( buffermts, 2 ); + buffertimeto[i]++; + } + } + + + CNFGSwapBuffers(); + OGUSleep( 10000 ); + } +} + + + +int main() +{ + ctx = survive_init( ); + + survive_install_light_fn( ctx, my_light_process ); + survive_install_imu_fn( ctx, my_imu_process ); + + survive_cal_install( ctx ); + + CNFGBGColor = 0x000000; + CNFGDialogColor = 0x444444; + CNFGSetup( "Survive GUI Debug", 640, 480 ); + OGCreateThread( GuiThread, 0 ); + + + if( !ctx ) + { + fprintf( stderr, "Fatal. Could not start\n" ); + return 1; + } + + while(survive_poll(ctx) == 0) + { + //Do stuff. + } +} + -- cgit v1.2.3 From 2e5d0355da2376f27dcbe0cc6d04b737145ac853 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Thu, 16 Feb 2017 15:47:46 -0500 Subject: update with more integration stuff. --- calibrate.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'calibrate.c') diff --git a/calibrate.c b/calibrate.c index 4db2ed0..ce50b67 100644 --- a/calibrate.c +++ b/calibrate.c @@ -40,6 +40,36 @@ int buffertimeto[32*3]; void my_light_process( struct SurviveObject * so, int sensor_id, int acode, int timeinsweep, uint32_t timecode, uint32_t length ) { survive_default_light_process( so, sensor_id, acode, timeinsweep, timecode, length ); + + if( acode == -1 ) return; +//return; + int jumpoffset = sensor_id; + if( strcmp( so->codename, "WM0" ) == 0 ) jumpoffset += 32; + else if( strcmp( so->codename, "WM1" ) == 0 ) jumpoffset += 64; + + + if( acode == 0 || acode == 2 ) //data = 0 + { + bufferpts[jumpoffset*2+0] = (timeinsweep-100000)/500; + buffertimeto[jumpoffset] = 0; + } + if( acode == 1 || acode == 3 ) //data = 1 + { + bufferpts[jumpoffset*2+1] = (timeinsweep-100000)/500; + buffertimeto[jumpoffset] = 0; + } + + + if( acode == 4 || acode == 6 ) //data = 0 + { + bufferpts[jumpoffset*2+0] = (timeinsweep-100000)/500; + buffertimeto[jumpoffset] = 0; + } + if( acode == 5 || acode == 7 ) //data = 1 + { + bufferpts[jumpoffset*2+1] = (timeinsweep-100000)/500; + buffertimeto[jumpoffset] = 0; + } } void my_imu_process( struct SurviveObject * so, int16_t * accelgyro, uint32_t timecode, int id ) -- cgit v1.2.3 From 32fbccbd7d90f1e456d1e477eab2128aaf88df93 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Thu, 16 Feb 2017 17:16:31 -0500 Subject: Move to having an angle callback. --- calibrate.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'calibrate.c') diff --git a/calibrate.c b/calibrate.c index ce50b67..6bd3e77 100644 --- a/calibrate.c +++ b/calibrate.c @@ -85,6 +85,10 @@ return; } +void my_angle_process( struct SurviveObject * so, int sensor_id, int acode, uint32_t timecode, FLT length, FLT angle ) +{ + survive_default_angle_process( so, sensor_id, acode, timecode, length, angle ); +} void * GuiThread( void * v ) @@ -125,12 +129,14 @@ void * GuiThread( void * v ) + int main() { ctx = survive_init( ); survive_install_light_fn( ctx, my_light_process ); survive_install_imu_fn( ctx, my_imu_process ); + survive_install_angle_fn( ctx, my_angle_process ); survive_cal_install( ctx ); -- cgit v1.2.3 From 9bba1f9e7888f512a587f76179b9dd8f389c7ae8 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Thu, 16 Feb 2017 18:09:19 -0500 Subject: Start collecting data. Getting closer to having a full cal stack. --- calibrate.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'calibrate.c') diff --git a/calibrate.c b/calibrate.c index 6bd3e77..2db544a 100644 --- a/calibrate.c +++ b/calibrate.c @@ -121,6 +121,13 @@ void * GuiThread( void * v ) } } + CNFGColor( 0xffffff ); + char caldesc[256]; + survive_cal_get_status( ctx, caldesc, sizeof( caldesc ) ); + CNFGPenX = 3; + CNFGPenY = 3; + CNFGDrawText( caldesc, 2 ); + CNFGSwapBuffers(); OGUSleep( 10000 ); -- cgit v1.2.3 From bd89d46cb01f7069166e85f017f169e07acc7094 Mon Sep 17 00:00:00 2001 From: cnlohr Date: Thu, 16 Feb 2017 18:28:54 -0500 Subject: closing in on finding common cal points. --- calibrate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'calibrate.c') diff --git a/calibrate.c b/calibrate.c index 2db544a..60f4316 100644 --- a/calibrate.c +++ b/calibrate.c @@ -126,7 +126,7 @@ void * GuiThread( void * v ) survive_cal_get_status( ctx, caldesc, sizeof( caldesc ) ); CNFGPenX = 3; CNFGPenY = 3; - CNFGDrawText( caldesc, 2 ); + CNFGDrawText( caldesc, 4 ); CNFGSwapBuffers(); -- cgit v1.2.3