Calibrate compass (#392)

* adding 'calibrate-compass' function

* fixing simulator.

* updated docs

* fixing compat test suite with 'calibrate()' function
This commit is contained in:
Peli de Halleux
2017-04-25 10:46:25 -07:00
committed by GitHub
parent a6ec23b76f
commit bd895f43ba
12 changed files with 68 additions and 14 deletions

View File

@ -22,7 +22,6 @@ input.rotation(Rotation.Pitch);
input.magneticForce(Dimension.X);
input.runningTime();
input.setAccelerometerRange(AcceleratorRange.OneG);
input.calibrate();
input.onLogoDown(() => {
});
@ -42,4 +41,4 @@ input.onShake(() => {
### See Also
[onButtonPressed](/reference/input/on-button-pressed), [onGesture](/reference/input/on-gesture), [onPinPressed](/reference/input/on-pin-pressed), [buttonIsPressed](/reference/input/button-is-pressed), [compassHeading](/reference/input/compass-heading), [pinIsPressed](/reference/input/pin-is-pressed), [temperature](/reference/input/temperature), [acceleration](/reference/input/acceleration), [lightLevel](/reference/input/light-level), [rotation](/reference/input/rotation), [magneticForce](/reference/input/magnetic-force), [runningTime](/reference/input/running-time), [setAccelerometerRange](/reference/input/set-accelerometer-range)
[onButtonPressed](/reference/input/on-button-pressed), [onGesture](/reference/input/on-gesture), [onPinPressed](/reference/input/on-pin-pressed), [buttonIsPressed](/reference/input/button-is-pressed), [compassHeading](/reference/input/compass-heading), [pinIsPressed](/reference/input/pin-is-pressed), [temperature](/reference/input/temperature), [acceleration](/reference/input/acceleration), [lightLevel](/reference/input/light-level), [rotation](/reference/input/rotation), [magneticForce](/reference/input/magnetic-force), [runningTime](/reference/input/running-time), [setAccelerometerRange](/reference/input/set-accelerometer-range), [calibrate-compass](/reference/input/calibrate-compass)

View File

@ -0,0 +1,29 @@
# Calibrate Compass
Runs the compass calibration sequence.
```sig
input.calibrateCompass();
```
### Calibration
The calibration will ask you to draw a circle by tilting the
@boardname@.
If you are calibrating or using the compass near metal, it might
confuse the @boardname@.
### Example
This example runs the calibration when the user presses **A+B** buttons.
```blocks
input.onButtonPressed(Button.AB, () => {
input.calibrateCompass();
})
```
### See also
[compassHeading](/reference/input/compass-heading)

View File

@ -52,13 +52,25 @@ basic.forever(() => {
### Calibration
Every time you start to use the compass (for example, if you have just
turned the @boardname@ on), the @boardname@ will start to **calibrate**
turned the @boardname@ on), the @boardname@ will start to [calibrateCompass](/reference/input/calibrate-compass)
(adjust itself). It will ask you to draw a circle by tilting the
@boardname@.
If you are calibrating or using the compass near metal, it might
confuse the @boardname@.
### ~ hint
Keep the calibration handy by running it when the user pressed **A+B**.
```block
input.onButtonPressed(Button.AB, () => {
input.calibrateCompass();
})
```
### ~
### See also
[acceleration](/reference/input/acceleration)
[acceleration](/reference/input/acceleration), [calibrateCompass](/reference/input/calibrate-compass)

View File

@ -10,8 +10,6 @@ music.beat(BeatFraction.Whole);
music.tempo();
music.changeTempoBy(20);
music.setTempo(120);
music.onEvent(MusicEvent.MelodyNotePlayed, () => {});
music.setPlayTone((freq, ms) => {});
```
### See Also

View File

@ -4,7 +4,7 @@ Replaces the implementation of the [music play tone](/reference/music/play-tone)
```sig
music.setPlayTone((freq, ms) => {})
music.setPlayTone((frequency: number, duration: number) => {})
```
### Parameters