Exemplo n.º 1
0
double get_magnitude(unsigned char *acc) 
{
	float x,y,z;
	double	r, r2;
	
	x = convert_to_g(acc[0]);
	y = convert_to_g(acc[1]);
	z = convert_to_g(acc[2]);
	
	r2 = x*x + y*y + z*z;
	r = sqrt(r2);
	
	return r;
	
}
Exemplo n.º 2
0
int get_data_x(float * result){
  unsigned char data;
  unsigned short raw;
  char negative = 0;
  //read data0 from X-Axis
  if(read_byte(DATAX0, &data) == 0)
    return 0;
 // printf("X-Axis Data0:  %02d\n",data);
  raw = data;

  //read data1 from X-Axis
  if(read_byte(DATAX1, &data) == 0)
    return 0;

 // printf("X-Axis Data1:  %02d -- %02x\n",data, data);
  raw += data<<8;

        *result = convert_to_g(raw);
  return 1;
}