コード例 #1
0
main()
{
  float a0, b1, b2, c12, c11, c22;
  unsigned int Padc;
  unsigned int Tadc;
  unsigned char msb, lsb;


  msb = 0x52;
  lsb = 0x00;
  Padc =  (((unsigned int)msb << 8) + lsb) >> 6;
  msb = 0x81;
  lsb = 0xc0;
  Tadc =  (((unsigned int)msb << 8) + lsb) >> 6;

  a0 = read_coefficients(16, 3, 0, 0x3a, 0xa0);
  b1 = read_coefficients(16, 13, 0, 0xba, 0xc0);
  b2 = read_coefficients(16, 14, 0, 0xc0, 0x53);
  c12 = read_coefficients(14, 13, 9, 0x2e, 0xc4);
  c11 = read_coefficients(11, 10, 11, 0x00, 0x00);
  c22 = read_coefficients(11, 10, 15, 0x00, 0x00);
  float Pcomp = a0 + (b1 + c11 * Padc + c12 * Tadc) * Padc + (b2 + c22 * Tadc) * Tadc;
  float hpa = Pcomp * 650 / 1023 + 500;
  printf("%f\n", hpa);

  msb = 0x00;
  lsb = 0x52;
  Padc =  (((unsigned int)msb << 8) + lsb) >> 6;
  msb = 0xc0;
  lsb = 0x81;
  Tadc =  (((unsigned int)msb << 8) + lsb) >> 6;
  a0 = read_coefficients2(16, 3, 0, 0x3a, 0xa0);
  b1 = read_coefficients2(16, 13, 0, 0xba, 0xc0);
  b2 = read_coefficients2(16, 14, 0, 0xc0, 0x53);
  c12 = read_coefficients2(14, 13, 9, 0x2e, 0xc4);
  c11 = read_coefficients2(11, 10, 11, 0x00, 0x00);
  c22 = read_coefficients2(11, 10, 15, 0x00, 0x00);
   Pcomp = a0 + (b1 + c11 * Padc + c12 * Tadc) * Padc + (b2 + c22 * Tadc) * Tadc;
   hpa = Pcomp * 650 / 1023 + 500;
  printf("%f\n", hpa);
}
コード例 #2
0
 void barometer_MPL115A2_init(){
	 P2DIR |= BIT7;
	 read_coefficients();
	 // read coefficient ??
 }
コード例 #3
0
bool Ckff_synthesis::On_Execute(void)
{
	CSG_Grid *poutgrid;

	int numlat = 0;
	int numlong = 0;
	int maxdegree = 0;
	int mindegree = 0;
	int rc = 0;
	double inc = 0.0;
	double lat_start = 0.0;
	double end_lat = 0.0;
	double long_start = 0.0;
	double end_long = 0.0;
	CSG_String fileName;
    double **c_lm;
	double **s_lm;
	double **gitter;
	char *error_liste = "nix";

	//poutgrid = Parameters ("OUTPUT GRID")->asGrid ();

	fileName	= Parameters("FILE")->asString();
	inc = Parameters ("INC")->asDouble ();
	mindegree = Parameters ("MINDEGREE")->asInt ();
	maxdegree = Parameters ("MAXDEGREE")->asInt ();
	lat_start = Parameters ("LAT_START")->asDouble ();
	end_lat = Parameters ("END_LAT")->asDouble ();
	long_start = Parameters ("LONG_START")->asDouble ();
	end_long = Parameters ("END_LONG")->asDouble ();

	numlat = static_cast <int> (floor ((end_lat - lat_start) / inc) + 1);
	numlong = static_cast <int> (floor ((end_long - long_start) / inc) + 1);
	gitter = (double **) matrix_all_alloc (numlat, numlong, 'D', 0);

	read_coefficients (fileName.b_str(),
		               mindegree,
                       maxdegree,
                       &c_lm,
                       &s_lm);


	rc = kff_synthese_regel_gitter_m (inc,
                                    lat_start,
                                    end_lat,
                                    long_start,
									end_long,
									numlat,
									numlong,
                                    'A',
                                    mindegree,
                                    maxdegree,
                                    c_lm,
                                    s_lm,
                                    gitter,
                                    &error_liste);

	poutgrid	= SG_Create_Grid(SG_DATATYPE_Double, numlong, numlat, inc, long_start, lat_start);
	poutgrid	->Set_Name(_TL("Synthesized Grid"));

	for (int y = 0; y < numlat; y++)
	{
		#pragma omp parallel for
       for (int x = 0; x < numlong; x++)
       {
		    poutgrid->Set_Value(x,y, gitter[y][x]);
	   }
   }

   Parameters("OUTPUT_GRID")->Set_Value(poutgrid);

   matrix_all_free ((void **) gitter);
   matrix_all_free ((void **) c_lm);
   matrix_all_free ((void **) s_lm);

   return( true );
}