Migrate docs from the other repo

This commit is contained in:
Michal Moskal
2016-03-25 16:47:20 -07:00
parent 38d2cf06d2
commit a08eb53f92
895 changed files with 36888 additions and 0 deletions

View File

@ -0,0 +1,26 @@
# Brightness
Set the brightness of the [LED screen](/microbit/device/screen).
```sig
led.brightness();
```
### Returns
* [Number](/microbit/reference/types/number) - returns the LCD screen brightness as a number from 0 to 255. A return value of 255 means the screen brightness is at 100% and 127 is about 50% brightness.
### Example: maximum brightness
If the screen brightness is < 100%, the following code sets the brightness to 100% (255):
```blocks
if (led.brightness() < 255) {
led.setBrightness(255)
}
```
### See also
[set brightness](/microbit/reference/led/set-brightness), [fade in](/microbit/reference/led/fade-in), [fade out](/microbit/reference/led/fade-out)

View File

@ -0,0 +1,34 @@
# Fade in
Gradually increase the [LED screen](/microbit/device/screen) brightness until the LED lights are at full brightness.
```sig
led.fadeIn(700);
```
### Parameters
* ms - [Number](/microbit/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.
### 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):
```blocks
led.plot(2, 2)
for (let i = 0; i < 5; i++) {
led.setBrightness(0)
led.fadeIn(100)
basic.pause(100)
led.fadeOut(100)
}
```
### Lessons
[glowing sword](/microbit/lessons/glowing-sword)
### See also
[brightness](/microbit/reference/led/brightness), [fade out](/microbit/reference/led/fade-out), [set brightness](/microbit/reference/led/set-brightness)

View File

@ -0,0 +1,30 @@
# Fade out
Gradually decrease the [LED screen](/microbit/device/screen) brightness until the LED lights are turned off.
```sig
led.fadeOut(700);
```
### Parameters
* ms - [Number](/microbit/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.
### 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:
```blocks
led.setBrightness(255)
basic.showString("A", 1000)
led.fadeOut(1000)
```
### Lessons
[glowing sword](/microbit/lessons/glowing-sword)
### See also
[brightness](/microbit/reference/led/brightness), [fade in](/microbit/reference/led/fade-in), [set brightness](/microbit/reference/led/set-brightness)

View File

@ -0,0 +1,16 @@
# Plot All
Turn on all the 25 LEDs on the [LED screen](/microbit/device/screen).
```sig
led.plotAll()
```
### Lessons
[night light](/microbit/lessons/night-light)
### See also
[LED screen](/microbit/device/screen), [clear screen](/microbit/reference/basic/clear-screen)

View File

@ -0,0 +1,25 @@
# Plot Bar Graph
Displays a vertical bar graph based on the value and high value.
```sig
led.plotBarGraph(2, 20);
```
### Parameters
* value: [Number](/microbit/reference/types/number) , high : [Number](/microbit/reference/types/number) displays a vertical bar graph based on the value and high value
### Example: chart acceleration
```blocks
basic.forever(() => {
let a = input.acceleration(Dimension.X);
led.plotBarGraph(a, 1023)
})
```
### See also
[brightness](/microbit/reference/led/brightness), [fade in](/microbit/reference/led/fade-in), [fade out](/microbit/reference/led/fade-out), [LED screen](/microbit/device/screen), [stop animation](/microbit/reference/led/stop-animation)

View File

@ -0,0 +1,40 @@
# Plot LEDs
Display an [Image](/microbit/reference/image/image) on the BBC micro:bit's [LED screen](/microbit/device/screen). NOTE: `basic -> plot image` has been replaced by `basic -> show leds`.
### KindScript syntax
```sig
basic.plotLeds(`
. . . . .
. # . # .
. . # . .
# ; . . #
. # # # .
`)
```
### Parameters
* leds - a series of LED on/off states that form an image (see steps below)
### Example: simley
```blocks
basic.plotLeds(`
. . . . .
. # . # .
. . # . .
# ; . . #
. # # # .
`)
```
### Lessons
[smiley](/microbit/lessons/smiley), [flashing heart](/microbit/lessons/flashing-heart), [magic logo](/microbit/lessons/magic-logo)
### See also
[show animation](/microbit/reference/basic/show-animation), [image](/microbit/reference/image/image), [show image](/microbit/reference/images/show-image), [scroll image](/microbit/reference/images/scroll-image)

View File

@ -0,0 +1,51 @@
# Plot
Turn on a LED light on the [LED screen](/microbit/device/screen). Specify which LED using x, y coordinates. Use [unplot](/microbit/reference/led/unplot) to turn a LED off.
```sig
led.plot(0,0);
```
### Parameters
* x - [Number](/microbit/reference/types/number); the *x coordinate* or horizontal position (0, 1, 2, 3, 4)
* y - [Number](/microbit/reference/types/number); the *y coordinate* or vertical position (0, 1, 2, 3, 4)
If a parameter is [out of bounds](/microbit/reference/out-of-bounds) (a value other than 0-4), then this function will do nothing.
### 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](/microbit/device/screen).
This code turns on the centre LED:
```blocks
led.plot(2, 2)
```
### Get the LED on/off state
Use the [point](/microbit/reference/led/point) function to find out if a LED is on or off.
### Example: a square
The following example uses a [for loop](/microbit/reference/loops/for) and the `plot` function to turn on the LED lights along the edge of the screen, making a square:
```blocks
for (let i = 0; i < 5; i++) {
led.plot(0, i)
led.plot(4, i)
led.plot(i, 0)
led.plot(i, 4)
basic.pause(500)
}
```
### Lessons
[blink](/microbit/lessons/blink), [beautiful image](/microbit/lessons/beautiful-image), [strobe light](/microbit/lessons/strobe-light)
### See also
[unplot](/microbit/reference/led/unplot), [point](/microbit/reference/led/point), [LED screen](/microbit/device/screen)

View File

@ -0,0 +1,37 @@
# Point
Get the on/off state of a LED on the [LED screen](/microbit/device/screen). Specify the LED using x, y coordinates.
```sig
led.point(0,0);
```
### Parameters
* x - [Number](/microbit/reference/types/number); the *x coordinate* or horizontal position (0, 1, 2, 3, 4)
* y - [Number](/microbit/reference/types/number); the *y coordinate* or vertical position (0, 1, 2, 3, 4)
If a parameter is [out of bounds](/microbit/reference/out-of-bounds) (a value other than 0-4), then this function will return `false`.
### Returns
* [Boolean](/microbit/reference/types/boolean) - `true` if the LED is *on* and `false` if the LED is *off*
### 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](/microbit/device/screen).
### Example: toggle off
If `point(1, 1)` returns `true`, then the following code turns off the LED:
```blocks
if (led.point(1, 1)) {
led.unplot(1, 1)
}
```
### See also
[unplot](/microbit/reference/led/unplot), [plot](/microbit/reference/led/plot), [LED screen](/microbit/device/screen), [create image](/microbit/reference/images/create-image)

View File

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

View File

@ -0,0 +1,31 @@
# Set Brightness
Sets the brightness of the [LED screen](/microbit/device/screen).
```sig
led.setBrightness(121)
```
### Parameters
* value : [Number](/microbit/reference/types/number) - the brightness of the LED screen expressed as a number between 0 and 255
### Example: change brightness
The following example sets the screen brightness to 100% (255), turns on LED `2, 2`, waits for a second and then sets the screen brightness to 50% (127):
```blocks
led.setBrightness(255)
led.plot(2, 2)
basic.pause(1000)
led.setBrightness(127)
```
### Lessons
[night light](/microbit/lessons/night-light)
### See also
[brightness](/microbit/reference/led/brightness), [fade in](/microbit/reference/led/fade-in), [fade out](/microbit/reference/led/fade-out), [LED screen](/microbit/device/screen)

View File

@ -0,0 +1,8 @@
# Set Display Mode
Sets the display mode between black and white and greyscale for rendering [LEDs](/microbit/device/screen).
```sig
led.setDisplayMode(DisplayMode.Greyscale)
```

View File

@ -0,0 +1,8 @@
# Stop Animation
Cancels the current animation and clears other pending animations .
```sig
led.stopAnimation()
```

View File

@ -0,0 +1,28 @@
# Toggle All
Toggle all the 25 LEDs on the [LED screen](/microbit/device/screen) - if an LED is on before the function is called, it will be off after; if an LED is off before the function is called, it will be on after.
```sig
led.toggleAll()
```
### Parameters
* none
### Example
The following code will result in every LED being on except for the LED at coordinate (2,2)
```blocks
basic.clearScreen()
led.plot(2, 2)
led.toggleAll()
```
![](/static/mb/toggle-all-0.png)
### See also
[toggle](/microbit/reference/led/toggle), [LED screen](/microbit/device/screen), [clear screen](/microbit/reference/basic/clear-screen)

View File

@ -0,0 +1,31 @@
# Toggle
Toggle a LED light on the [LED screen](/microbit/device/screen), meaning to turn it on (off) if it is off (on). Specify which LED using x, y coordinates.
```sig
led.toggle(0,0)
```
### Parameters
* x - [Number](/microbit/reference/types/number); the *x coordinate* or horizontal position (0, 1, 2, 3, 4)
* y - [Number](/microbit/reference/types/number); the *y coordinate* or vertical position (0, 1, 2, 3, 4)
If a parameter is [out of bounds](/microbit/reference/out-of-bounds) (a value other than 0-4), then this function will do nothing.
### 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](/microbit/device/screen).
### Example
This code toggles the centre LED:
```blocks
led.toggle(2, 2)
```
### See also
[toggle all](/microbit/reference/led/toggle-all), [plot](/microbit/reference/led/plot), [unplot](/microbit/reference/led/unplot), [point](/microbit/reference/led/point), [LED screen](/microbit/device/screen),

View File

@ -0,0 +1,53 @@
# Unplot
Turn off a LED light on the [LED screen](/microbit/device/screen). Specify which LED using x, y coordinates. Use [plot](/microbit/reference/led/plot) to turn a LED on.
```sig
led.unplot(0,0)
```
### Parameters
* x - [Number](/microbit/reference/types/number); the *x coordinate* or horizontal position (0, 1, 2, 3, 4)
* y - [Number](/microbit/reference/types/number); the *y coordinate* or vertical position (0, 1, 2, 3, 4)
If a parameter is [out of bounds](/microbit/reference/out-of-bounds) (a value other than 0-4), this function will do nothing.
### 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](/microbit/device/screen).
This code turns off centre LED:
```blocks
led.unplot(2, 2)
```
### Get the LED on/off state
Use the [point](/microbit/reference/led/point) function to find out if a LED is on or off.
### Example: toggle off
This code creates and shows an image on the micro:bit screen, and then clears the centre LED using `unplot`:
```blocks
basic.showLeds(`
. . # . .
. . # . .
# # # # #
. . # . .
. . # . .
`)
basic.pause(500)
led.unplot(2, 2)
```
### Lessons
[strobe light](/microbit/lessons/strobe-light)
### See also
[plot](/microbit/reference/led/plot), [point](/microbit/reference/led/point), [LED screen](/microbit/device/screen), [create image](/microbit/reference/images/create-image)