コード例 #1
0
ファイル: eMPL_outputs.c プロジェクト: fishr/Origin
/**
 *  @brief      Acceleration (g's) in body frame.
 *  Embedded MPL defines gravity as positive acceleration pointing away from
 *  the Earth.
 *  @param[out] data        Acceleration in g's, q16 fixed point.
 *  @param[out] accuracy    Accuracy of the measurement from 0 (least accurate)
 *                          to 3 (most accurate).
 *  @param[out] timestamp   The time in milliseconds when this sensor was read.
 *  @return     1 if data was updated.
 */
int inv_get_sensor_type_accel(long *data, int8_t *accuracy, inv_time_t *timestamp)
{
    inv_get_accel_set(data, accuracy, timestamp);
    if (eMPL_out.accel_status & INV_NEW_DATA)
        return 1;
    else
        return 0;
}
コード例 #2
0
/**
 *  Acceleration (g's) in body frame.
 *  Microsoft defines gravity as positive acceleration pointing towards the
 *  Earth.
 *  @param[out] values      Acceleration in g's.
 *  @param[out] accuracy    0 (uncalibrated) to 3 (most accurate).
 *  @param[out] timestamp   Time when sensor was sampled.
 */
void inv_get_sensor_type_accel_float(float *values, int8_t *accuracy,
        inv_time_t *timestamp)
{
    long accel[3];
    inv_get_accel_set(accel, accuracy, timestamp);

    values[0] = (float) -accel[0] / 65536.f;
    values[1] = (float) -accel[1] / 65536.f;
    values[2] = (float) -accel[2] / 65536.f;
}
コード例 #3
0
/**
 *  @brief      Returns 3-element vector of accelerometer data in body frame
 *                with gravity removed
 *  @param[out] data    3-element vector of accelerometer data in body frame
 *                with gravity removed
 *  @return     INV_SUCCESS if successful
 *              INV_ERROR_INVALID_PARAMETER if invalid input pointer
 */
inv_error_t inv_get_linear_accel(long *data)
{
    long gravity[3];

    if (data != NULL)
    {
        inv_get_accel_set(data, NULL, NULL);
        inv_get_gravity(gravity);
        data[0] -= gravity[0] >> 14;
        data[1] -= gravity[1] >> 14;
        data[2] -= gravity[2] >> 14;
        return INV_SUCCESS;
    }