/* toAccelG.cpp -- convert raw data to actual acceleration G values
 *
 * from: MMA8452Q Basic Example Code
 * Nathan Seidle SparkFun Electronics
 * November 5, 2012
 */
#include "MMA8452Q.h" // our externs

// convert given int data to floating point G accellerations
//  takes array of 3 ints in and fills array of 3 floats on return
void MMA8452Q::toAccelG( int *data, float *accelG )
{  
  // Now we'll calculate the accleration value into actual g's
  for (int i = 0 ; i < 3 ; i++)
  {
	// get actual g value, this depends on GSCALE being set
    accelG[i] = (float) data[i] / ((1<<12)/(2*GSCALE));
  }
}
