|
SensorLib 0.5.0
Multi-platform sensor driver library for Arduino, PlatformIO, and ESP-IDF
|
#include <SensorBHI260AP_Klio.hpp>
Public Types | |
| enum | LearningChangeReason { LEARNING_PROGRESSING , LEARNING_NO_REPETITIVE_ACTIVITY , LEARNING_NO_SIGNIFICANT } |
| enum | KlioPatternState { PATTERN_STATE_DISABLE = 0 , PATTERN_STATE_ENABLE , PATTERN_STATE_SWITCH_HAND , PATTERN_STATE_AP_DISABLE } |
| using | KlioParameter = bhy2_klio_parameter_t |
| using | KlioError = bhy2_klio_driver_error_state_t |
| using | KlioState = bhy2_klio_sensor_state_t |
| using | RecognitionCallback = void(*)(uint8_t pattern_id, float count, void *user_data) |
| using | LearningCallback = void(*)(LearningChangeReason reason, uint32_t progress, int learn_index, void *user_data) |
Public Member Functions | |
| SensorBHI260AP_Klio (SensorBHI260AP &sensor) | |
| Constructor to initialize the SensorBHI260AP_Klio object. | |
| ~SensorBHI260AP_Klio () | |
| Destructor to release resources occupied by the SensorBHI260AP_Klio object. | |
| void | end () |
| End the interaction with the KLIO functionality of the BHI260AP sensor and release related resources. | |
| bool | begin () |
| Initialize the interaction with the KLIO functionality of the BHI260AP sensor. | |
| bool | setState (bool learning_enable, bool learning_reset, bool recognition_enable, bool recognition_reset) |
| Set the learning and recognition states of the KLIO sensor. | |
| KlioState | getState () |
| Get the current state of the KLIO sensor. | |
| bool | setState (KlioState sensor_state) |
| Set the state of the KLIO sensor using a KlioState object. | |
| bool | learning () |
| Start the learning function of the KLIO sensor. | |
| bool | recognition (const uint8_t *pattern_ids, size_t size) |
| Start the recognition function of the KLIO sensor for the specified pattern IDs. | |
| bool | getLearnPattern (uint8_t *pattern, uint16_t *size) |
| Retrieve the learned pattern from the sensor. | |
| uint8_t | getMaxPatterns () |
| Retrieve the maximum number of recognition patterns allowed. | |
| bool | getParameter (KlioParameter id, uint8_t *parameter_data, uint16_t *size) |
| Get a parameter from the KLIO sensor. | |
| bool | setParameter (KlioParameter id, const void *parameter_data, uint16_t size) |
| Set a parameter of the KLIO sensor. | |
| bool | writePattern (uint8_t idx, const uint8_t *parameter_data, uint16_t size) |
| Write a pattern to the KLIO sensor. | |
| bool | writeMultiplePatterns (const uint8_t *ids, const uint8_t **parameter_data_array, const uint16_t *sizes, uint8_t count) |
| Write multiple patterns to the KLIO sensor. | |
| bool | setPattern (KlioPatternState operation, const uint8_t *pattern_ids, uint16_t size) |
| Set the state of patterns in the KLIO sensor. | |
| bool | enablePattern (const uint8_t *pattern_ids, uint16_t size) |
| Enable specified patterns in the KLIO sensor. | |
| bool | readPattern (uint8_t idx, uint8_t *buffer, uint16_t *length) |
| Read a pattern from the KLIO sensor. | |
| bool | enable (float sample_rate, uint32_t report_latency_ms) |
| Enable the KLIO sensor with specified sample rate and report latency. | |
| void | disable () |
| Disable the KLIO sensor. | |
| bool | logout (float sample_rate, uint32_t report_latency_ms) |
| Log out the KLIO sensor with specified sample rate and report latency. | |
| void | setLearningCallback (LearningCallback cb, void *user_data) |
| Set the callback function for the learning event. | |
| void | setRecognitionCallback (RecognitionCallback cb, void *user_data) |
| Set the callback function for the recognition event. | |
| bool | checkError () |
| Check if there is an error in the KLIO sensor. | |
| KlioError | getError () const |
| Get the error information of the KLIO sensor. | |
| const char * | errorToString () const |
| Convert the error information to a string. | |
Static Public Attributes | |
| static constexpr int8_t | INVALID_LEARNING_INDEX = -1 |
Definition at line 39 of file sensor/imu/bhi260/SensorBHI260AP_Klio.hpp.
| using SensorBHI260AP_Klio::KlioError = bhy2_klio_driver_error_state_t |
Definition at line 58 of file sensor/imu/bhi260/SensorBHI260AP_Klio.hpp.
| using SensorBHI260AP_Klio::KlioParameter = bhy2_klio_parameter_t |
Definition at line 57 of file sensor/imu/bhi260/SensorBHI260AP_Klio.hpp.
| using SensorBHI260AP_Klio::KlioState = bhy2_klio_sensor_state_t |
Definition at line 59 of file sensor/imu/bhi260/SensorBHI260AP_Klio.hpp.
| using SensorBHI260AP_Klio::LearningCallback = void (*)(LearningChangeReason reason, uint32_t progress, int learn_index, void *user_data) |
Definition at line 61 of file sensor/imu/bhi260/SensorBHI260AP_Klio.hpp.
| using SensorBHI260AP_Klio::RecognitionCallback = void (*)(uint8_t pattern_id, float count, void *user_data) |
Definition at line 60 of file sensor/imu/bhi260/SensorBHI260AP_Klio.hpp.
| Enumerator | |
|---|---|
| PATTERN_STATE_DISABLE | |
| PATTERN_STATE_ENABLE | |
| PATTERN_STATE_SWITCH_HAND | |
| PATTERN_STATE_AP_DISABLE | |
Definition at line 50 of file sensor/imu/bhi260/SensorBHI260AP_Klio.hpp.
| Enumerator | |
|---|---|
| LEARNING_PROGRESSING | |
| LEARNING_NO_REPETITIVE_ACTIVITY | |
| LEARNING_NO_SIGNIFICANT | |
Definition at line 44 of file sensor/imu/bhi260/SensorBHI260AP_Klio.hpp.
| SensorBHI260AP_Klio::SensorBHI260AP_Klio | ( | SensorBHI260AP & | sensor | ) |
Constructor to initialize the SensorBHI260AP_Klio object.
| sensor | A reference to the SensorBHI260AP object, used for communication with the BHI260AP sensor. |
Definition at line 48 of file SensorBHI260AP_Klio.cpp.
| SensorBHI260AP_Klio::~SensorBHI260AP_Klio | ( | ) |
Destructor to release resources occupied by the SensorBHI260AP_Klio object.
Definition at line 61 of file SensorBHI260AP_Klio.cpp.
References end().
| bool SensorBHI260AP_Klio::begin | ( | ) |
Initialize the interaction with the KLIO functionality of the BHI260AP sensor.
Definition at line 86 of file SensorBHI260AP_Klio.cpp.
References getParameter(), SENSORLIB_LOG_D, SENSORLIB_LOG_E, and setParameter().
Referenced by setup().
| bool SensorBHI260AP_Klio::checkError | ( | ) |
Check if there is an error in the KLIO sensor.
Definition at line 346 of file SensorBHI260AP_Klio.cpp.
References SENSORLIB_LOG_E.
| void SensorBHI260AP_Klio::disable | ( | ) |
Disable the KLIO sensor.
Definition at line 316 of file SensorBHI260AP_Klio.cpp.
References SENSORLIB_LOG_E.
Referenced by recognition_event_callback().
| bool SensorBHI260AP_Klio::enable | ( | float | sample_rate, |
| uint32_t | report_latency_ms | ||
| ) |
Enable the KLIO sensor with specified sample rate and report latency.
| sample_rate | The sample rate of the sensor. |
| report_latency_ms | The report latency in milliseconds. |
Definition at line 307 of file SensorBHI260AP_Klio.cpp.
References SENSORLIB_LOG_E.
Referenced by beginRecognition(), and setup().
| bool SensorBHI260AP_Klio::enablePattern | ( | const uint8_t * | pattern_ids, |
| uint16_t | size | ||
| ) |
Enable specified patterns in the KLIO sensor.
| pattern_ids | An array containing the IDs of the patterns to be enabled. |
| size | The number of elements in the pattern_ids array. |
Definition at line 297 of file SensorBHI260AP_Klio.cpp.
| void SensorBHI260AP_Klio::end | ( | ) |
End the interaction with the KLIO functionality of the BHI260AP sensor and release related resources.
Definition at line 66 of file SensorBHI260AP_Klio.cpp.
Referenced by ~SensorBHI260AP_Klio().
| const char * SensorBHI260AP_Klio::errorToString | ( | ) | const |
Convert the error information to a string.
Definition at line 367 of file SensorBHI260AP_Klio.cpp.
Referenced by learning_event_callback().
| SensorBHI260AP_Klio::KlioError SensorBHI260AP_Klio::getError | ( | ) | const |
Get the error information of the KLIO sensor.
Definition at line 362 of file SensorBHI260AP_Klio.cpp.
| bool SensorBHI260AP_Klio::getLearnPattern | ( | uint8_t * | pattern, |
| uint16_t * | size | ||
| ) |
Retrieve the learned pattern from the sensor.
This function attempts to obtain the learned pattern data from the sensor. It populates the provided buffer with the pattern data and sets the size parameter to indicate the actual size of the retrieved pattern.
| pattern | A pointer to a buffer where the learned pattern data will be stored. The buffer should be large enough to hold the entire pattern. |
| size | A pointer to a variable of type uint16_t. On input, it can be used to specify the maximum capacity of the pattern buffer. On output, it will be updated to contain the actual size of the retrieved pattern. |
Definition at line 211 of file SensorBHI260AP_Klio.cpp.
Referenced by learning_event_callback().
| uint8_t SensorBHI260AP_Klio::getMaxPatterns | ( | ) |
Retrieve the maximum number of recognition patterns allowed.
This function is used to obtain the maximum number of recognition patterns that the system or device can support. It provides an important parameter for operations related to pattern recognition, such as determining how many different patterns can be learned and stored for subsequent recognition tasks.
Definition at line 216 of file SensorBHI260AP_Klio.cpp.
Referenced by setup().
| bool SensorBHI260AP_Klio::getParameter | ( | KlioParameter | id, |
| uint8_t * | parameter_data, | ||
| uint16_t * | size | ||
| ) |
Get a parameter from the KLIO sensor.
| id | The ID of the parameter to be retrieved. |
| parameter_data | A pointer to the buffer where the parameter data will be stored. |
| size | A pointer to the variable that stores the size of the parameter data. On input, it should be the size of the buffer. On output, it will be the actual size of the retrieved data. |
Definition at line 266 of file SensorBHI260AP_Klio.cpp.
Referenced by begin().
| SensorBHI260AP_Klio::KlioState SensorBHI260AP_Klio::getState | ( | ) |
Get the current state of the KLIO sensor.
Definition at line 172 of file SensorBHI260AP_Klio.cpp.
References SENSORLIB_LOG_E.
Referenced by learning(), and recognition().
| bool SensorBHI260AP_Klio::learning | ( | ) |
Start the learning function of the KLIO sensor.
Definition at line 192 of file SensorBHI260AP_Klio.cpp.
References getState(), and setState().
Referenced by setup().
| bool SensorBHI260AP_Klio::logout | ( | float | sample_rate, |
| uint32_t | report_latency_ms | ||
| ) |
Log out the KLIO sensor with specified sample rate and report latency.
| sample_rate | The sample rate of the sensor. |
| report_latency_ms | The report latency in milliseconds. |
Definition at line 325 of file SensorBHI260AP_Klio.cpp.
References SENSORLIB_LOG_E.
| bool SensorBHI260AP_Klio::readPattern | ( | uint8_t | idx, |
| uint8_t * | buffer, | ||
| uint16_t * | length | ||
| ) |
Read a pattern from the KLIO sensor.
| idx | The index of the pattern to be read. |
| buffer | A pointer to the buffer where the pattern data will be stored. |
| length | A pointer to the variable that stores the size of the buffer. On input, it should be the size of the buffer. On output, it will be the actual size of the read data. |
Definition at line 302 of file SensorBHI260AP_Klio.cpp.
| bool SensorBHI260AP_Klio::recognition | ( | const uint8_t * | pattern_ids, |
| size_t | size | ||
| ) |
Start the recognition function of the KLIO sensor for the specified pattern IDs.
| pattern_ids | An array containing the pattern IDs to be recognized. |
| size | The number of elements in the pattern_ids array. |
Definition at line 199 of file SensorBHI260AP_Klio.cpp.
References getState(), SENSORLIB_LOG_E, and setState().
Referenced by beginRecognition(), learning_event_callback(), and setup().
| void SensorBHI260AP_Klio::setLearningCallback | ( | LearningCallback | cb, |
| void * | user_data | ||
| ) |
Set the callback function for the learning event.
| cb | A pointer to the callback function to be set. |
| user_data | A pointer to user - defined data to be passed to the callback function. |
Definition at line 334 of file SensorBHI260AP_Klio.cpp.
Referenced by setup().
| bool SensorBHI260AP_Klio::setParameter | ( | KlioParameter | id, |
| const void * | parameter_data, | ||
| uint16_t | size | ||
| ) |
Set a parameter of the KLIO sensor.
| id | The ID of the parameter to be set. |
| parameter_data | A pointer to the data to be set as the parameter. |
| size | The size of the parameter data. |
Definition at line 271 of file SensorBHI260AP_Klio.cpp.
Referenced by begin().
| bool SensorBHI260AP_Klio::setPattern | ( | KlioPatternState | operation, |
| const uint8_t * | pattern_ids, | ||
| uint16_t | size | ||
| ) |
Set the state of patterns in the KLIO sensor.
| operation | The operation to be performed on the patterns (e.g., enable, disable). |
| pattern_ids | An array containing the IDs of the patterns to be operated on. |
| size | The number of elements in the pattern_ids array. |
Definition at line 292 of file SensorBHI260AP_Klio.cpp.
| void SensorBHI260AP_Klio::setRecognitionCallback | ( | RecognitionCallback | cb, |
| void * | user_data | ||
| ) |
Set the callback function for the recognition event.
| cb | A pointer to the callback function to be set. |
| user_data | A pointer to user - defined data to be passed to the callback function. |
Definition at line 340 of file SensorBHI260AP_Klio.cpp.
Referenced by setup().
| bool SensorBHI260AP_Klio::setState | ( | bool | learning_enable, |
| bool | learning_reset, | ||
| bool | recognition_enable, | ||
| bool | recognition_reset | ||
| ) |
Set the learning and recognition states of the KLIO sensor.
| learning_enable | Whether to enable the learning function. true for enable, false for disable. |
| learning_reset | Whether to reset the learning state. true for reset, false for not reset. |
| recognition_enable | Whether to enable the recognition function. true for enable, false for disable. |
| recognition_reset | Whether to reset the recognition state. true for reset, false for not reset. |
Definition at line 160 of file SensorBHI260AP_Klio.cpp.
Referenced by learning(), and recognition().
| bool SensorBHI260AP_Klio::setState | ( | KlioState | sensor_state | ) |
Set the state of the KLIO sensor using a KlioState object.
| sensor_state | A KlioState object containing learning and recognition state information. |
Definition at line 183 of file SensorBHI260AP_Klio.cpp.
References SENSORLIB_LOG_E.
| bool SensorBHI260AP_Klio::writeMultiplePatterns | ( | const uint8_t * | ids, |
| const uint8_t ** | parameter_data_array, | ||
| const uint16_t * | sizes, | ||
| uint8_t | count | ||
| ) |
Write multiple patterns to the KLIO sensor.
| ids | An array containing the indices of the patterns to be written. |
| parameter_data_array | An array of pointers to the pattern data arrays. |
| sizes | An array containing the sizes of the pattern data arrays. |
| count | The number of patterns to be written. |
Definition at line 281 of file SensorBHI260AP_Klio.cpp.
References i, and SENSORLIB_LOG_D.
Referenced by beginRecognition().
| bool SensorBHI260AP_Klio::writePattern | ( | uint8_t | idx, |
| const uint8_t * | parameter_data, | ||
| uint16_t | size | ||
| ) |
Write a pattern to the KLIO sensor.
| idx | The index of the pattern to be written. |
| parameter_data | A pointer to the pattern data. |
| size | The size of the pattern data. |
Definition at line 276 of file SensorBHI260AP_Klio.cpp.
Referenced by learning_event_callback(), and setup().
|
staticconstexpr |
Definition at line 42 of file sensor/imu/bhi260/SensorBHI260AP_Klio.hpp.
Referenced by learning_event_callback().