Map and clean deprecated functions (#175)

* add image and deprecated arrow functions

* update locales

* map basic.showArrow

* map arrow blocks

* map & remove arrow images

* remove arrow blocks

* update locales

* remove & patch:
rgbw -> rgb
button/pin pressed -> button/pin event
loudness -> soundLevel

* update ts mappings for arrows

* add wip ts patch rules

* update .blocks files

* use Click instead of Down as default in Documentation and tests

* patch test.blocks

* fix lowercase name tag

* update test.blocks

* update blocks test files

* update blocks test files

* format block files

* pass blocks file tests

* fix ts mapping

* fix color.defl value

closes https://github.com/microsoft/pxt-calliope/issues/136

* fix ts mappings

- add optional spacing at the end of rgbw()
- map up to v4.0.19

* add suggested changes

* replace innerText by textContent

Co-authored-by: JW <gitkraken@juriwolf.de>
Co-authored-by: Juri <info@juriwolf.de>
This commit is contained in:
Juri Wolf
2022-04-26 19:28:42 +02:00
committed by GitHub
parent 3b9d90e551
commit a93febb5b7
102 changed files with 1458 additions and 740 deletions

View File

@@ -18,7 +18,7 @@ basic.forever(() => {
});
basic.pause(100);
basic.showArrow(ArrowNames.North);
basic.showIcon(IconNames.ArrowNorth);
```
## See also
@@ -27,4 +27,4 @@ basic.showArrow(ArrowNames.North);
[showIcon](/reference/basic/show-icon),
[showLeds](/reference/basic/show-leds), [showString](/reference/basic/show-string),
[clearScreen](/reference/basic/clear-screen), [forever](/reference/basic/forever), [pause](/reference/basic/pause),
[showArrow](/reference/basic/show-arrow), [showAnimation](/reference/basic/show-animation)
[showAnimation](/reference/basic/show-animation)

View File

@@ -43,7 +43,7 @@ let num = 0
basic.forever(() => {
basic.showNumber(num)
})
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
num = num + 1
})
```
@@ -59,7 +59,7 @@ Try this on your @boardname@:
basic.forever(() => {
basic.showNumber(6789)
})
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
basic.showNumber(2)
})
```

View File

@@ -1,29 +0,0 @@
# Show Arrow
Shows the selected arrow on the LED screen
```sig
basic.showArrow(ArrowNames.North)
```
## Parameters
* ``direction``, the identifier of the arrow to display
* ``interval`` (optional), the time to display in milliseconds. default is 400.
## Example
This program shows all eight arrows.
```blocks
for (let index = 0; index <= 7; index++) {
basic.showArrow(index)
basic.pause(300)
}
```
## See also
[showIcon](/reference/basic/show-icon),
[showLeds](/reference/basic/show-leds)

View File

@@ -24,7 +24,7 @@ bluetooth.stopAdvertising();
## Example: stop advertising on button pressed
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
bluetooth.stopAdvertising();
})
```

View File

@@ -27,7 +27,7 @@ bluetooth.onBluetoothDisconnected(() => {
basic.showString("D");
connected = 0;
});
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
if (connected == 1) {
bluetooth.uartWriteLine("HELLO");
}

View File

@@ -27,7 +27,7 @@ bluetooth.onBluetoothDisconnected(() => {
basic.showString("D");
connected = 0;
});
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
if (connected == 1) {
bluetooth.uartWriteString("HELLO");
}

View File

@@ -29,7 +29,7 @@ control.inBackground(() => {
basic.pause(100)
}
})
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
num++;
})
```
@@ -42,7 +42,7 @@ let num = 0
basic.forever(() => {
basic.showNumber(num)
})
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
num++;
})
```

View File

@@ -24,11 +24,11 @@ When you get tired of counting, press button `B` to reset the
```blocks
let item = 0;
basic.showNumber(item);
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
item = item + 1;
basic.showNumber(item);
});
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Down, () => {
control.reset();
});
```

View File

