Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avionics
Software Development
Skyward Boardcore
Wiki
SensorManager
Changes
Page history
New page
Templates
Clone repository
Update SensorManager example
authored
5 years ago
by
Luca Conterio
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
SensorManager.md
+11
-4
11 additions, 4 deletions
SensorManager.md
with
11 additions
and
4 deletions
SensorManager.md
View page @
cd14d174
...
...
@@ -113,6 +113,7 @@ class TestSensor : public virtual Sensor
```
### Step 2: Sampling the sensor
Include needed modules, define your sensor and the
`SensorManager`
.
```
cpp
#include
<miosix.h>
#include
<sensors/SensorManager.h>
...
...
@@ -120,14 +121,20 @@ class TestSensor : public virtual Sensor
SensorManager
sensor_manager
;
TestSensor
*
sensor
;
```
Define the callback that will be passed to the
`SensorSampler`
, along with the sensor.
Inside the callback you can get the sampled data from the sensor and perform operations on it.
```
cpp
void
testCallback
()
{
// get the sampled data and
// perform whatever action you want
float
data
=
sensor
->
getData
();
printf
(
"Test data : %f
\n
"
,
data
);
}
```
You use use
`std::bind()`
in order to bind your callback to an
`std::function<void()>>`
object.
Select the required frequency for the sampling and add the sensor and the callback to the
`SensorManager`
.
You can now start the
`SensorManager`
.
```
cpp
int
main
()
{
uint32_t
frequency
=
10
;
// 10 Hz
...
...
This diff is collapsed.
Click to expand it.