root/core/gps_simulate.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. camera_jpeg_current_filename
  2. camera_jpeg_current_gps
  3. GPS_FakeData

   1 /*
   2  * 
   3  * GPS simulation code for cameras without GPS capability
   4  *   - only useful for testing code changes on non-GPS cameras
   5  *   - comment out gps_key_trap, camera_jpeg_current_filename, camera_jpeg_current_gps here if 
   6  *     they are actually defined for the camera being tested
   7  * 
   8  */
   9  
  10 char gps_fakename[32] = "img_1234" ;
  11 tGPS gps_dummy_data ;
  12 
  13 int  gps_key_trap = 0 ;
  14 char *camera_jpeg_current_filename() { return (void*)gps_fakename; }
  15 char *camera_jpeg_current_gps() { return (void*)&gps_dummy_data; }
  16 
  17 static int gps_first_pass = 0 ;
  18 static int x_velocity = 4000 ;
  19 static int y_velocity = 2000 ;
  20 
  21 void GPS_FakeData()
  22 {
  23     struct tm *ttm = get_localtime();
  24 
  25     gps_dummy_data.timeStamp[0] = ttm->tm_hour;
  26     gps_dummy_data.timeStamp[1] = 1 ;
  27     gps_dummy_data.timeStamp[2] = ttm->tm_min ;
  28     gps_dummy_data.timeStamp[3] = 1 ;
  29     gps_dummy_data.timeStamp[4] = ttm->tm_sec*1000 ;
  30     gps_dummy_data.timeStamp[5] = 1000 ;    
  31     
  32     
  33     if ( gps_first_pass == 0 ) 
  34     {
  35         gps_first_pass = 1; 
  36         
  37         gps_dummy_data.latitude[0] = 40;
  38         gps_dummy_data.latitude[1] = 1;
  39         gps_dummy_data.latitude[2] = 00;
  40         gps_dummy_data.latitude[3] = 1;
  41         gps_dummy_data.latitude[4] = 0;
  42         gps_dummy_data.latitude[5] = 1000;
  43         
  44         gps_dummy_data.longitude[0] = 80 ;
  45         gps_dummy_data.longitude[1] = 1 ;
  46         gps_dummy_data.longitude[2] = 0 ;
  47         gps_dummy_data.longitude[3] = 1;
  48         gps_dummy_data.longitude[4] = 0;
  49         gps_dummy_data.longitude[5] = 1000;
  50         
  51         gps_dummy_data.height[0] = 3000 ;
  52         gps_dummy_data.height[1] = 100 ;
  53                     
  54         strcpy(gps_dummy_data.latitudeRef ,"N"  ) ;
  55         strcpy(gps_dummy_data.longitudeRef ,"W" ) ;
  56         strcpy(gps_dummy_data.heightRef,   "n/a") ;   // not used
  57         strcpy(gps_dummy_data.status,      "??" ) ;   // not used
  58         strcpy(gps_dummy_data.mapDatum,    "??" ) ;   // not used
  59         strcpy(gps_dummy_data.dateStamp,   "??" ) ;   // not used
  60         strcpy(gps_dummy_data.unknown2,    "???") ;   // not used
  61     }
  62     else
  63     {
  64         gps_dummy_data.latitude[4] +=  x_velocity;
  65         if( gps_dummy_data.latitude[4] >= 60000 )
  66         {
  67             gps_dummy_data.latitude[4] = gps_dummy_data.latitude[4] - 60000;
  68             if( ++gps_dummy_data.latitude[2] >= 60 ) 
  69             {
  70                 gps_dummy_data.latitude[2] = 0 ;
  71                 if( ++gps_dummy_data.latitude[0] >= 42 ) x_velocity *= -1 ;
  72             }
  73         }
  74         if( gps_dummy_data.latitude[4] < 0 )
  75         {
  76             gps_dummy_data.latitude[4]  = gps_dummy_data.latitude[4] + 60000 ;
  77             if ( --gps_dummy_data.latitude[2] < 0 )        
  78             {
  79                 gps_dummy_data.latitude[2] = 59 ;              
  80                 if( --gps_dummy_data.latitude[0] < 40 ) x_velocity *= -1 ;
  81             }
  82         }
  83      
  84         gps_dummy_data.longitude[4] +=  y_velocity;
  85         if( gps_dummy_data.longitude[4] >= 60000 )
  86         {
  87             gps_dummy_data.longitude[4] = gps_dummy_data.longitude[4] - 60000;
  88             if( ++gps_dummy_data.longitude[2] >= 60 ) 
  89             {
  90                 gps_dummy_data.longitude[2] = 0 ;
  91                 if( ++gps_dummy_data.longitude[0] >= 82 ) y_velocity *= -1 ;
  92             }
  93         }
  94         if( gps_dummy_data.longitude[4] < 0 )
  95         {
  96             gps_dummy_data.longitude[4]  = gps_dummy_data.longitude[4] + 60000 ;
  97             if ( --gps_dummy_data.longitude[2] < 0 )        
  98             {
  99                 gps_dummy_data.longitude[2] = 59 ;              
 100                 if( --gps_dummy_data.longitude[0] < 80 ) y_velocity *= -1 ;
 101             }
 102         }
 103     }
 104     
 105     char vBuf[256];
 106     sprintf(vBuf, "%02d.%02d.%05d  %02d.%02d.%05d",
 107         gps_dummy_data.latitude[0] / gps_dummy_data.latitude[1] , 
 108         gps_dummy_data.latitude[2] / gps_dummy_data.latitude[3] ,
 109         gps_dummy_data.latitude[4] / gps_dummy_data.latitude[5] ,   
 110         gps_dummy_data.longitude[0] / gps_dummy_data.longitude[1] , 
 111         gps_dummy_data.longitude[2] / gps_dummy_data.longitude[3] ,
 112         gps_dummy_data.longitude[4] / gps_dummy_data.longitude[5] );      
 113     draw_txt_string(1, 0, vBuf, MAKE_COLOR(COLOR_TRANSPARENT, COLOR_RED));    
 114     
 115     return ;
 116 } ;
 117 
 118 
 119 

/* [<][>][^][v][top][bottom][index][help] */