The sensor fusion algorithm interface enables the plug-in sensors, such as pedometer and activity recognition and the application of the fusion algorithms.
More...
The sensor fusion algorithm interface enables the plug-in sensors, such as pedometer and activity recognition and the application of the fusion algorithms.
The fusion algorithm is available in a library format. The APIs are designed to feed the physical sensor data into fusion algorithms and obtain the results based on the various application needs.
How to use sensor fusion algorithm interface
Below is an example of the pedometer fusion algorithm (requires accelerometer of 50Hz sampling rate) registration. The steps are shown below:
- Step 1. Prepare the sensor_descriptor_t for the pedometer.
- Step 2. Set the required input sensor.
- Step 3. Register the pedometer fusion algorithm using sensor_fusion_algorithm_register_type().
- Step 4. Register the data buffer using sensor_fusion_algorithm_register_data_buffer(). Please refer to sensor_manager_t in [sdk_root]/middleware/MTK/sensor_subsys/src/sensor_manager.c for data buffer allocation.
- Sample code:
{
return 1;
}
static int32_t pedometer_process_data(
const sensor_data_t *input_list,
void *reserved)
{
while (count != 0) {
data_start++;
count--;
}
return 1;
}
static int32_t pedometer_operate(int32_t command, void *buffer_out, int32_t size_out, \
void *buffer_in, int32_t size_in)
{
return 0;
}
1,
&input_comp_acc,
pedometer_operate,
get_pedometer_result,
pedometer_process_data,
0
};
int pedometer_register()
{
int ret;
if (ret < 0) {
}
if (ret < 0) {
}
return ret;
}
int32_t sensor_fusion_algorithm_notify |
( |
uint32_t |
sensor_type | ) |
|
For fusion algorithm to notify sensor manager of sensor event.
- Parameters
-
[in] | sensor_type | is the specified sensor type. |
- Returns
- >=0, if the operation completed successfully.
int32_t sensor_fusion_algorithm_register_data_buffer |
( |
uint32_t |
sensor_type, |
|
|
uint32_t |
exist_data_count |
|
) |
| |
Registers the required data buffer of fusion algorithm of the specified sensor type.
- Parameters
-
[in] | sensor_type | is the specified sensor type. |
[in] | exist_data_count | is the required data buffer count. |
- Returns
- >=0, if the operation completed successfully.
Registers fusion algorithm of the specified sensor_descriptor.
- Parameters
-
- Returns
- >=0, if the operation completed successfully.