... | @@ -2,7 +2,7 @@ The `SensorManager` component manages all the sensors connected to the board. |
... | @@ -2,7 +2,7 @@ The `SensorManager` component manages all the sensors connected to the board. |
|
|
|
|
|
Sensors are periodically sampled and their corresponding callback is called, so that further operations can be performed on the retrieved data.
|
|
Sensors are periodically sampled and their corresponding callback is called, so that further operations can be performed on the retrieved data.
|
|
|
|
|
|
# Main Elements
|
|
## Main Elements
|
|
|
|
|
|
### Sensor Sampler
|
|
### Sensor Sampler
|
|
|
|
|
... | @@ -28,7 +28,7 @@ The sensor will be added only if both the initialization and the test succeed. |
... | @@ -28,7 +28,7 @@ The sensor will be added only if both the initialization and the test succeed. |
|
|
|
|
|
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 frequency.
|
|
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 frequency.
|
|
|
|
|
|
# Component Behavior
|
|
## Component Behavior
|
|
It might seem tricky and complex, so in order to simplify the understanding we can schematize the component's behavior.
|
|
It might seem tricky and complex, so in order to simplify the understanding we can schematize the component's behavior.
|
|
|
|
|
|
We outline three phases:
|
|
We outline three phases:
|
... | @@ -38,17 +38,17 @@ We outline three phases: |
... | @@ -38,17 +38,17 @@ We outline three phases: |
|
|
|
|
|

|
|

|
|
|
|
|
|
# Component Structure
|
|
## Component Structure
|
|
For simplicity, each arrow in the diagram describes an action and reports the phase number that action belongs to (according to the above defined phases).
|
|
For simplicity, each arrow in the diagram describes an action and reports the phase number that action belongs to (according to the above defined phases).
|
|
|
|
|
|

|
|

|
|
|
|
|
|
# Example
|
|
## Example
|
|
### Step 1: Creating a sensor
|
|
#### Step 1: Creating a sensor
|
|
This example refers to the `TestSensor` class defined in [Sensor](Sensor).
|
|
This example refers to the `TestSensor` class defined in [Sensor](Sensor).
|
|
For more details see how to create a sensor, visit that page.
|
|
For more details see how to create a sensor, visit that page.
|
|
|
|
|
|
### Step 2: Sampling the sensor
|
|
#### Step 2: Sampling the sensor
|
|
Include needed modules, define your sensor and the `SensorManager`.
|
|
Include needed modules, define your sensor and the `SensorManager`.
|
|
```cpp
|
|
```cpp
|
|
#include <miosix.h>
|
|
#include <miosix.h>
|
... | | ... | |