mbed.org local branch of microbit-dal. The real version lives in git at https://github.com/lancaster-university/microbit-dal

Dependencies:   BLE_API nRF51822 mbed-dev-bin

Dependents:   microbit Microbit IoTChallenge1 microbit ... more

Embed: (wiki syntax)

« Back to documentation index

MicroBitCompassCalibrator Class Reference

MicroBitCompassCalibrator Class Reference

Class definition for an interactive compass calibration algorithm. More...

#include <MicroBitCompassCalibrator.h>

Public Member Functions

 MicroBitCompassCalibrator (MicroBitCompass &_compass, MicroBitAccelerometer &_accelerometer, MicroBitDisplay &_display)
 Constructor.
void calibrate (MicroBitEvent)
 Performs a simple game that in parallel, calibrates the compass.

Detailed Description

Class definition for an interactive compass calibration algorithm.

The algorithm uses an accelerometer to ensure that a broad range of sample data has been gathered from the compass module, then performs a least mean squares optimisation of the results to determine the calibration data for the compass.

The LED matrix display is used to provide feedback to the user on the gestures required.

This class listens for calibration requests from the compass (on the default event model), and automatically initiates a calibration sequence as necessary.

Definition at line 47 of file MicroBitCompassCalibrator.h.


Constructor & Destructor Documentation

MicroBitCompassCalibrator ( MicroBitCompass _compass,
MicroBitAccelerometer _accelerometer,
MicroBitDisplay _display 
)

Constructor.

Create an object capable of calibrating the compass.

The algorithm uses an accelerometer to ensure that a broad range of sample data has been gathered from the compass module, then performs a least mean squares optimisation of the results to determine the calibration data for the compass.

The LED matrix display is used to provide feedback to the user on the gestures required.

Parameters:
compassThe compass instance to calibrate.
accelerometerThe accelerometer to gather contextual data from.
displayThe LED matrix to display user feedback on.

Definition at line 48 of file MicroBitCompassCalibrator.cpp.


Member Function Documentation

void calibrate ( MicroBitEvent   )

Performs a simple game that in parallel, calibrates the compass.

This function is executed automatically when the user requests a compass bearing, and compass calibration is required.

This function is, by design, synchronous and only returns once calibration is complete.

Definition at line 61 of file MicroBitCompassCalibrator.cpp.