Skip to content

Commit

Permalink
add asume callibration function to compass
Browse files Browse the repository at this point in the history
  • Loading branch information
JW committed Sep 6, 2021
1 parent d8c12e6 commit 75e04bd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions inc/drivers/MicroBitCompass.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ class MicroBitCompass : public MicroBitComponent
*/
void clearCalibration();

/**
* Assumes the calibration held in persistent storage, and sets the calibrated flag to 1.
*/
void assumeCalibration();


/**
* Configures the device for the sample rate defined
Expand Down
12 changes: 10 additions & 2 deletions source/drivers/MicroBitCompass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ void MicroBitCompass::init(uint16_t id)
this->samplePeriod = 100;
this->configure();

// Assume that we have calibration information.
status |= MICROBIT_COMPASS_STATUS_CALIBRATED;
// Assume that we have no calibration information.
status &= ~MICROBIT_COMPASS_STATUS_CALIBRATED;

// Indicate that we're up and running.
status |= MICROBIT_COMPONENT_RUNNING;
Expand Down Expand Up @@ -305,6 +305,14 @@ void MicroBitCompass::clearCalibration()
status &= ~MICROBIT_COMPASS_STATUS_CALIBRATED;
}

/**
* Assumes the calibration held in memory storage, and sets the calibrated flag to 1.
*/
void MicroBitCompass::assumeCalibration()
{
status |= MICROBIT_COMPASS_STATUS_CALIBRATED;
}

/**
* Configures the device for the sample rate defined
* in this object. The nearest values are chosen to those defined
Expand Down

0 comments on commit 75e04bd

Please sign in to comment.