2.1.28, initiation update to PXT v5.28.24 (#54)

This commit is contained in:
Amerlander
2019-12-02 05:58:26 +01:00
committed by Peli de Halleux
parent 38a964516e
commit 5c114a0c57
1261 changed files with 50692 additions and 21604 deletions

View File

@ -6,11 +6,11 @@ Find how bright the [LED screen](/device/screen) is _when it is turned on_.
led.brightness();
```
### Returns
## Returns
* a [number](/reference/types/number) that means how bright the screen is when it is turned on, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright when it is turned on.
* a [number](/types/number) that means how bright the screen is when it is turned on, from `0` (darkest) to `255` (brightest). For example, the number `127` means the screen is halfway bright when it is turned on.
### Example: highest brightness
## Example: highest brightness
This program makes the screen completely bright when it is turned on (if it is not that way already):
@ -21,7 +21,7 @@ if (led.brightness() < 255) {
```
### Example: change brightness
## Example: change brightness
This program makes the screen brightness 100% (255). Then it turns on
the center LED (`2, 2`), waits for one second and then sets the screen
@ -34,7 +34,7 @@ basic.pause(1000)
led.setBrightness(led.brightness() / 2)
```
### See also
## See also
[set brightness](/reference/led/set-brightness), [fade in](/reference/led/fade-in), [fade out](/reference/led/fade-out)

View File

@ -6,21 +6,21 @@ Turns the LED screen on and off
led.enable(false);
```
### Parameters
## Parameters
* ``on`` is a [boolean](/reference/types/boolean) that defines the on/off state of the screen
* ``on`` is a [boolean](/types/boolean) that defines the on/off state of the screen
### Example: Turning off the screen
## Example: Turning off the screen
This program turns off the screen when pressing button ``B``
```typescript
```blocks
input.onButtonPressed(Button.B, () => {
led.enable(false)
});
```
### Pins: P3, P4, P6, P7, P9, P10
## Pins: P3, P4, P6, P7, P9, P10
These pins are coupled to the LED matrix display, and also its associated ambient light sensing mode.
To disable the display driver feature (which will automatically disable the light sensing feature) call the DAL function ``led.enable(false)``.
@ -28,6 +28,6 @@ To turn the display driver back on again later, call ``led.enable(true)``.
More information at http://tech.microbit.org/hardware/edgeconnector_ds/ .
### See also
## See also
[unplot](/reference/led/unplot), [point](/reference/led/point), [LED screen](/device/screen)

View File

@ -6,11 +6,11 @@ Gradually increase the [LED screen](/device/screen) brightness until the LED lig
led.fadeIn(700);
```
### Parameters
## Parameters
* ms - [Number](/reference/types/number); the speed by which the screen brightness is increased, expressed in milliseconds (1,000 milliseconds = 1 second). The smaller the number the faster the screen brightness increased.
* ms - [Number](/types/number); the speed by which the screen brightness is increased, expressed in milliseconds (1,000 milliseconds = 1 second). The smaller the number the faster the screen brightness increased.
### Example: fading dot
## Example: fading dot
The following code turns on centre LED and then gradually increases and decreases the screen brightness (the centre LED pulses 5 times):
@ -24,7 +24,7 @@ for (let i = 0; i < 5; i++) {
}
```
### See also
## See also
[brightness](/reference/led/brightness), [fade out](/reference/led/fade-out), [set brightness](/reference/led/set-brightness)

View File

@ -6,11 +6,11 @@ Gradually decrease the [LED screen](/device/screen) brightness until the LED lig
led.fadeOut(700);
```
### Parameters
## Parameters
* ms - [Number](/reference/types/number); the speed that the screen brightness is decreased, expressed in milliseconds (1,000 milliseconds = 1 second). The smaller the number the faster the screen brightness decreased.
* ms - [Number](/types/number); the speed that the screen brightness is decreased, expressed in milliseconds (1,000 milliseconds = 1 second). The smaller the number the faster the screen brightness decreased.
### Example: fade away letter A
## Example: fade away letter A
The following example sets the screen brightness to the maximum brightness, displays the letter A, and then gradually fades the letter away:
@ -20,7 +20,7 @@ basic.showString("A", 1000)
led.fadeOut(1000)
```
### See also
## See also
[brightness](/reference/led/brightness), [fade in](/reference/led/fade-in), [set brightness](/reference/led/set-brightness)

View File

@ -6,7 +6,7 @@ Turn on all the 25 LEDs on the [LED screen](/device/screen).
led.plotAll()
```
### See also
## See also
[LED screen](/device/screen), [clear screen](/reference/basic/clear-screen)

View File

@ -1,30 +1,29 @@
# Plot Bar Graph
# plot Bar Graph
Displays a bar graph of the numbers you say.
A bar graph is a kind of chart that shows numbers as lines with different lengths.
Display a bar graph for a number value.
```sig
led.plotBarGraph(2, 20);
```
### Parameters
A bar graph is a kind of chart that shows numbers as lines with different lengths.
* ``value`` is a [number](/reference/types/number) that means what you
## Parameters
* **value**: a [number](/types/number) that is the value of what you
are measuring or trying to show. For example, if you are measuring
the temperature of ice with the @boardname@, ``value`` might be `0`
because the temperature might be 0 degrees centigrade.
* ``high`` is a [number](/reference/types/number) that means the highest
possible number that the ``value`` parameter can be. This number is
also the tallest that the lines in the bar chart can be.
if the temperature is 0 degrees Celsius.
* **high**: a [number](/types/number) that is the highest
possible number (maximum) that the **value** parameter can be. The lines in the bar graph will reach their highest point when **value** reaches this number. If **high** is `0`, then the largest value recently plotted is used as the maximum.
### Example: chart acceleration
## Example: chart acceleration
This program shows a bar graph of the [acceleration](/reference/input/acceleration)
Show a bar graph of the [acceleration](/reference/input/acceleration)
in the `x` direction of the @boardname@.
The @boardname@'s `x` direction is from left to right (or right to left).
The more you speed up moving the @boardname@ in this direction,
the taller the lines in the bar graph will be,
until they are as tall as the parameter `high` says they can be.
The faster you move the @boardname@ in this direction,
the taller the lines in the bar graph will be. The **high** paramter is `1023` which sets the highest possible value of acceleration to show.
```blocks
basic.forever(() => {
@ -33,7 +32,7 @@ basic.forever(() => {
})
```
### See also
## See also
[brightness](/reference/led/brightness), [fade in](/reference/led/fade-in), [fade out](/reference/led/fade-out), [LED screen](/device/screen), [stop animation](/reference/led/stop-animation)

View File

@ -0,0 +1,63 @@
# Plot Brightness
Turn on a LED light with a specific brightness on the [LED screen](/device/screen).
```sig
led.plotBrightness(0,0, 128);
```
### Parameters
* ``x`` is a [number](/types/number) that means the
horizontal spot on the LED screen (from left to right: 0, 1, 2, 3,
or 4)
* ``y`` is a [number](/types/number) that means the vertical
spot on the LED screen (from top to bottom: 0, 1, 2, 3, or 4)
* ``brightness` is a [number](/types/number) that represents the brightness of the LED, from 0 (off) to 255 (full brightness)
If a parameter is [out of bounds](/reference/out-of-bounds) (a value
other than 0 to 4), then this function will do nothing.
### ~hint
The LED screen is a solid square of LEDs with five LEDs on each side.
To learn more about how you number the LEDs with ``x`` and ``y``
coordinates, see [LED screen](/device/screen).
### ~
### Example: One LED
This program turns on the bottom right LED at 50% brightness
```blocks
led.plotBrightness(2, 2, 128)
```
### Example: Square
This program uses a [for loop](/blocks/loops/for)
and the `plotBrightness` function
to make a square around the edges of the LED screen.
```blocks
for (let i = 0; i < 5; i++) {
led.plotBrightness(0, i, 64)
led.plotBrightness(4, i, 128)
led.plotBrightness(i, 0, 172)
led.plotBrightness(i, 4, 255)
basic.pause(500)
}
```
### ~hint
Use the [point](/reference/led/point) function to find out if an LED is
on or off.
### ~
### See also
[plot](/reference/led/plot), [unplot](/reference/led/unplot), [point](/reference/led/point), [LED screen](/device/screen)

View File

@ -1,34 +0,0 @@
# Plot LEDs
Display an [Image](/reference/images/image) on the @boardname@'s [LED screen](/device/screen). NOTE: `basic -> plot image` has been replaced by `basic -> show leds`.
```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)

