... | ... | @@ -4,7 +4,7 @@ Periodically, sensors are sampled and their corresponding callback is called, so |
|
|
|
|
|
## Component Structure
|
|
|
|
|
|
TODO
|
|
|

|
|
|
|
|
|
## Sensor
|
|
|
|
... | ... | @@ -28,19 +28,19 @@ Since these classes are a bit limited, you can always directly extend `Sensor`, |
|
|
|
|
|
Sensors are grouped by type (simple or DMA) and the required sampling frequency.
|
|
|
|
|
|
A `SensorSampler` is characterized by a type (SIMPLE_SAMPLER or DMA_SAMPLER), the sampling frequency and a set of sensors.
|
|
|
A `SensorSampler` is characterized by a type (`SIMPLE_SAMPLER` or `DMA_SAMPLER`), the sampling frequency and a set of sensors.
|
|
|
|
|
|
In particular, the `SensorSampler` class maintains a `map<Sensor*, function<void()>>` that maps each sensor to its corresponding callback function.
|
|
|
Every time the `sampleAndCallback()` method of the `SensorSampler` is called, the sampler cycles through all its sensors, samples them and calls their corresponding callback, where these samples can be processed and dispatched.
|
|
|
|
|
|
## Sensor Manager
|
|
|
In order to add a sensor to the `SensorManager`, the `addSensor()` method is provided: simply pass it the sensor, the required sampling frequency, the callback function and the sampler type (that has default value equal to SIMPLE_SAMPLER).
|
|
|
In order to add a sensor to the `SensorManager`, the `addSensor()` method is provided: simply pass it the sensor, the required sampling frequency, the callback function and the sampler type (that has default value equal to `SIMPLE_SAMPLER`).
|
|
|
|
|
|
Every time a sensor is added, the `SensorManager` assigns it to a `SensorSampler`, according to the required sampling frequency and the sampling type, that can be either SIMPLE or DMA.
|
|
|
Every time a sensor is added, the `SensorManager` assigns it to a `SensorSampler`, according to the required sampling frequency and the sampling type.
|
|
|
If a `SensorSampler` for that frequency and type doesn't exist, the `SensorManager` manages its creation.
|
|
|
|
|
|
Note that when a sensor is added, it is also initialized and its `selftest()` method is called.
|
|
|
The sensor will be added only if both those functions return `true`.
|
|
|
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.
|
|
|
|
|
|
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.
|
|
|
|
... | ... | |