2024-11-27 23:54:47 +00:00
|
|
|
/**
|
2024-12-05 06:09:15 +00:00
|
|
|
* @file BNO08xRptTapDetector.cpp
|
2024-11-27 23:54:47 +00:00
|
|
|
* @author Myles Parfeniuk
|
|
|
|
|
*/
|
|
|
|
|
|
2024-12-05 06:09:15 +00:00
|
|
|
#include "BNO08xRptTapDetector.hpp"
|
2024-11-24 03:22:06 +00:00
|
|
|
|
|
|
|
|
/**
|
2024-12-05 04:07:40 +00:00
|
|
|
* @brief Enables tap detector reports such that the BNO08x begins sending them (only sends reports
|
|
|
|
|
* when a tap is detected).
|
2024-11-24 03:22:06 +00:00
|
|
|
*
|
|
|
|
|
* @param time_between_reports The period/interval of the report in microseconds.
|
2024-12-05 04:07:40 +00:00
|
|
|
* @param sensor_cfg Sensor special configuration (optional, see
|
|
|
|
|
* BNO08xPrivateTypes::default_sensor_cfg for defaults).
|
2024-11-24 03:22:06 +00:00
|
|
|
*
|
|
|
|
|
* @return True if report was successfully enabled.
|
|
|
|
|
*/
|
2024-12-05 06:09:15 +00:00
|
|
|
bool BNO08xRptTapDetector::enable(uint32_t time_between_reports, sh2_SensorConfig_t sensor_cfg)
|
2024-11-24 03:22:06 +00:00
|
|
|
{
|
2024-12-05 06:09:15 +00:00
|
|
|
sensor_cfg.changeSensitivityEnabled = true; // this must be set regardless of user cfg or no reports will be received
|
|
|
|
|
sensor_cfg.changeSensitivity = 0U; // this must be set regardless of user cfg or no reports will be received
|
2024-11-24 03:22:06 +00:00
|
|
|
|
2024-12-26 23:39:01 +00:00
|
|
|
return BNO08xRpt::rpt_enable(time_between_reports, sensor_cfg);
|
2024-11-24 03:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Updates tap detector data from decoded sensor event.
|
|
|
|
|
*
|
|
|
|
|
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
|
|
|
|
*
|
|
|
|
|
* @return void, nothing to return
|
|
|
|
|
*/
|
2024-12-05 06:09:15 +00:00
|
|
|
void BNO08xRptTapDetector::update_data(sh2_SensorValue_t* sensor_val)
|
2024-11-24 03:22:06 +00:00
|
|
|
{
|
2024-12-05 02:12:10 +00:00
|
|
|
lock_user_data();
|
2024-11-24 03:22:06 +00:00
|
|
|
data = sensor_val->un.tapDetector;
|
2024-11-26 21:28:27 +00:00
|
|
|
data.accuracy = static_cast<BNO08xAccuracy>(sensor_val->status);
|
2025-02-09 04:55:00 +00:00
|
|
|
update_timestamp(sensor_val);
|
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-24 03:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Grabs most recent tap detector detector data.
|
|
|
|
|
*
|
|
|
|
|
* @return Struct containing requested data;
|
|
|
|
|
*/
|
2024-12-05 06:09:15 +00:00
|
|
|
bno08x_tap_detector_t BNO08xRptTapDetector::get()
|
2024-11-24 03:22:06 +00:00
|
|
|
{
|
2024-12-05 02:12:10 +00:00
|
|
|
lock_user_data();
|
2024-11-24 03:22:06 +00:00
|
|
|
bno08x_tap_detector_t rqdata = data;
|
2024-12-05 02:12:10 +00:00
|
|
|
unlock_user_data();
|
2024-11-24 03:22:06 +00:00
|
|
|
return rqdata;
|
|
|
|
|
}
|