@@ -9,7 +9,7 @@ An event handler is code that is associated with a particular event, such as "bu
Functions named "on <event>" create an association between an event and the event handler code. For example, the following code registers the event handler (the code between the `do` and `end` keywords) with the event of a press of button A:
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
basic.showString("hello", 150)
})
```
@@ -21,7 +21,7 @@ After this code executes, then whenever button A is pressed in the future, the s
Once you have registered an event handler for an event, like above, that event handler is active for the rest of the program execution. If you want to stop the string "hello" from printing each time button A is pressed then you need to arrange for the following code to execute:
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
})
```
@@ -32,10 +32,10 @@ The above code associated an event handler that does nothing with the event of a
The above example also illustrates that there is only one event handler for each event. What is the result of the following code?
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
basic.showString("hello", 150)
})
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
basic.showString("goodbye", 150)
})
```
@@ -43,7 +43,7 @@ input.onButtonPressed(Button.A, () => {
The answer is that whenever button A is pressed, the string "goodbye" will be printed. If you want both the strings "hello" and "goodbye" to be printed, you need to write the code like this:
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
basic.showString("hello", 150)
basic.showString("goodbye", 150)
})

View File

@@ -16,11 +16,11 @@ Press button ``A`` as much as possible to increase the score.
Press ``B`` to display the score and reset the score.
```blocks
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Down, () => {
basic.showNumber(game.score())
game.setScore(0)
})
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
game.addScore(1)
})
```

View File

@@ -16,7 +16,7 @@ Press button ``A`` as much as possible.
At the end of 10 seconds, the program will show your score.
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
game.addScore(1)
})
game.startCountdown(10000)

View File

@@ -27,7 +27,7 @@ let img = images.createImage(`
. . . . .
`)
img.showImage(0)
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
img.clear()
img.showImage(0)
})

View File

@@ -14,10 +14,10 @@ If you press button `B`, it shows an animation and ends the game.
```blocks
basic.showString("PICK A BUTTON");
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
basic.showString("YOU WIN!");
});
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Down, () => {
game.gameOver();
});
```

View File

@@ -20,7 +20,7 @@ degrees -- exactly the opposite direction.
```blocks
let ball = game.createSprite(4, 2);
basic.showNumber(ball.get(LedSpriteProperty.Direction));
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Down, () => {
ball.ifOnEdgeBounce();
basic.showNumber(ball.get(LedSpriteProperty.Direction));
});

View File

