esp32_BNO08x/source/report/BNO08xRptAcceleration.cpp

32 lines
829 B
C++
Raw Normal View History

2024-11-24 04:08:15 +00:00
#include "BNO08xRptAcceleration.hpp"
2024-11-23 01:05:03 +00:00
#include "BNO08x.hpp"
/**
* @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 BNO08xRptAcceleration::update_data(sh2_SensorValue_t* sensor_val)
{
imu->lock_user_data();
data = sensor_val->un.accelerometer;
imu->unlock_user_data();
2024-11-24 04:08:15 +00:00
if (rpt_bit & xEventGroupGetBits(imu->evt_grp_report_en))
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.
*/
bno08x_accel_t BNO08xRptAcceleration::get()
2024-11-23 01:05:03 +00:00
{
imu->lock_user_data();
bno08x_accel_t rqdata = data;
2024-11-23 01:05:03 +00:00
imu->unlock_user_data();
return rqdata;
}