fsdfds
Dependencies: BLE_API mbed-dev-bin nRF51822
Fork of microbit-dal by
MicroBitCompassCalibrator.h
00001 /* 00002 The MIT License (MIT) 00003 00004 Copyright (c) 2016 British Broadcasting Corporation. 00005 This software is provided by Lancaster University by arrangement with the BBC. 00006 00007 Permission is hereby granted, free of charge, to any person obtaining a 00008 copy of this software and associated documentation files (the "Software"), 00009 to deal in the Software without restriction, including without limitation 00010 the rights to use, copy, modify, merge, publish, distribute, sublicense, 00011 and/or sell copies of the Software, and to permit persons to whom the 00012 Software is furnished to do so, subject to the following conditions: 00013 00014 The above copyright notice and this permission notice shall be included in 00015 all copies or substantial portions of the Software. 00016 00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 00020 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00021 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00022 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 00023 DEALINGS IN THE SOFTWARE. 00024 */ 00025 00026 #ifndef MICROBIT_COMPASS_CALIBRATOR_H 00027 #define MICROBIT_COMPASS_CALIBRATOR_H 00028 00029 #include "MicroBitConfig.h" 00030 #include "MicroBitCompass.h" 00031 #include "MicroBitAccelerometer.h" 00032 #include "MicroBitDisplay.h" 00033 00034 00035 /** 00036 * Class definition for an interactive compass calibration algorithm. 00037 * 00038 * The algorithm uses an accelerometer to ensure that a broad range of sample data has been gathered 00039 * from the compass module, then performs a least mean squares optimisation of the 00040 * results to determine the calibration data for the compass. 00041 * 00042 * The LED matrix display is used to provide feedback to the user on the gestures required. 00043 * 00044 * This class listens for calibration requests from the compass (on the default event model), 00045 * and automatically initiates a calibration sequence as necessary. 00046 */ 00047 class MicroBitCompassCalibrator 00048 { 00049 MicroBitCompass& compass; 00050 MicroBitAccelerometer& accelerometer; 00051 MicroBitDisplay& display; 00052 00053 public: 00054 00055 /** 00056 * Constructor. 00057 * 00058 * Create an object capable of calibrating the compass. 00059 * 00060 * The algorithm uses an accelerometer to ensure that a broad range of sample data has been gathered 00061 * from the compass module, then performs a least mean squares optimisation of the 00062 * results to determine the calibration data for the compass. 00063 * 00064 * The LED matrix display is used to provide feedback to the user on the gestures required. 00065 * 00066 * @param compass The compass instance to calibrate. 00067 * 00068 * @param accelerometer The accelerometer to gather contextual data from. 00069 * 00070 * @param display The LED matrix to display user feedback on. 00071 */ 00072 MicroBitCompassCalibrator(MicroBitCompass& _compass, MicroBitAccelerometer& _accelerometer, MicroBitDisplay& _display); 00073 00074 /** 00075 * Performs a simple game that in parallel, calibrates the compass. 00076 * 00077 * This function is executed automatically when the user requests a compass bearing, and compass calibration is required. 00078 * 00079 * This function is, by design, synchronous and only returns once calibration is complete. 00080 */ 00081 void calibrate(MicroBitEvent); 00082 }; 00083 00084 #endif
Generated on Wed Jul 13 2022 00:58:03 by 1.7.2