esp32_BNO08x/source/report/BNO08xRptRawMEMSAcceleromet...

53 lines
1.5 KiB
C++
Raw Normal View History

/**
* @file BNO08xRptRawMEMSAccelerometer.cpp
* @author Myles Parfeniuk
*/
2024-11-24 04:08:15 +00:00
#include "BNO08xRptRawMEMSAccelerometer.hpp"
/**
* @brief Updates raw 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 BNO08xRptRawMEMSAccelerometer::update_data(sh2_SensorValue_t* sensor_val)
{
lock_user_data();
data = sensor_val->un.rawAccelerometer;
2024-11-26 21:28:27 +00:00
data.accuracy = static_cast<BNO08xAccuracy>(sensor_val->status);
update_timestamp(sensor_val);
unlock_user_data();
2024-11-26 21:28:27 +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();
}
/**
* @brief Enables raw accelerometer reports such that the BNO08x begins sending them.
*
* @param report_period_us The period/interval of the report in microseconds.
* @param sensor_cfg Sensor special configuration (optional, see
* BNO08xPrivateTypes::default_sensor_cfg for defaults).
*
* @return True if report was successfully enabled.
*/
2024-12-27 02:02:09 +00:00
bool BNO08xRptRawMEMSAccelerometer::enable(uint32_t time_between_reports, sh2_SensorConfig_t sensor_cfg)
{
return BNO08xRpt::rpt_enable(time_between_reports, sensor_cfg);
}
/**
2024-12-05 04:07:40 +00:00
* @brief Grabs most recent raw accelerometer data, units are ADC counts, time_stamp in
* microseconds.
*
* @return Struct containing requested data.
*/
bno08x_raw_accel_t BNO08xRptRawMEMSAccelerometer::get()
{
lock_user_data();
bno08x_raw_accel_t rqdata = data;
unlock_user_data();
return rqdata;
}