@@ -15,7 +15,7 @@ game.isPaused()
Resume the game if it's paused and button **B** is pressed.
```blocks
input.onButtonPressed(Button.B, function () {
input.onButtonEvent(Button.B, ButtonEvent.Down, function () {
if (game.isPaused()) {
game.resume()
}

View File

@@ -15,7 +15,7 @@ game.isRunning()
If the game is currently running, end the game if button **B** is pressed.
```blocks
input.onButtonPressed(Button.B, function () {
input.onButtonEvent(Button.B, ButtonEvent.Click, function () {
if (game.isRunning()) {
game.gameOver()
}

View File

@@ -13,7 +13,7 @@ This program adds one point to your score every time you press button
second) and shows your score.
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Down, () => {
game.addScore(1);
basic.pause(500);
basic.showNumber(game.score());

View File

@@ -16,11 +16,11 @@ Press button ``A`` as much as possible to increase the score.
Press ``B`` to display the score and reset the score.
```blocks
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
basic.showNumber(game.score())
game.setScore(0)
})
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
game.addScore(1)
})
```

View File

@@ -17,7 +17,7 @@ Press button ``A`` as much as possible.
At the end of 10 seconds, the program will show your score.
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
game.addScore(1)
})
game.startCountdown(10000)

View File

@@ -19,14 +19,12 @@ images.createBigImage(`
`);
images.createImage(``).showImage(0);
images.createImage(``).scrollImage(0,0);
images.arrowImage(ArrowNames.North)
images.iconImage(IconNames.Heart)
images.arrowNumber(ArrowNames.North)
```
## See Also
[createImage](/reference/images/create-image), [createBigImage](/reference/images/create-big-image),
[showImage](/reference/images/show-image), [scrollImage](/reference/images/scroll-image),
[arrowImage](/reference/images/arrow-image), [iconImage](/reference/images/icon-image), [arrowNumber](/reference/images/arrow-number),
[iconImage](/reference/images/icon-image),
[pixel](/reference/images/pixel), [set-pixel](/reference/images/set-pixel)

View File

@@ -1,41 +0,0 @@
# arrow Image
Create an arrow shaped [image](/reference/images/image) for the [LED screen](/device/screen).
```sig
images.arrowImage(ArrowNames.North)
```
The arrow points in the direction of the arrow name you choose, like `North`.
## Parameters
* **i**: the arrow name to make an arrow [image](/reference/images/image) for. You can make an arrow image that points in one of these directions:
>* `North`
>* `NorthEast`
>* `East`
>* `SouthEast`
>* `South`
>* `SouthWest`
>* `West`
>* `NorthWest`
## Example
Display a left arrow when button A is pressed or a right arrow when button B is pressed.
```blocks
let arrowLeft = images.arrowImage(ArrowNames.West)
let arrowRight = images.arrowImage(ArrowNames.East)
input.onButtonPressed(Button.A, () => {
arrowLeft.showImage(0);
});
input.onButtonPressed(Button.B, () => {
arrowRight.showImage(0);
});
```
## See also
[arrow number](/reference/images/arrow-number)

View File

@@ -1,33 +0,0 @@
# arrow Number
Get the number that matches an arrow image name.
```sig
images.arrowNumber(ArrowNames.North)
```
Each arrow image name has a number for it. You can find the number for any arrow name with ``||Images:arrow number||``.
## Parameters
* **arrow**: the arrow name to get an arrow number for. These are the arrow names:
>* `North`
* `NorthEast`
* `East`
* `SouthEast`
* `South`
* `SouthWest`
* `West`
* `NorthWest`
## Example
Get the arrow number for `ArrowNames.South`.
```blocks
let arrowSouthNumber = images.arrowNumber(ArrowNames.South)
```
## See also
[arrow image](/reference/images/arrow-image)

View File

@@ -36,10 +36,10 @@ let arrows = images.createBigImage(`
. . # . . . # # # .
. . # . . . . # . .
`);
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
arrows.showImage(0);
});
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
arrows.showImage(5);
});
```

View File

@@ -25,7 +25,7 @@ arrow and show it on the LED screen. If you press button `B`, the
program will show a picture of the arrow upside-down.
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
images.createImage(`
. . # . .
. # # # .
@@ -34,7 +34,7 @@ input.onButtonPressed(Button.A, () => {
. . # . .
`).showImage(0);
});
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
images.createImage(`
. . # . .
. . # . .

View File

@@ -20,10 +20,10 @@ Show a happy face when button A is pressed or a sad face when button B is presse
let iamHappy = images.iconImage(IconNames.Happy)
let iamSad = images.iconImage(IconNames.Sad)
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
iamHappy.showImage(0);
});
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
iamSad.showImage(0);
});
```

View File

@@ -31,10 +31,10 @@ let arrows = images.createBigImage(`
. . # . . . # # # .
. . # . . . . # . .
`);
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
arrows.showImage(0);
});
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
arrows.showImage(5);
});
```

View File

@@ -3,13 +3,13 @@
Events and data from sensors
```cards
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
});
input.onGesture(Gesture.Shake, () => {
});
input.onPinPressed(TouchPin.P0, () => {
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Click, () => {
});
input.buttonIsPressed(Button.A);

View File

@@ -23,7 +23,7 @@ confuse the @boardname@.
This example runs the calibration when the user presses **A+B** buttons.
```blocks
input.onButtonPressed(Button.AB, () => {
input.onButtonEvent(Button.AB, ButtonEvent.Click, () => {
input.calibrateCompass();
})
```

View File

@@ -41,15 +41,15 @@ let degrees = 0
basic.forever(() => {
degrees = input.compassHeading()
if (degrees < 45) {
basic.showArrow(ArrowNames.North)
basic.showIcon(IconNames.ArrowNorth)
} else if (degrees < 135) {
basic.showArrow(ArrowNames.East)
basic.showIcon(IconNames.ArrowEast)
} else if (degrees < 225) {
basic.showArrow(ArrowNames.South)
basic.showIcon(IconNames.ArrowSouth)
} else if (degrees < 315) {
basic.showArrow(ArrowNames.West)
basic.showIcon(IconNames.ArrowWest)
} else {
basic.showArrow(ArrowNames.North)
basic.showIcon(IconNames.ArrowNorth)
}
})
```
@@ -70,7 +70,7 @@ confuse the @boardname@.
Keep the calibration handy by running it when the user pressed **A+B**.
```block
input.onButtonPressed(Button.AB, () => {
input.onButtonEvent(Button.AB, ButtonEvent.Click, () => {
input.calibrateCompass();
})
```

View File

@@ -29,7 +29,7 @@ program shows the light level
on the [LED screen](/device/screen).
```blocks
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
let level = input.lightLevel()
basic.showNumber(level)
})

View File

@@ -9,7 +9,7 @@ on the @boardname@.
* For `A` and `B` together: This handler works when `A` and `B` are both pushed down, then one of them is released within 1.5 seconds of pushing down the second button.
```sig
input.onButtonPressed(Button.A, () => {})
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {})
```
Find out how buttons provide input to the @boardname@ in this video:
@@ -24,7 +24,7 @@ Each time you press the button, the [LED screen](/device/screen) shows the `coun
```blocks
let count = 0
basic.showNumber(count)
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
count++;
basic.showNumber(count);
})
@@ -35,7 +35,7 @@ input.onButtonPressed(Button.A, () => {
This example shows a number from 1 to 6 when you press the `B` button.
```blocks
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
let dice = randint(0, 5) + 1
basic.showNumber(dice)
})

View File

@@ -14,7 +14,7 @@ through your body and back into the @boardname@. This is called
**completing a circuit**. It's like you're a big wire!
```sig
input.onPinPressed(TouchPin.P0, () => {
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Click, () => {
})
```
@@ -43,7 +43,7 @@ Every time you press the pin, the program shows the number of times on the scree
```blocks
let count = 0
basic.showNumber(count)
input.onPinPressed(TouchPin.P0, () => {
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Click, () => {
count = count + 1
basic.showNumber(count)
})

View File

@@ -13,7 +13,7 @@ through your body and back into the @boardname@. This is called
**completing a circuit**. It's like you're a big wire!
```sig
input.onPinReleased(TouchPin.P0, () => {
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Up, () => {
})
```
@@ -36,7 +36,7 @@ Every time you release the pin, the program shows the number of times on the scr
```blocks
let count = 0
basic.showNumber(count, 100)
input.onPinReleased(TouchPin.P0, () => {
input.onPinTouchEvent(TouchPin.P0, ButtonEvent.Up, () => {
count = count + 1
basic.showNumber(count, 100)
})

View File

@@ -18,7 +18,7 @@ program finds the number of milliseconds since the program started
and shows it on the [LED screen](/device/screen).
```blocks
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
let now = input.runningTime()
basic.showNumber(now)
})

View File

@@ -15,7 +15,7 @@ led.enable(false);
This program turns off the screen when pressing button ``B``
```blocks
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
led.enable(false)
});
```

View File

@@ -13,7 +13,7 @@ This program sets up the ``stop animation`` part of the program,
and then shows a string that you can stop with button ``B``.
```blocks
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
led.stopAnimation();
});
basic.showString("STOP ME! STOP ME! PLEASE, WON'T SOMEBODY STOP ME?");

View File

@@ -43,7 +43,7 @@ music.onEvent(MusicEvent.BackgroundMelodyResumed, () => {
music.onEvent(MusicEvent.BackgroundMelodyRepeated, () => {
serial.writeLine("background repeated")
})
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
music.beginMelody(music.builtInMelody(Melodies.BaDing), MelodyOptions.Once)
})
music.setTempo(100)

View File

@@ -17,7 +17,7 @@ This example send the frequency and duration over radio
and plays it on the remote @boardname@.
```typescript
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
music.playTone(440, 120)
led.toggle(0, 0)
})
@@ -26,7 +26,7 @@ radio.onReceivedNumber(function (receivedNumber) {
const duration = receivedNumber & 0xffff;
music.playTone(freq, duration);
})
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
music.setPlayTone((frequency: number, duration: number) => {
radio.sendNumber((frequency << 16) | (duration & 0xffff));
})

