2.1.28, initiation update to PXT v5.28.24 (#54)
This commit is contained in:
committed by
Peli de Halleux
parent
38a964516e
commit
5c114a0c57
@ -6,7 +6,7 @@ Turn off all the LED lights on the [LED screen](/device/screen).
|
||||
basic.clearScreen()
|
||||
```
|
||||
|
||||
### Example: Vanishing heart
|
||||
## Example: Vanishing heart
|
||||
|
||||
The following code shows a heart on the screen and then turns off all the LED lights.
|
||||
|
||||
@ -21,7 +21,7 @@ basic.showLeds(`
|
||||
basic.clearScreen()
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[set brightness](/reference/led/set-brightness), [unplot](/reference/led/unplot), [plot](/reference/led/plot), [Image](/reference/images/image)
|
||||
|
||||
|
@ -8,46 +8,47 @@ basic.forever(() => {
|
||||
})
|
||||
```
|
||||
|
||||
### Example: compass
|
||||
## Example: compass
|
||||
|
||||
The following example constantly checks the
|
||||
[compass heading](/reference/input/compass-heading)
|
||||
and updates the screen with the direction.
|
||||
|
||||
```blocks
|
||||
let degrees = 0
|
||||
basic.forever(() => {
|
||||
let heading = input.compassHeading()
|
||||
if (heading < 45) {
|
||||
basic.showString("N", 100)
|
||||
} else if (heading < 135) {
|
||||
basic.showString("E", 100)
|
||||
}
|
||||
else if (heading < 225) {
|
||||
basic.showString("S", 100)
|
||||
}
|
||||
else {
|
||||
basic.showString("W", 100)
|
||||
degrees = input.compassHeading()
|
||||
if (degrees < 45) {
|
||||
basic.showString("N")
|
||||
} else if (degrees < 135) {
|
||||
basic.showString("E")
|
||||
} else if (degrees < 225) {
|
||||
basic.showString("S")
|
||||
} else if (degrees < 315) {
|
||||
basic.showString("W")
|
||||
} else {
|
||||
basic.showString("N")
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
### Example: counter
|
||||
## Example: counter
|
||||
|
||||
The following example keeps showing the [number](/reference/types/number) stored in a global variable.
|
||||
The following example keeps showing the [number](/types/number) stored in a global variable.
|
||||
When you press button `A`, the number gets bigger.
|
||||
You can use a program like this to count things with your @boardname@.
|
||||
|
||||
```blocks
|
||||
let num = 0
|
||||
basic.forever(() => {
|
||||
basic.showNumber(num, 150)
|
||||
basic.showNumber(num)
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
num = num + 1
|
||||
})
|
||||
```
|
||||
|
||||
### Competing for the LED screen
|
||||
## Competing for the LED screen
|
||||
|
||||
If different parts of a program are each trying
|
||||
to show something on the LED screen at the same time,
|
||||
@ -56,14 +57,14 @@ Try this on your @boardname@:
|
||||
|
||||
```blocks
|
||||
basic.forever(() => {
|
||||
basic.showNumber(6789, 150)
|
||||
basic.showNumber(6789)
|
||||
})
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
basic.showNumber(2, 150)
|
||||
basic.showNumber(2)
|
||||
})
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[while](/blocks/loops/while), [on button pressed](/reference/input/on-button-pressed), [in background](/reference/control/in-background)
|
||||
|
||||
|
@ -7,11 +7,11 @@ You can use this function to slow your program down.
|
||||
basic.pause(400)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* ``ms`` is the number of milliseconds that you want to pause (100 milliseconds = 1/10 second, and 1000 milliseconds = 1 second).
|
||||
|
||||
### Example: diagonal line
|
||||
## Example: diagonal line
|
||||
|
||||
This example draws a diagonal line by turning on LED `0, 0` (top left) through LED `4, 4` (bottom right).
|
||||
The program pauses 500 milliseconds after turning on each LED.
|
||||
@ -24,7 +24,7 @@ for (let i = 0; i < 5; i++) {
|
||||
}
|
||||
```
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[while](/blocks/loops/while), [running time](/reference/input/running-time), [for](/blocks/loops/for)
|
||||
|
||||
|
34
docs/reference/basic/plot-leds.md
Normal file
34
docs/reference/basic/plot-leds.md
Normal file
@ -0,0 +1,34 @@
|
||||
# Plot LEDs
|
||||
|
||||
Display an [Image](/reference/images/image) on the @boardname@'s [LED screen](/device/screen).
|
||||
|
||||
```sig
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
* leds - a series of LED on/off states that form an image (see steps below)
|
||||
|
||||
## Example: smiley
|
||||
|
||||
```blocks
|
||||
basic.showLeds(`
|
||||
. . . . .
|
||||
. # . # .
|
||||
. . # . .
|
||||
# . . . #
|
||||
. # # # .
|
||||
`)
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[show animation](/reference/basic/show-animation), [image](/reference/images/image), [show image](/reference/images/show-image), [scroll image](/reference/images/scroll-image)
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Show Animation
|
||||
# show Animation
|
||||
|
||||
Show a group of image frames (pictures) one after another on the [LED screen](/device/screen). It pauses the amount of time you tell it after each frame.
|
||||
|
||||
@ -12,12 +12,12 @@ basic.showAnimation(`
|
||||
`)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* `leds` is a [String](/reference/types/string) that shows which LEDs are on and off, in groups one after another.
|
||||
* `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds to pause after each image frame.
|
||||
* `leds` is a [string](/types/string) that shows which LEDs are on and off, in groups one after another.
|
||||
* `interval` is an optional [number](/types/number). It means the number of milliseconds to pause after each image frame.
|
||||
|
||||
### Example: Animating a group of image frames
|
||||
## Example: Animating a group of image frames
|
||||
|
||||
In this animation, each row is 15 spaces wide because
|
||||
there are three frames in the animation, and each frame is
|
||||
@ -33,13 +33,13 @@ basic.showAnimation(`
|
||||
`)
|
||||
```
|
||||
|
||||
### ~hint
|
||||
## ~hint
|
||||
|
||||
If the animation is too fast, make `interval` bigger.
|
||||
|
||||
### ~
|
||||
## ~
|
||||
|
||||
### Example: animating frames with a pause
|
||||
## Example: animating frames with a pause
|
||||
|
||||
This example shows six frames on the screen, pausing 500 milliseconds after each frame.
|
||||
|
||||
@ -57,8 +57,8 @@ basic.showAnimation(`
|
||||
`, 500)
|
||||
```
|
||||
|
||||
### ~hint
|
||||
## ~hint
|
||||
|
||||
Use [forever](/reference/basic/forever) to show an animation over and over.
|
||||
|
||||
### ~
|
||||
## ~
|
||||
|
29
docs/reference/basic/show-arrow.md
Normal file
29
docs/reference/basic/show-arrow.md
Normal file
@ -0,0 +1,29 @@
|
||||
# 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)
|
26
docs/reference/basic/show-icon.md
Normal file
26
docs/reference/basic/show-icon.md
Normal file
@ -0,0 +1,26 @@
|
||||
# Show Icon
|
||||
|
||||
Shows the selected icon on the LED screen
|
||||
|
||||
```sig
|
||||
basic.showIcon(IconNames.Heart)
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
* ``icon``, the identifier of the icon to display
|
||||
* ``interval`` (optional), the time to display in milliseconds. default is 400.
|
||||
|
||||
## Example
|
||||
|
||||
This program shows a happy face and then a sad face with the ``show icon`` function, with a one second pause in between.
|
||||
|
||||
```blocks
|
||||
basic.showIcon(IconNames.Happy)
|
||||
basic.pause(1000)
|
||||
basic.showIcon(IconNames.Sad)
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
[showLeds](/reference/basic/show-leds)
|
@ -13,13 +13,19 @@ basic.showLeds(`
|
||||
)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* `leds` is a [string](/reference/types/string) that controls which LEDs are on and off.
|
||||
* `interval` is an optional [number](/reference/types/number) that means how many milliseconds to wait after showing a picture.
|
||||
* `leds` is a [string](/types/string) that controls which LEDs are on and off.
|
||||
* `interval` is an optional [number](/types/number) that means how many milliseconds to wait after showing a picture.
|
||||
If you are programming with blocks, `interval` is set at 400 milliseconds.
|
||||
|
||||
### Example
|
||||
## ~ hint
|
||||
|
||||
See how the @boardname@ shows numbers, text, and displays images by watching this video about [LEDs](https://www.youtube.com/watch?v=qqBmvHD5bCw).
|
||||
|
||||
## ~
|
||||
|
||||
## Example
|
||||
|
||||
This program shows a picture with the ``show leds`` function.
|
||||
|
||||
@ -34,14 +40,14 @@ basic.showLeds(`
|
||||
)
|
||||
```
|
||||
|
||||
### ~hint
|
||||
## ~hint
|
||||
|
||||
If you are programming in JavaScript, `#` means an LED that is turned
|
||||
on and `.` means an LED that is turned off.
|
||||
|
||||
### ~
|
||||
## ~
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[plot leds](/reference/led/plot-leds), [show animation](/reference/basic/show-animation)
|
||||
[plot leds](/reference/basic/plot-leds), [show animation](/reference/basic/show-animation)
|
||||
|
||||
|
@ -2,47 +2,47 @@
|
||||
|
||||
Show a number on the [LED screen](/device/screen). It will slide left if it has more than one digit.
|
||||
|
||||
~~~~sig
|
||||
basic.showNumber(2, 150)
|
||||
~~~~
|
||||
```sig
|
||||
basic.showNumber(2)
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* `value` is a [Number](/reference/types/number).
|
||||
* `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
|
||||
* `value` is a [Number](/types/number).
|
||||
* `interval` is an optional [Number](/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
|
||||
|
||||
### Examples:
|
||||
## Examples:
|
||||
|
||||
To show the number 10:
|
||||
|
||||
~~~~blocks
|
||||
```blocks
|
||||
basic.showNumber(10)
|
||||
~~~~
|
||||
```
|
||||
|
||||
To show the number stored in a variable:
|
||||
|
||||
~~~~blocks
|
||||
```blocks
|
||||
let x = 1
|
||||
basic.showNumber(x)
|
||||
~~~~
|
||||
```
|
||||
|
||||
### Example: count to 5
|
||||
## Example: count to 5
|
||||
|
||||
This example uses a [for](/blocks/loops/for) loop to show numbers ``0`` through ``5`` on the screen:
|
||||
|
||||
~~~~blocks
|
||||
```blocks
|
||||
for (let i = 0; i < 6; i++) {
|
||||
basic.showNumber(i)
|
||||
basic.pause(200)
|
||||
}
|
||||
~~~~
|
||||
```
|
||||
|
||||
### Other show functions
|
||||
## Other show functions
|
||||
|
||||
* Use [show string](/reference/basic/show-string) to show a [String](/reference/types/string) with letters on the screen.
|
||||
* Use [show string](/reference/basic/show-string) to show a [String](/types/string) with letters on the screen.
|
||||
* Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[show string](/reference/basic/show-string), [show animation](/reference/basic/show-animation), [Number](/reference/types/number), [math](/blocks/math)
|
||||
[show string](/reference/basic/show-string), [show animation](/reference/basic/show-animation), [Number](/types/number), [math](/blocks/math)
|
||||
|
||||
|
@ -1,17 +1,17 @@
|
||||
# Show String
|
||||
|
||||
Show a number on the [LED screen](/device/screen). It will slide left if it is bigger than the screen.
|
||||
Show a string on the [LED screen](/device/screen). It will scroll to left if it's bigger than the screen.
|
||||
|
||||
```sig
|
||||
basic.showString("Hello!")
|
||||
basic.showString("hi!")
|
||||
```
|
||||
|
||||
### Parameters
|
||||
## Parameters
|
||||
|
||||
* `text` is a [String](/reference/types/string). It can contain letters, numbers, and punctuation.
|
||||
* `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds before sliding the [String](/reference/types/string) left by one LED each time. Bigger intervals make the sliding slower.
|
||||
* `text` is a [String](/types/string). It can contain letters, numbers, and punctuation.
|
||||
* `interval` is an optional [Number](/types/number). It means the number of milliseconds before sliding the [String](/types/string) left by one LED each time. Bigger intervals make the sliding slower.
|
||||
|
||||
### Examples:
|
||||
## Examples:
|
||||
|
||||
To show the word **Hello**:
|
||||
|
||||
@ -19,19 +19,19 @@ To show the word **Hello**:
|
||||
basic.showString("Hello")
|
||||
```
|
||||
|
||||
To show what is stored in a [String](/reference/types/string) variable:
|
||||
To show what is stored in a [String](/types/string) variable:
|
||||
|
||||
```blocks
|
||||
let s = "Hi"
|
||||
basic.showString(s)
|
||||
```
|
||||
|
||||
### Other show functions
|
||||
## Other show functions
|
||||
|
||||
* Use [show number](/reference/basic/show-number) to show a number on the [LED screen](/device/screen).
|
||||
* Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
|
||||
|
||||
### See also
|
||||
## See also
|
||||
|
||||
[String](/reference/types/string), [show number](/reference/basic/show-number), [show animation](/reference/basic/show-animation)
|
||||
[String](/types/string), [show number](/reference/basic/show-number), [show animation](/reference/basic/show-animation)
|
||||
|
||||
|
Reference in New Issue
Block a user