View File

@ -12,26 +12,26 @@ Use [unplot](/reference/led/unplot) to turn **off** an LED.
## ~
### Parameters
## Parameters
* ``x`` is a [number](/reference/types/number) that means the
* ``x`` is a [number](/types/number) that means the
horizontal spot on the LED screen (from left to right: 0, 1, 2, 3,
or 4)
* ``y`` is a [number](/reference/types/number) that means the vertical
* ``y`` is a [number](/types/number) that means the vertical
spot on the LED screen (from top to bottom: 0, 1, 2, 3, or 4)
If a parameter is [out of bounds](/reference/out-of-bounds) (a value
other than 0 to 4), then this function will do nothing.
### ~hint
## ~hint
The LED screen is a solid square of LEDs with five LEDs on each side.
To learn more about how you number the LEDs with ``x`` and ``y``
coordinates, see [LED screen](/device/screen).
### ~
## ~
### Example: One LED
## Example: One LED
This program turns on the bottom right LED.
@ -40,7 +40,7 @@ led.plot(4, 4)
```
### Example: Square
## Example: Square
This program uses a [for loop](/blocks/loops/for)
and the `plot` function
@ -56,13 +56,13 @@ for (let i = 0; i < 5; i++) {
}
```
### ~hint
## ~hint
Use the [point](/reference/led/point) function to find out if an LED is
on or off.
### ~
## ~
### See also
## See also
[unplot](/reference/led/unplot), [point](/reference/led/point), [LED screen](/device/screen)

