Fix compass doc errors (#721)

* Fix compass doc errors

* Another heading point error
This commit is contained in:
Galen Nickel 2018-03-27 15:02:38 -07:00 committed by Peli de Halleux
parent f70665d1a0
commit 0ec922c7f4
3 changed files with 14 additions and 13 deletions

View File

@ -15,18 +15,19 @@ The following example constantly checks the
and updates the screen with the direction. and updates the screen with the direction.
```blocks ```blocks
let degrees = 0
basic.forever(() => { basic.forever(() => {
let heading = input.compassHeading() degrees = input.compassHeading()
if (heading < 45) { if (degrees < 45) {
basic.showString("N") basic.showString("N")
} else if (heading < 135) { } else if (degrees < 135) {
basic.showString("E") basic.showString("E")
} } else if (degrees < 225) {
else if (heading < 225) {
basic.showString("S") basic.showString("S")
} } else if (degrees < 315) {
else {
basic.showString("W") basic.showString("W")
} else {
basic.showString("N")
} }
}) })
``` ```

View File

@ -2,7 +2,7 @@
Find which direction on a compass the @boardname@ is facing. Find which direction on a compass the @boardname@ is facing.
The @boardname@ measures the **compass heading** from `0` to `360` The @boardname@ measures the **compass heading** from `0` to `359`
degrees with its **magnetometer** chip. Different numbers mean north, degrees with its **magnetometer** chip. Different numbers mean north,
east, south, and west. east, south, and west.
@ -12,7 +12,7 @@ input.compassHeading();
## Returns ## Returns
* a [number](/types/number) from `0` to `360` degrees, which means the compass heading. If the compass isn't ready, it returns `-1003`. * a [number](/types/number) from `0` to `359` degrees, which means the compass heading. If the compass isn't ready, it returns `-1003`.
## Example ## Example
@ -43,11 +43,11 @@ basic.forever(() => {
if (degrees < 45) { if (degrees < 45) {
basic.showArrow(ArrowNames.North) basic.showArrow(ArrowNames.North)
} else if (degrees < 135) { } else if (degrees < 135) {
basic.showArrow(ArrowNames.West) basic.showArrow(ArrowNames.East)
} else if (degrees < 225) { } else if (degrees < 225) {
basic.showArrow(ArrowNames.South) basic.showArrow(ArrowNames.South)
} else if (degrees < 315) { } else if (degrees < 315) {
basic.showArrow(ArrowNames.East) basic.showArrow(ArrowNames.West)
} else { } else {
basic.showArrow(ArrowNames.North) basic.showArrow(ArrowNames.North)
} }

View File

@ -35,11 +35,11 @@ basic.forever(() => {
if (degrees < 45) { if (degrees < 45) {
basic.showArrow(ArrowNames.North) basic.showArrow(ArrowNames.North)
} else if (degrees < 135) { } else if (degrees < 135) {
basic.showArrow(ArrowNames.West) basic.showArrow(ArrowNames.East)
} else if (degrees < 225) { } else if (degrees < 225) {
basic.showArrow(ArrowNames.South) basic.showArrow(ArrowNames.South)
} else if (degrees < 315) { } else if (degrees < 315) {
basic.showArrow(ArrowNames.East) basic.showArrow(ArrowNames.West)
} else { } else {
basic.showArrow(ArrowNames.North) basic.showArrow(ArrowNames.North)
} }