| ... | ... | @@ -5,7 +5,7 @@ Sensors are periodically sampled and their corresponding callback is called, so |
|
|
|
## Main Elements
|
|
|
|
|
|
|
|
### Sensor Info
|
|
|
|
The `SensorInfo` strucutre defines an information set needed by the `SensorManager` along with the sensor itself
|
|
|
|
The `SensorInfo` structure defines an information set needed by the `SensorManager` along with the sensor itself
|
|
|
|
|
|
|
|
It contains:
|
|
|
|
* The sampling period for the given sensor.
|
| ... | ... | @@ -33,8 +33,8 @@ In order to add sensors to the `SensorManager` a map correlating each sensor to |
|
|
|
When the `SensorManager` is instantiated, each sensor is assigned to a `SensorSampler`, according to the required sampling period and the sampling type (DMA or not).
|
|
|
|
If a `SensorSampler` for that sampling period and type doesn't exist, the `SensorManager` manages its creation.
|
|
|
|
|
|
|
|
Note that when a sensor is added, it is also initialized (via `init()`) and `selfTest()` is performed.
|
|
|
|
The sensor will be added only if both the initialization and the test succeed.
|
|
|
|
Note that when a sensor is added to a sampler, it is also initialized (via `init()`) and `selfTest()` is performed.
|
|
|
|
The `is_initialized` boolean in `SensorInfo` is set to `true` or `false` according to the result of the `init()` and `selfTest()`. If a sensor fails to initialize, it will not be sampled.
|
|
|
|
|
|
|
|
When `start()` is called, the `SensorManager` initializes the `TaskScheduler`: for each `SensorSampler`, it adds to the scheduler the `sampleAndCallback()` method to be called periodically according to the sampler's period.
|
|
|
|
Samplers with lower period are added to the `TaskScheduler` before the ones that have higher period (see `TaskScheduler`'s warning).
|
| ... | ... | |