View File

@ -7,30 +7,30 @@ Find whether the LED you say on the
led.point(0,0);
```
### Parameters
## Parameters
* ``x`` is a [number](/reference/types/number) that means the
* ``x`` is a [number](/types/number) that means the
horizontal spot on the LED screen (from left to right: 0, 1, 2, 3,
or 4)
* ``y`` is a [number](/reference/types/number) that means the vertical
* ``y`` is a [number](/types/number) that means the vertical
spot on the LED screen (from top to bottom: 0, 1, 2, 3, or 4)
If a parameter is [out of bounds](/reference/out-of-bounds) (a value
other than 0 to 4), this function will return `false`.
### Returns
## Returns
* a [boolean](/blocks/logic/boolean). If it is `true`, that means the LED is on. If it is `false`, that means the LED is off.
### ~hint
## ~hint
The LED screen is a solid square of LEDs with five LEDs on each side.
To learn more about how you number the LEDs with ``x`` and ``y``
coordinates, see [LED screen](/device/screen).
### ~
## ~
### Example: Toggle off
## Example: Toggle off
This program turns the center LED (2, 2) off if it is already on. (If
it is already off, this program leaves it off.)
@ -41,7 +41,7 @@ if (led.point(2, 2)) {
}
```
### See also
## See also
[unplot](/reference/led/unplot), [plot](/reference/led/plot), [LED screen](/device/screen)

View File

