2024-11-27 23:54:47 +00:00
|
|
|
/**
|
|
|
|
|
* @file BNO08xRptGameRV.cpp
|
|
|
|
|
* @author Myles Parfeniuk
|
|
|
|
|
*/
|
|
|
|
|
|
2024-11-24 19:16:07 +00:00
|
|
|
#include "BNO08xRptGameRV.hpp"
|
2024-11-23 01:05:03 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Updates game rotation vector data from decoded sensor event.
|
|
|
|
|
*
|
|
|
|
|
* @param sensor_val The sh2_SensorValue_t struct used in sh2_decodeSensorEvent() call.
|
|
|
|
|
*
|
|
|
|
|
* @return void, nothing to return
|
|
|
|
|
*/
|
|
|
|
|
void BNO08xRptGameRV::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.gameRotationVector;
|
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-24 19:16:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Tares game rotation vector axis.
|
|
|
|
|
*
|
|
|
|
|
* @param x If true tare x axis (optional, default true).
|
|
|
|
|
* @param y If true tare y axis (optional, default true).
|
|
|
|
|
* @param z If true tare z axis (optional, default true).
|
|
|
|
|
*
|
|
|
|
|
* @return True if tare operation succeeded.
|
|
|
|
|
*/
|
|
|
|
|
bool BNO08xRptGameRV::tare(bool x, bool y, bool z)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return BNO08xRptRVGeneric::tare(x, y, z, SH2_TARE_BASIS_GAMING_ROTATION_VECTOR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Saves most recent tare operation to BNO08x internal flash, such that it persists on reset.
|
|
|
|
|
*
|
|
|
|
|
* @return True if tare operation succeeded.
|
|
|
|
|
*/
|
|
|
|
|
bool BNO08xRptGameRV::tare_persist()
|
|
|
|
|
{
|
|
|
|
|
int success = SH2_ERR;
|
|
|
|
|
|
2024-12-05 02:12:10 +00:00
|
|
|
lock_sh2_HAL();
|
2024-11-24 19:16:07 +00:00
|
|
|
success = sh2_persistTare();
|
2024-12-05 02:12:10 +00:00
|
|
|
unlock_sh2_HAL();
|
2024-11-24 19:16:07 +00:00
|
|
|
|
|
|
|
|
if (success != SH2_OK)
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Clears most recent tare operation.
|
|
|
|
|
*
|
|
|
|
|
* @return void, nothing to return
|
|
|
|
|
*/
|
|
|
|
|
void BNO08xRptGameRV::tare_clear()
|
|
|
|
|
{
|
2024-12-05 02:12:10 +00:00
|
|
|
lock_sh2_HAL();
|
2024-11-24 19:16:07 +00:00
|
|
|
sh2_clearTare();
|
2024-12-05 02:12:10 +00:00
|
|
|
unlock_sh2_HAL();
|
2024-11-23 01:05:03 +00:00
|
|
|
}
|