View File

@@ -48,7 +48,7 @@ keeper @boardname@, you can press button `B` on the remote to buzz and
make the score bigger on the other @boardname@.
```blocks
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
pins.digitalWritePin(DigitalPin.P1, 1);
basic.pause(500);
pins.digitalWritePin(DigitalPin.P1, 0);

View File

@@ -46,7 +46,7 @@ will use ``digital write pin`` to make the other @boardname@ buzz and
make the score bigger.
```blocks
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
pins.digitalWritePin(DigitalPin.P1, 1);
basic.pause(500);
pins.digitalWritePin(DigitalPin.P1, 0);

View File

@@ -34,7 +34,7 @@ If you load this program onto two or more @boardname@s, you can send a code word
The other @boardname@s will receive the code word and then show it.
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
radio.sendString("Codeword: TRIMARAN")
basic.showString("SENT");
})
@@ -59,10 +59,10 @@ This program will also receive your friend's mood.
```blocks
let data: string = "";
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
radio.sendString("H");
});
input.onButtonPressed(Button.B, () => {
input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
radio.sendString("S");
});
radio.onDataReceived(() => {

View File

@@ -27,7 +27,7 @@ in the `x` direction (left and right) to other @boardname@s. This kind
of program might be useful in a model car or model rocket.
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
radio.sendNumber(input.acceleration(Dimension.X))
})
```

