removal of map find() for faster cb execution
This commit is contained in:
parent
3d06f4adbb
commit
f00416c297
|
|
@ -220,11 +220,10 @@ class BNO08x
|
||||||
|
|
||||||
sh2_ProductIds_t product_IDs; ///< Product ID info returned IMU at initialization, can be viewed with print_product_ids()
|
sh2_ProductIds_t product_IDs; ///< Product ID info returned IMU at initialization, can be viewed with print_product_ids()
|
||||||
|
|
||||||
static const constexpr uint8_t IMPLEMENTED_REPORT_COUNT =
|
static const constexpr uint8_t TOTAL_RPT_COUNT = 38; ///< Amount of possible reports returned from BNO08x.
|
||||||
21; ///< Amount of report implementations that have been created, some are still missing.
|
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
etl::map<uint8_t, BNO08xRpt*, IMPLEMENTED_REPORT_COUNT, etl::less<uint8_t>> usr_reports =
|
etl::map<uint8_t, BNO08xRpt*, TOTAL_RPT_COUNT, etl::less<uint8_t>> usr_reports =
|
||||||
{
|
{
|
||||||
{SH2_ACCELEROMETER, &accelerometer},
|
{SH2_ACCELEROMETER, &accelerometer},
|
||||||
{SH2_LINEAR_ACCELERATION, &linear_accelerometer},
|
{SH2_LINEAR_ACCELERATION, &linear_accelerometer},
|
||||||
|
|
@ -233,7 +232,8 @@ class BNO08x
|
||||||
{SH2_MAGNETIC_FIELD_UNCALIBRATED, &uncal_magnetometer},
|
{SH2_MAGNETIC_FIELD_UNCALIBRATED, &uncal_magnetometer},
|
||||||
{SH2_GYROSCOPE_CALIBRATED, &cal_gyro},
|
{SH2_GYROSCOPE_CALIBRATED, &cal_gyro},
|
||||||
{SH2_GYROSCOPE_UNCALIBRATED, &uncal_gyro},
|
{SH2_GYROSCOPE_UNCALIBRATED, &uncal_gyro},
|
||||||
{SH2_ROTATION_VECTOR, &rv}, {SH2_GAME_ROTATION_VECTOR, &rv_game},
|
{SH2_ROTATION_VECTOR, &rv},
|
||||||
|
{SH2_GAME_ROTATION_VECTOR, &rv_game},
|
||||||
{SH2_ARVR_STABILIZED_RV, &rv_ARVR_stabilized},
|
{SH2_ARVR_STABILIZED_RV, &rv_ARVR_stabilized},
|
||||||
{SH2_ARVR_STABILIZED_GRV, &rv_ARVR_stabilized_game},
|
{SH2_ARVR_STABILIZED_GRV, &rv_ARVR_stabilized_game},
|
||||||
{SH2_GYRO_INTEGRATED_RV, &rv_gyro_integrated},
|
{SH2_GYRO_INTEGRATED_RV, &rv_gyro_integrated},
|
||||||
|
|
@ -245,7 +245,26 @@ class BNO08x
|
||||||
{SH2_PERSONAL_ACTIVITY_CLASSIFIER, &activity_classifier},
|
{SH2_PERSONAL_ACTIVITY_CLASSIFIER, &activity_classifier},
|
||||||
{SH2_STABILITY_CLASSIFIER, &stability_classifier},
|
{SH2_STABILITY_CLASSIFIER, &stability_classifier},
|
||||||
{SH2_SHAKE_DETECTOR, &shake_detector},
|
{SH2_SHAKE_DETECTOR, &shake_detector},
|
||||||
{SH2_TAP_DETECTOR, &tap_detector}};
|
{SH2_TAP_DETECTOR, &tap_detector},
|
||||||
|
|
||||||
|
// not implemented, see include/report for existing implementations to add your own
|
||||||
|
{SH2_PRESSURE, nullptr}, // requires auxilary i2c sensor
|
||||||
|
{SH2_AMBIENT_LIGHT, nullptr}, // requires auxilary i2c sensor
|
||||||
|
{SH2_HUMIDITY, nullptr}, // requires auxilary i2c sensor
|
||||||
|
{SH2_PROXIMITY, nullptr}, // requires auxilary i2c sensor
|
||||||
|
{SH2_TEMPERATURE, nullptr}, // requires auxilary i2c sensor
|
||||||
|
{SH2_HEART_RATE_MONITOR, nullptr}, // requires auxilary i2c sensor
|
||||||
|
{SH2_STEP_DETECTOR, nullptr},
|
||||||
|
{SH2_SIGNIFICANT_MOTION, nullptr},
|
||||||
|
{SH2_FLIP_DETECTOR, nullptr},
|
||||||
|
{SH2_PICKUP_DETECTOR, nullptr},
|
||||||
|
{SH2_STABILITY_DETECTOR, nullptr},
|
||||||
|
{SH2_SLEEP_DETECTOR, nullptr},
|
||||||
|
{SH2_TILT_DETECTOR, nullptr},
|
||||||
|
{SH2_POCKET_DETECTOR, nullptr},
|
||||||
|
{SH2_CIRCLE_DETECTOR, nullptr},
|
||||||
|
{SH2_IZRO_MOTION_REQUEST, nullptr}
|
||||||
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
static void IRAM_ATTR hint_handler(void* arg);
|
static void IRAM_ATTR hint_handler(void* arg);
|
||||||
|
|
|
||||||
|
|
@ -324,12 +324,14 @@ void BNO08x::handle_sensor_report(sh2_SensorValue_t* sensor_val)
|
||||||
{
|
{
|
||||||
uint8_t rpt_ID = sensor_val->sensorId;
|
uint8_t rpt_ID = sensor_val->sensorId;
|
||||||
|
|
||||||
// check if report exists within map
|
// check if report implementation exists within map
|
||||||
auto it = usr_reports.find(rpt_ID);
|
if(rpt_ID == SH2_RESERVED)
|
||||||
if (it == usr_reports.end())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto& rpt = it->second;
|
auto& rpt = usr_reports.at(rpt_ID);
|
||||||
|
|
||||||
|
if(rpt == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
// send report ids to cb_task for callback execution (only if this report is enabled)
|
// send report ids to cb_task for callback execution (only if this report is enabled)
|
||||||
if (rpt->rpt_bit & xEventGroupGetBits(evt_grp_report_en))
|
if (rpt->rpt_bit & xEventGroupGetBits(evt_grp_report_en))
|
||||||
|
|
@ -1266,6 +1268,11 @@ esp_err_t BNO08x::re_enable_reports()
|
||||||
for (auto entry = usr_reports.begin(); entry != usr_reports.end(); ++entry)
|
for (auto entry = usr_reports.begin(); entry != usr_reports.end(); ++entry)
|
||||||
{
|
{
|
||||||
BNO08xRpt* rpt = entry->second;
|
BNO08xRpt* rpt = entry->second;
|
||||||
|
|
||||||
|
//all reports in map passed this point should be null
|
||||||
|
if(rpt == nullptr)
|
||||||
|
break;
|
||||||
|
|
||||||
if (rpt->rpt_bit & report_en_bits)
|
if (rpt->rpt_bit & report_en_bits)
|
||||||
{
|
{
|
||||||
if (!rpt->enable(rpt->period_us))
|
if (!rpt->enable(rpt->period_us))
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue