aboutsummaryrefslogtreecommitdiff
path: root/calibrate.c
diff options
context:
space:
mode:
Diffstat (limited to 'calibrate.c')
-rw-r--r--calibrate.c80
1 files changed, 55 insertions, 25 deletions
diff --git a/calibrate.c b/calibrate.c
index 82da7a7..667089a 100644
--- a/calibrate.c
+++ b/calibrate.c
@@ -13,6 +13,7 @@
#include "src/survive_config.h"
struct SurviveContext * ctx;
+int quit = 0;
void HandleKey( int keycode, int bDown )
{
@@ -26,6 +27,10 @@ void HandleKey( int keycode, int bDown )
{
survive_send_magic(ctx,0,0,0);
}
+ if( keycode == 'Q' || keycode == 'q' )
+ {
+ quit = 1;
+ }
}
void HandleButton( int x, int y, int button, int bDown )
@@ -36,9 +41,12 @@ void HandleMotion( int x, int y, int mask )
{
}
-int bufferpts[32*2*3];
+//int bufferpts[32*2*3][2];
+int bufferpts[32*2*3][2];
+
+
char buffermts[32*128*3];
-int buffertimeto[32*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 )
{
@@ -54,25 +62,25 @@ void my_light_process( struct SurviveObject * so, int sensor_id, int acode, int
if( acode == 0 || acode == 2 ) //data = 0
{
- bufferpts[jumpoffset*2+0] = (timeinsweep-100000)/500;
- buffertimeto[jumpoffset] = 0;
+ bufferpts[jumpoffset*2+0][0] = (timeinsweep-100000)/500;
+ buffertimeto[jumpoffset][0] = 0;
}
if( acode == 1 || acode == 3 ) //data = 1
{
- bufferpts[jumpoffset*2+1] = (timeinsweep-100000)/500;
- buffertimeto[jumpoffset] = 0;
+ bufferpts[jumpoffset*2+1][0] = (timeinsweep-100000)/500;
+ buffertimeto[jumpoffset][0] = 0;
}
if( acode == 4 || acode == 6 ) //data = 0
{
- bufferpts[jumpoffset*2+0] = (timeinsweep-100000)/500;
- buffertimeto[jumpoffset] = 0;
+ bufferpts[jumpoffset*2+0][1] = (timeinsweep-100000)/500;
+ buffertimeto[jumpoffset][1] = 0;
}
if( acode == 5 || acode == 7 ) //data = 1
{
- bufferpts[jumpoffset*2+1] = (timeinsweep-100000)/500;
- buffertimeto[jumpoffset] = 0;
+ bufferpts[jumpoffset*2+1][1] = (timeinsweep-100000)/500;
+ buffertimeto[jumpoffset][1] = 0;
}
}
@@ -93,6 +101,7 @@ void my_angle_process( struct SurviveObject * so, int sensor_id, int acode, uint
survive_default_angle_process( so, sensor_id, acode, timecode, length, angle );
}
+char* sensor_name[32];
void * GuiThread( void * v )
{
@@ -108,23 +117,35 @@ void * GuiThread( void * v )
CNFGColor( 0xFFFFFF );
CNFGGetDimensions( &screenx, &screeny );
- int i;
+ int i,nn;
for( i = 0; i < 32*3; i++ )
{
- if( buffertimeto[i] < 50 )
+ for( nn = 0; nn < 2; nn++ )
{
- 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]++;
+ if( buffertimeto[i][nn] < 50 )
+ {
+ uint32_t color = i * 3231349;
+ uint8_t r = 0xff;
+ uint8_t g = 0x00;
+ uint8_t b = 0xff;
+
+ if (nn==0) b = 0; //lighthouse B
+ if (nn==1) r = 0; //lighthouse C
+
+// r = (r * (5-buffertimeto[i][nn])) / 5 ;
+// g = (g * (5-buffertimeto[i][nn])) / 5 ;
+// b = (b * (5-buffertimeto[i][nn])) / 5 ;
+ CNFGColor( (b<<16) | (g<<8) | r );
+ CNFGTackRectangle( bufferpts[i*2+0][nn], bufferpts[i*2+1][nn], bufferpts[i*2+0][nn] + 5, bufferpts[i*2+1][nn] + 5 );
+ CNFGPenX = bufferpts[i*2+0][nn]; CNFGPenY = bufferpts[i*2+1][nn];
+ CNFGDrawText( buffermts, 2 );
+
+ if (i<32) {
+ CNFGPenX = bufferpts[i*2+0][nn]+5; CNFGPenY = bufferpts[i*2+1][nn]+5;
+ CNFGDrawText( sensor_name[i], 2 );
+ }
+ buffertimeto[i][nn]++;
+ }
}
}
@@ -148,6 +169,12 @@ int main()
{
ctx = survive_init( 0 );
+ uint8_t i =0;
+ for (i=0;i<32;++i) {
+ sensor_name[i] = malloc(3);
+ sprintf(sensor_name[i],"%d",i);
+ }
+
survive_install_light_fn( ctx, my_light_process );
survive_install_imu_fn( ctx, my_imu_process );
survive_install_angle_fn( ctx, my_angle_process );
@@ -163,10 +190,13 @@ int main()
return 1;
}
- while(survive_poll(ctx) == 0)
+ while(survive_poll(ctx) == 0 && !quit)
{
//Do stuff.
}
+
+ survive_close( ctx );
+
printf( "Returned\n" );
}