View File

@@ -26,7 +26,7 @@ code word from one of them to the others by pressing button `A`. The
other @boardname@s will receive the code word and then show it.
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
radio.sendString("Codeword: TRIMARAN")
basic.showString("SENT");
})

View File

@@ -29,7 +29,7 @@ or model rocket.
```blocks
radio.setGroup(99)
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
radio.sendValue("acc", input.acceleration(Dimension.X))
})
```

View File

@@ -30,7 +30,7 @@ the second @boardname@), this program sends temperature data to the
serial port.
```blocks
input.onButtonPressed(Button.A, function () {
input.onButtonEvent(Button.A, ButtonEvent.Click, function () {
radio.sendNumber(input.temperature())
radio.sendValue("temp", input.temperature())
radio.sendString("It's warm now")

View File

@@ -29,7 +29,7 @@ the second @boardname@), this program sends temperature data to
serial.
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
radio.sendNumber(input.temperature());
});
radio.onDataReceived(() => {

View File

@@ -32,7 +32,7 @@ serial port to use the pins. The new configuration uses pin ``P1`` to transmit a
``P2`` to receive. The baud rate is set to `9600`.
```blocks
input.onButtonPressed(Button.A, () => {
input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
serial.redirect(SerialPin.P1, SerialPin.P2, BaudRate.BaudRate9600);
});
```

View File

@@ -34,19 +34,19 @@ let direction = ""
basic.forever(() => {
degrees = input.compassHeading()
if (degrees < 45) {
basic.showArrow(ArrowNames.North)
basic.showIcon(IconNames.ArrowNorth)
direction = "North"
} else if (degrees < 135) {
basic.showArrow(ArrowNames.East)
basic.showIcon(IconNames.ArrowEast)
direction = "East"
} else if (degrees < 225) {
basic.showArrow(ArrowNames.South)
basic.showIcon(IconNames.ArrowSouth)
direction = "South"
} else if (degrees < 315) {
basic.showArrow(ArrowNames.West)
basic.showIcon(IconNames.ArrowWest)
direction = "West"
} else {
basic.showArrow(ArrowNames.North)
basic.showIcon(IconNames.ArrowNorth)
direction = "North"
}
serial.writeLine(direction + " @ " + degrees + " degrees")