@ -6,15 +6,15 @@ Make an [Image](/reference/images/image) out of the current state of the [LED sc
led.screenshot();
```
### Parameters
## Parameters
* none
### Returns
## Returns
* an [Image](/reference/images/image) of what is currently visible on the [LED screen](/device/screen)
### See also
## See also
[create image](/reference/images/create-image), [LED screen](/device/screen),

View File

@ -7,14 +7,20 @@ turned on.
led.setBrightness(121)
```
### Parameters
## Parameters
* ``value`` is a [number](/reference/types/number) that means how
* ``value`` is a [number](/types/number) that means how
bright the screen is when it is turned on, from `0` (darkest) to
`255` (brightest). For example, the number `127` means the screen is
halfway bright when it is turned on.
### Example: change brightness
## ~ hint
The brightness is not supported in the simulator. You will need to try it on the @boardname@ itself!
## ~
## Example: change brightness
This program makes the screen brightness 100% (`255`). Then it turns on
the center LED (`2, 2`), waits for one second, and then sets the screen
@ -27,6 +33,6 @@ basic.pause(1000)
led.setBrightness(led.brightness() / 2)
```
### See also
## See also
[brightness](/reference/led/brightness), [fade in](/reference/led/fade-in), [fade out](/reference/led/fade-out), [LED screen](/device/screen)

View File

@ -1,8 +1,26 @@
# Set Display Mode
# set Display Mode
Sets the display mode between black and white and greyscale for rendering [LEDs](/device/screen).
Set the display mode to either black and white or greyscale for rendering [LEDs](/device/screen).
```sig
led.setDisplayMode(DisplayMode.Greyscale)
```
The LED screen can create a sense of color depth with the display mode setting. Color depth is the difference in darkness between the pixels in the display. The `greyscale` mode makes the pixels appear
to have some amount of brightness to represent the grey value of real color. The `black and white` mode just shows an image on the pixels with the LEDs either on or off.
## Parameters
* ``mode`` the display mode type. This is either `BlackAndWhite` or `GreyScale`.
## Example
Set the display mode to `black and white`.
```blocks
led.setDisplayMode(DisplayMode.BlackAndWhite)
```
## See also
[set brightness](/reference/led/set-brightness)

View File

@ -7,7 +7,7 @@ play.
led.stopAnimation()
```
### Example
## Example
This program sets up the ``stop animation`` part of the program,
and then shows a string that you can stop with button ``B``.
@ -19,14 +19,14 @@ input.onButtonPressed(Button.B, () => {
basic.showString("STOP ME! STOP ME! PLEASE, WON'T SOMEBODY STOP ME?");
```
### ~hint
## ~hint
It's important to set up ``stop animation`` before showing the
animation, so the ``stop animation`` part of the program will be ready
to go.
### ~
## ~
### See Also
## See Also
[show animation](/reference/basic/show-animation)

View File

@ -6,11 +6,11 @@ Toggle all the 25 LEDs on the [LED screen](/device/screen) - if an LED is on bef
led.toggleAll()
```
### Parameters
## Parameters
* none
### Example
## Example
The following code will result in every LED being on except for the LED at coordinate (2,2)
@ -26,7 +26,7 @@ led.plot(2, 2)
led.toggleAll()
```
### See also
## See also
[toggle](/reference/led/toggle), [LED screen](/device/screen), [clear screen](/reference/basic/clear-screen)

View File

@ -6,18 +6,18 @@ Toggle a LED light on the [LED screen](/device/screen), meaning to turn it on (
led.toggle(0,0)
```
### Parameters
## Parameters
* x - [Number](/reference/types/number); the *x coordinate* or horizontal position (0, 1, 2, 3, 4)
* y - [Number](/reference/types/number); the *y coordinate* or vertical position (0, 1, 2, 3, 4)
* x - [Number](/types/number); the *x coordinate* or horizontal position (0, 1, 2, 3, 4)
* y - [Number](/types/number); the *y coordinate* or vertical position (0, 1, 2, 3, 4)
If a parameter is [out of bounds](/reference/out-of-bounds) (a value other than 0-4), then this function will do nothing.
### x, y coordinates?
## x, y coordinates?
The LED screen is made up of 25 LEDs arranged in a 5x5 grid. To figure out the ``x``, ``y`` coordinates, see [LED screen](/device/screen).
### Example
## Example
This code toggles the centre LED:
@ -25,7 +25,7 @@ This code toggles the centre LED:
led.toggle(2, 2)
```
### See also
## See also
[toggle all](/reference/led/toggle-all), [plot](/reference/led/plot), [unplot](/reference/led/unplot), [point](/reference/led/point), [LED screen](/device/screen),

View File

@ -12,26 +12,26 @@ Use [plot](/reference/led/plot) to turn **on** an LED.
## ~
### Parameters
## Parameters
* ``x`` is a [number](/reference/types/number) that means the
* ``x`` is a [number](/types/number) that means the
horizontal spot on the LED screen (from left to right: 0, 1, 2, 3,
or 4)
* ``y`` is a [number](/reference/types/number) that means the vertical
* ``y`` is a [number](/types/number) that means the vertical
spot on the LED screen (from top to bottom: 0, 1, 2, 3, or 4)
If a parameter is [out of bounds](/reference/out-of-bounds) (a value
other than 0 to 4), then this function will do nothing.
### ~hint
## ~hint
The LED screen is a solid square of LEDs with five LEDs on each side.
To learn more about how you number the LEDs with ``x`` and ``y``
coordinates, see [LED screen](/device/screen).
### ~
## ~
### Example: Center off
## Example: Center off
This program shows a picture on the LED screen, and then turns off the center LED with `unplot`.
@ -47,14 +47,14 @@ basic.pause(500)
led.unplot(2, 2)
```
### ~hint
## ~hint
Use the [point](/reference/led/point) function to find out if an LED is
on or off.
### ~
## ~
### See also
## See also
[plot](/reference/led/plot), [point](/reference/led/point), [LED screen](/device/screen)