2024-11-27 23:54:47 +00:00
|
|
|
/**
|
|
|
|
|
* @file BNO08xRptLinearAcceleration.cpp
|
|
|
|
|
* @author Myles Parfeniuk
|
|
|
|
|
*/
|
|
|
|
|
|
2024-11-24 04:08:15 +00:00
|
|
|
#include "BNO08xRptLinearAcceleration.hpp"
|
2024-11-23 01:05:03 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Updates accelerometer data from decoded sensor event.
|
|
|
|
|
*
|
|
|
|
|
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
|
|
|
|
*
|
|
|
|
|
* @return void, nothing to return
|
|
|
|
|
*/
|
|
|
|
|
void BNO08xRptLinearAcceleration::update_data(sh2_SensorValue_t* sensor_val)
|
|
|
|
|
{
|
2024-12-05 02:12:10 +00:00
|
|
|
lock_user_data();
|
2024-11-23 01:05:03 +00:00
|
|
|
data = sensor_val->un.linearAcceleration;
|
2024-11-26 21:28:27 +00:00
|
|
|
data.accuracy = static_cast<BNO08xAccuracy>(sensor_val->status);
|
2024-12-05 02:12:10 +00:00
|
|
|
unlock_user_data();
|
2024-11-24 04:08:15 +00:00
|
|
|
|
2024-12-05 06:09:15 +00:00
|
|
|
if (rpt_bit & xEventGroupGetBits(sync_ctx->evt_grp_rpt_en))
|
2024-11-24 04:08:15 +00:00
|
|
|
signal_data_available();
|
2024-11-23 01:05:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Grabs most recent acceleration data (including gravity), units are in m/s^2.
|
|
|
|
|
*
|
|
|
|
|
* @return Struct containing requested data.
|
|
|
|
|
*/
|
2024-11-24 03:22:06 +00:00
|
|
|
bno08x_accel_t BNO08xRptLinearAcceleration::get()
|
2024-11-23 01:05:03 +00:00
|
|
|
{
|
2024-12-05 02:12:10 +00:00
|
|
|
lock_user_data();
|
2024-11-24 03:22:06 +00:00
|
|
|
bno08x_accel_t rqdata = data;
|
2024-12-05 02:12:10 +00:00
|
|
|
unlock_user_data();
|
2024-11-23 01:05:03 +00:00
|
|
|
return rqdata;
|
|
|
|
|
}
|