/reference/types -> /types

This commit is contained in:
Peli de Halleux 2017-03-16 07:57:41 -07:00
parent 69bd0225ad
commit 00e9217e73
116 changed files with 224 additions and 361 deletions

View File

@ -27,4 +27,4 @@ input.onButtonPressed(Button.A, () => {
}) })
``` ```
See the documentation on [Numbers](/reference/types/number) for more information on comparing two Numbers. You can also [compare strings](/reference/types/string-functions) using the `equals` function. See the documentation on [Numbers](/types/number) for more information on comparing two Numbers.

View File

@ -1,7 +1,7 @@
# Assignment Operator # Assignment Operator
Use an equals sign to make a [variable](/blocks/variables/var) store the [number](/reference/types/number) Use an equals sign to make a [variable](/blocks/variables/var) store the [number](/types/number)
or [string](/reference/types/string) you say. or [string](/types/string) you say.
When you use the equals sign to store something in a variable, the equals sign is called When you use the equals sign to store something in a variable, the equals sign is called
an *assignment operator*, and what you store is called a *value*. an *assignment operator*, and what you store is called a *value*.
@ -27,10 +27,10 @@ basic.showString(name);
### Notes ### Notes
You can use the assignment operator with variables of You can use the assignment operator with variables of
every [type](/reference/types). A *type* is which kind of thing every [type](/types). A *type* is which kind of thing
a variable can store, like a number or string. a variable can store, like a number or string.
### See also ### See also
[variable](/blocks/variables/var), [types](/reference/types) [variable](/blocks/variables/var), [types](/types)

View File

@ -4,7 +4,7 @@ How to define and use local variables.
### @parent language ### @parent language
A variable is a place where you can store and retrieve data. Variables have a name, a [type](/reference/types), and value: A variable is a place where you can store and retrieve data. Variables have a name, a [type](/types), and value:
* *name* is how you'll refer to the variable * *name* is how you'll refer to the variable
* *type* refers to the kind of data a variable can store * *type* refers to the kind of data a variable can store
@ -83,5 +83,5 @@ if (led.brightness() > 128) {
### See also ### See also
[types](/reference/types), [assignment operator](/blocks/variables/assign) [types](/types), [assignment operator](/blocks/variables/assign)

View File

@ -35,7 +35,7 @@ basic.showLeds(`
``` ```
* **variable**: [read more...](/blocks/variables) * **variable**: [read more...](/blocks/variables)
* **arithmetic operators**: [read more...](/reference/types/number) * **arithmetic operators**: [read more...](/types/number)
* **on button pressed** : [read more...](/reference/input/on-button-pressed) * **on button pressed** : [read more...](/reference/input/on-button-pressed)
* **show number** : [read more...](/reference/basic/show-number) * **show number** : [read more...](/reference/basic/show-number)

View File

@ -44,4 +44,4 @@ bluetooth
### See Also ### See Also
[basic](/reference/basic), [input](/reference/input), [music](/reference/music), [led](/reference/led), [Math (blocks)](/blocks/math), [String](/reference/types/string), [game](/reference/game), [images](/reference/images), [pins](/reference/pins), [serial](/reference/serial), [control](/reference/control), [radio](/reference/radio), [devices](/reference/devices), [bluetooth](/reference/bluetooth) [basic](/reference/basic), [input](/reference/input), [music](/reference/music), [led](/reference/led), [Math (blocks)](/blocks/math), [String](/types/string), [game](/reference/game), [images](/reference/images), [pins](/reference/pins), [serial](/reference/serial), [control](/reference/control), [radio](/reference/radio), [devices](/reference/devices), [bluetooth](/reference/bluetooth)

View File

@ -33,7 +33,7 @@ basic.forever(() => {
### 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. When you press button `A`, the number gets bigger.
You can use a program like this to count things with your @boardname@. You can use a program like this to count things with your @boardname@.

View File

@ -14,8 +14,8 @@ basic.showAnimation(`
### Parameters ### Parameters
* `leds` is a [String](/reference/types/string) that shows which LEDs are on and off, in groups one after another. * `leds` is a [String](/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. * `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

View File

@ -15,8 +15,8 @@ basic.showLeds(`
### Parameters ### Parameters
* `leds` is a [string](/reference/types/string) that controls which LEDs are on and off. * `leds` is a [string](/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. * `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. If you are programming with blocks, `interval` is set at 400 milliseconds.
### Example ### Example

View File

@ -8,8 +8,8 @@ basic.showNumber(2)
### Parameters ### Parameters
* `value` is a [Number](/reference/types/number). * `value` is a [Number](/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. * `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:
@ -39,10 +39,10 @@ for (let i = 0; i < 6; i++) {
### 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. * 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)

View File

@ -8,8 +8,8 @@ basic.showString("Hello!")
### Parameters ### Parameters
* `text` is a [String](/reference/types/string). It can contain letters, numbers, and punctuation. * `text` is a [String](/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. * `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:
@ -19,7 +19,7 @@ To show the word **Hello**:
basic.showString("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 ```blocks
let s = "Hi" let s = "Hi"
@ -33,5 +33,5 @@ basic.showString(s)
### 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)

View File

@ -24,7 +24,7 @@ bluetooth.advertiseUidBuffer(pins.createBuffer(16), 7, true);
### Parameters ### Parameters
* ``buffer`` - a 16 bytes buffer containing the namespace (first 10 bytes) and instance (last 6 bytes). * ``buffer`` - a 16 bytes buffer containing the namespace (first 10 bytes) and instance (last 6 bytes).
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range). * ``power`` - a [number](/types/number) representing the power level between 0 (short) and 7 (maximum range).
* ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the @boardname@ should accept connections. * ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the @boardname@ should accept connections.

View File

@ -25,7 +25,7 @@ bluetooth.advertiseUid(42, 1, 7, true);
* ``namespace`` last 4 bytes of the namespace uid (6 to 9) * ``namespace`` last 4 bytes of the namespace uid (6 to 9)
* ``instance`` last 4 bytes of the instance (2 to 5) * ``instance`` last 4 bytes of the instance (2 to 5)
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range). * ``power`` - a [number](/types/number) representing the power level between 0 (short) and 7 (maximum range).
* ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the @boardname@ should accept connections. * ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the @boardname@ should accept connections.
## Encoding ## Encoding

View File

@ -23,8 +23,8 @@ bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
### Parameters ### Parameters
* ``url`` - a [string](/reference/types/string) containing the URL to broadcast, at most 17 characters long, excluding the protocol (eg: ``https://``) which gets encoded as 1 byte. * ``url`` - a [string](/types/string) containing the URL to broadcast, at most 17 characters long, excluding the protocol (eg: ``https://``) which gets encoded as 1 byte.
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range). * ``power`` - a [number](/types/number) representing the power level between 0 (short) and 7 (maximum range).
* ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the @boardname@ should accept connections. * ``connectable`` - a [boolean](/blocks/logic/boolean) indicating whether or not the @boardname@ should accept connections.
### Example: Broadcast a secret code ### Example: Broadcast a secret code

View File

@ -15,7 +15,7 @@ bluetooth.setTransmitPower(7);
### Parameters ### Parameters
* `power`: a [number](/reference/types/number) in the range ``0..7``, where ``0`` is the lowest power and ``7`` is the highest. * `power`: a [number](/types/number) in the range ``0..7``, where ``0`` is the lowest power and ``7`` is the highest.
### See also ### See also

View File

@ -7,7 +7,7 @@ game.addScore(1)
``` ```
### Parameters ### Parameters
* a [number](/reference/types/number) that means how much to add to the score. A negative number means to subtract from the score. * a [number](/types/number) that means how much to add to the score. A negative number means to subtract from the score.
### Examples ### Examples

View File

@ -1,6 +1,6 @@
# Get Sprite Property # Get Sprite Property
Change the kind of [number](/reference/types/number) you say for a [sprite](/reference/game/create-sprite). Change the kind of [number](/types/number) you say for a [sprite](/reference/game/create-sprite).
```sig ```sig
let item: game.LedSprite = null; let item: game.LedSprite = null;
@ -10,7 +10,7 @@ item.set(LedSpriteProperty.X, 0);
### Parameters ### Parameters
* the **sprite** you want to change * the **sprite** you want to change
* the kind of [number](/reference/types/number) you want to change for the sprite, like * the kind of [number](/types/number) you want to change for the sprite, like
* ``x``, how far up or down the sprite is on the screen (`0`-`4`) * ``x``, how far up or down the sprite is on the screen (`0`-`4`)
* ``y``, how far left or right the sprite is on the screen (`0`-`4`) * ``y``, how far left or right the sprite is on the screen (`0`-`4`)
* ``direction``, which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function) * ``direction``, which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function)

View File

@ -10,7 +10,7 @@ item.get(LedSpriteProperty.X);
### Parameters ### Parameters
* the **sprite** you want to know something about * the **sprite** you want to know something about
* the kind of [number](/reference/types/number) you want to know about the sprite, like * the kind of [number](/types/number) you want to know about the sprite, like
* ``x``, how far up or down the sprite is on the screen (`0`-`4`) * ``x``, how far up or down the sprite is on the screen (`0`-`4`)
* ``y``, how far left or right the sprite is on the screen (`0`-`4`) * ``y``, how far left or right the sprite is on the screen (`0`-`4`)
* ``direction``, which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function) * ``direction``, which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function)
@ -19,7 +19,7 @@ item.get(LedSpriteProperty.X);
### Returns ### Returns
The [number](/reference/types/number) you asked for. The [number](/types/number) you asked for.
### Example ### Example

View File

@ -9,7 +9,7 @@ item.move(1);
### Parameters ### Parameters
* a [number](/reference/types/number) that means how many LEDs the sprite should move * a [number](/types/number) that means how many LEDs the sprite should move
### Example ### Example

View File

@ -7,7 +7,7 @@ game.setScore(1)
``` ```
### Parameters ### Parameters
* a [number](/reference/types/number) that represents the new score. * a [number](/types/number) that represents the new score.
### Examples ### Examples

View File

@ -1,6 +1,6 @@
# Set Sprite Property # Set Sprite Property
Make a [sprite](/reference/game/create-sprite) store the kind of [number](/reference/types/number) you say. Make a [sprite](/reference/game/create-sprite) store the kind of [number](/types/number) you say.
```sig ```sig
let item: game.LedSprite = null; let item: game.LedSprite = null;
@ -10,7 +10,7 @@ item.set(LedSpriteProperty.X, 0);
### Parameters ### Parameters
* the **sprite** you want to make store the number you say * the **sprite** you want to make store the number you say
* the kind of [number](/reference/types/number) you want to store in the sprite, like * the kind of [number](/types/number) you want to store in the sprite, like
* ``x``, how far up or down the sprite is on the screen (`0`-`4`) * ``x``, how far up or down the sprite is on the screen (`0`-`4`)
* ``y``, how far left or right the sprite is on the screen (`0`-`4`) * ``y``, how far left or right the sprite is on the screen (`0`-`4`)
* ``direction``, which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function) * ``direction``, which way the sprite is pointing (this works the same way as the [turn](/reference/game/turn) function)

View File

@ -8,7 +8,7 @@ game.startCountdown(1000)
### Parameters ### Parameters
* ``ms`` is a [number](/reference/types/number) that says how many milliseconds to count down (one second is 1000 milliseconds) * ``ms`` is a [number](/types/number) that says how many milliseconds to count down (one second is 1000 milliseconds)
### Examples ### Examples

View File

@ -10,7 +10,7 @@ item.turn(Direction.Right, 45);
### Parameters ### Parameters
* a choice whether the sprite should turn **left** or **right** * a choice whether the sprite should turn **left** or **right**
* a [number](/reference/types/number) that means how much the sprite should turn. * a [number](/types/number) that means how much the sprite should turn.
This number is in **degrees**, so a straight left or right turn is 90 degrees. This number is in **degrees**, so a straight left or right turn is 90 degrees.
### Example ### Example

View File

@ -16,7 +16,7 @@ images.createBigImage(`
### Parameters ### Parameters
* ``leds`` is a [string](/reference/types/string) that says which LEDs * ``leds`` is a [string](/types/string) that says which LEDs
on the screen should be on and which should be off. on the screen should be on and which should be off.

View File

@ -15,7 +15,7 @@ images.createImage(`
### Parameters ### Parameters
* ``leds`` is a [string](/reference/types/string) that says which LEDs * ``leds`` is a [string](/types/string) that says which LEDs
on the screen should be on and which should be off. on the screen should be on and which should be off.
### Example: Flip-flopping arrow ### Example: Flip-flopping arrow

View File

@ -12,8 +12,8 @@ export function pixel(_this: micro_bit.Image, x: number, y: number) : boolean
### Parameters ### Parameters
* x - [Number](/reference/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image) * x - [Number](/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image)
* y - [Number](/reference/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image) * y - [Number](/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image)
### x, y coordinates? ### x, y coordinates?

View File

@ -12,7 +12,7 @@ export function plotFrame(_this: micro_bit.Image, index: number)
### Parameters ### Parameters
* index - [Number](/reference/types/number); which frame of the image to display * index - [Number](/types/number); which frame of the image to display
### Difference from `plot image` ### Difference from `plot image`

View File

@ -12,7 +12,7 @@ export function plotImage(_this: micro_bit.Image, xOffset: number)
### Parameters ### Parameters
* x offset - [Number](/reference/types/number); the horizontal starting point of an image; use 0 for the first frame of the image, 5 for the second frame of the image, 10 for the third frame and so on. * x offset - [Number](/types/number); the horizontal starting point of an image; use 0 for the first frame of the image, 5 for the second frame of the image, 10 for the third frame and so on.
### Difference from `show image` ### Difference from `show image`

View File

@ -10,7 +10,7 @@ item.scrollImage(5, 200);
### Parameters ### Parameters
* a [number](/reference/types/number) that means * a [number](/types/number) that means
how many LEDs to scroll at a time, from right to left or how many LEDs to scroll at a time, from right to left or
left to right. If you use a positive number like `2`, the image left to right. If you use a positive number like `2`, the image
will scroll from the right side of the screen to the left. will scroll from the right side of the screen to the left.
@ -20,7 +20,7 @@ item.scrollImage(5, 200);
image. It is a square with five LEDs on a side). This is image. It is a square with five LEDs on a side). This is
useful for **animation**. useful for **animation**.
* a [number](/reference/types/number) that means * a [number](/types/number) that means
how many milliseconds to wait before scrolling the amount that how many milliseconds to wait before scrolling the amount that
``offset`` says. (1000 milliseconds is one second.) The bigger you ``offset`` says. (1000 milliseconds is one second.) The bigger you
make this number, the slower the image will scroll. make this number, the slower the image will scroll.

View File

@ -12,8 +12,8 @@ export function setPixel(_this: micro_bit.Image, x: number, y: number, value: bo
### Parameters ### Parameters
* x - [Number](/reference/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image) * x - [Number](/types/number); the *x coordinate* or horizontal position of a pixel in an [image](/reference/images/image)
* x - [Number](/reference/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image) * x - [Number](/types/number); the *y coordinate* or vertical position of a pixel in an [image](/reference/images/image)
* value -[Boolean](/blocks/logic/boolean); the on/off state of a pixel; `true` for on, `false` for off * value -[Boolean](/blocks/logic/boolean); the on/off state of a pixel; `true` for on, `false` for off
### x, y coordinates? ### x, y coordinates?

View File

@ -12,7 +12,7 @@ export function showFrame(img: micro_bit.Image, frame: number)
### Parameters ### Parameters
* index - [Number](/reference/types/number); which frame of the image to display * index - [Number](/types/number); which frame of the image to display
### Difference from `plot frame` ### Difference from `plot frame`

View File

@ -12,7 +12,7 @@ item.showImage(0);
### Parameters ### Parameters
* an [image](/reference/images/image) (picture). It is usually a square with five LEDs on a side, but it might be wider. * an [image](/reference/images/image) (picture). It is usually a square with five LEDs on a side, but it might be wider.
* a [number](/reference/types/number) that says how many LEDs from the left of the picture the @boardname@ should start. `0` means start at the first **frame** of the picture, `5` means start at the second frame, `10` means start at the third, and so on. * a [number](/types/number) that says how many LEDs from the left of the picture the @boardname@ should start. `0` means start at the first **frame** of the picture, `5` means start at the second frame, `10` means start at the third, and so on.
### Example: Flip-flopping arrow ### Example: Flip-flopping arrow

View File

@ -14,7 +14,7 @@ images.createImage().width();
### Returns ### Returns
* [Number](/reference/types/number) - the number of columns in a image. This function returns 5 if the image has 1 frame, 10 for 2 frames, 15 for 3 frames and so on. Divide the number of columns by 5 to find out how many frames an image has (see example below). * [Number](/types/number) - the number of columns in a image. This function returns 5 if the image has 1 frame, 10 for 2 frames, 15 for 3 frames and so on. Divide the number of columns by 5 to find out how many frames an image has (see example below).
The following example gets the width of `img` and stores it in the `w` variable: The following example gets the width of `img` and stores it in the `w` variable:

View File

@ -23,7 +23,7 @@ A **g** is as much acceleration as you get from Earth's gravity.
### Returns ### Returns
* a [number](/reference/types/number) that means the amount of acceleration. When the @boardname@ is lying flat on a surface with the screen pointing up, `x` is `0`, `y` is `0`, and `z` is `-1023`. * a [number](/types/number) that means the amount of acceleration. When the @boardname@ is lying flat on a surface with the screen pointing up, `x` is `0`, `y` is `0`, and `z` is `-1023`.
### Example: bar chart ### Example: bar chart

View File

@ -8,7 +8,7 @@ input.buttonIsPressed(Button.A);
### Parameters ### Parameters
* ``button`` is a [String](/reference/types/string). You should store `A` in it to check the left button, `B` to check the right button, or `A+B` to check both at the same time. * ``button`` is a [String](/types/string). You should store `A` in it to check the left button, `B` to check the right button, or `A+B` to check both at the same time.
### Returns ### Returns

View File

@ -12,7 +12,7 @@ input.compassHeading();
### Returns ### Returns
* a [number](/reference/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 `360` degrees, which means the compass heading. If the compass isn't ready, it returns `-1003`.
### Example ### Example

View File

@ -16,7 +16,7 @@ input.lightLevel();
### Returns ### Returns
* a [Number](/reference/types/number) that means a light level from ``0`` (dark) to ``255`` (bright). * a [Number](/types/number) that means a light level from ``0`` (dark) to ``255`` (bright).
### Example: show light level ### Example: show light level

View File

@ -22,7 +22,7 @@ The @boardname@ measures magnetic force with **microteslas**.
### Returns ### Returns
* a [number](/reference/types/number) of microteslas that means the strength of the magnet * a [number](/types/number) of microteslas that means the strength of the magnet
### Example: metal detector ### Example: metal detector

View File

@ -19,7 +19,7 @@ instead of the USB cable.
### Parameters ### Parameters
* a [string](/reference/types/string) that holds the pin name (**P0**, **P1**, or **P2**) * a [string](/types/string) that holds the pin name (**P0**, **P1**, or **P2**)
### returns ### returns

View File

@ -19,7 +19,7 @@ check how the @boardname@ is moving.
### Returns ### Returns
* a [number](/reference/types/number) that means how much the microbit is tilted in the direction you say, from `0` to `360` degrees * a [number](/types/number) that means how much the microbit is tilted in the direction you say, from `0` to `360` degrees
### Example: @boardname@ leveler ### Example: @boardname@ leveler

View File

@ -8,7 +8,7 @@ input.runningTime();
### Returns ### Returns
* the [Number](/reference/types/number) of milliseconds since the program started. * the [Number](/types/number) of milliseconds since the program started.
(One second is 1000 milliseconds.) (One second is 1000 milliseconds.)
### Example: elapsed time ### Example: elapsed time

View File

@ -9,7 +9,7 @@ input.temperature();
### Returns ### Returns
* a [Number](/reference/types/number) that means the Celsius temperature. * a [Number](/types/number) that means the Celsius temperature.
### How does it work? ### How does it work?

View File

@ -8,7 +8,7 @@ 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

View File

@ -8,7 +8,7 @@ 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

View File

@ -8,7 +8,7 @@ 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

View File

@ -8,7 +8,7 @@ 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

View File

@ -9,11 +9,11 @@ led.plotBarGraph(2, 20);
### Parameters ### Parameters
* ``value`` is a [number](/reference/types/number) that means what you * ``value`` is a [number](/types/number) that means what you
are measuring or trying to show. For example, if you are measuring are measuring or trying to show. For example, if you are measuring
the temperature of ice with the @boardname@, ``value`` might be `0` the temperature of ice with the @boardname@, ``value`` might be `0`
because the temperature might be 0 degrees centigrade. because the temperature might be 0 degrees centigrade.
* ``high`` is a [number](/reference/types/number) that means the highest * ``high`` is a [number](/types/number) that means the highest
possible number that the ``value`` parameter can be. This number is possible number that the ``value`` parameter can be. This number is
also the tallest that the lines in the bar chart can be. also the tallest that the lines in the bar chart can be.

View File

@ -14,10 +14,10 @@ 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, horizontal spot on the LED screen (from left to right: 0, 1, 2, 3,
or 4) 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) 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 If a parameter is [out of bounds](/reference/out-of-bounds) (a value

View File

@ -9,10 +9,10 @@ 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, horizontal spot on the LED screen (from left to right: 0, 1, 2, 3,
or 4) 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) 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 If a parameter is [out of bounds](/reference/out-of-bounds) (a value

View File

@ -9,7 +9,7 @@ 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 bright the screen is when it is turned on, from `0` (darkest) to
`255` (brightest). For example, the number `127` means the screen is `255` (brightest). For example, the number `127` means the screen is
halfway bright when it is turned on. halfway bright when it is turned on.

View File

@ -8,8 +8,8 @@ led.toggle(0,0)
### Parameters ### Parameters
* x - [Number](/reference/types/number); the *x coordinate* or horizontal position (0, 1, 2, 3, 4) * x - [Number](/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) * 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. If a parameter is [out of bounds](/reference/out-of-bounds) (a value other than 0-4), then this function will do nothing.

View File

@ -14,10 +14,10 @@ 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, horizontal spot on the LED screen (from left to right: 0, 1, 2, 3,
or 4) 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) 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 If a parameter is [out of bounds](/reference/out-of-bounds) (a value

View File

@ -16,7 +16,7 @@ music.beat(BeatFraction.Whole)
### Returns ### Returns
* a [number](/reference/types/number) that means the amount of milli-seconds a beat fraction represents. * a [number](/types/number) that means the amount of milli-seconds a beat fraction represents.
## Example ## Example

View File

@ -13,7 +13,7 @@ music.changeTempoBy(20)
### Parameters ### Parameters
* ``bpm`` is a [number](/reference/types/number) that says how much to * ``bpm`` is a [number](/types/number) that says how much to
change the bpm (beats per minute, or number of beats in a minute of change the bpm (beats per minute, or number of beats in a minute of
the music that the @boardname@ is playing). the music that the @boardname@ is playing).

View File

@ -12,8 +12,8 @@ music.playTone(440, 120)
### Parameters ### Parameters
* ``frequency`` is the [number](/reference/types/number) of Hertz (how high or low the tone is). * ``frequency`` is the [number](/types/number) of Hertz (how high or low the tone is).
* ``ms`` is the [number](/reference/types/number) of milliseconds that the tone lasts * ``ms`` is the [number](/types/number) of milliseconds that the tone lasts
## Example ## Example

View File

@ -12,7 +12,7 @@ music.rest(400)
### Parameters ### Parameters
* ``ms`` is a [number](/reference/types/number) saying how many * ``ms`` is a [number](/types/number) saying how many
milliseconds the @boardname@ should rest. One second is 1000 milliseconds the @boardname@ should rest. One second is 1000
milliseconds. milliseconds.

View File

@ -13,7 +13,7 @@ music.ringTone(440)
### Parameters ### Parameters
* ``frequency`` is a [number](/reference/types/number) that says * ``frequency`` is a [number](/types/number) that says
how high-pitched or low-pitched the tone is. This how high-pitched or low-pitched the tone is. This
number is in **Hz** (**Hertz**), which is a measurement of frequency number is in **Hz** (**Hertz**), which is a measurement of frequency
or pitch. or pitch.

View File

@ -11,7 +11,7 @@ This function only works on the @boardname@ and in some browsers.
### Parameters ### Parameters
* ``bpm`` is a [number](/reference/types/number) that means the beats per minute you want (the number of beats in a minute of the music that the @boardname@ is playing). * ``bpm`` is a [number](/types/number) that means the beats per minute you want (the number of beats in a minute of the music that the @boardname@ is playing).
### See also ### See also

View File

@ -8,7 +8,7 @@ music.tempo()
### Returns ### Returns
* a [number](/reference/types/number) that means the beats per minute (number of * a [number](/types/number) that means the beats per minute (number of
beats in a minute of the music that the @boardname@ is playing). beats in a minute of the music that the @boardname@ is playing).
### See also ### See also

View File

@ -9,8 +9,8 @@ pins.analogPitch(440, 300)
### Parameters ### Parameters
* `frequency` : [Number](/reference/types/number) * `frequency` : [Number](/types/number)
* `ms`: [Number](/reference/types/number) * `ms`: [Number](/types/number)
### Example ### Example

View File

@ -9,12 +9,12 @@ pins.analogReadPin(AnalogPin.P0)
### Parameters ### Parameters
* ``name`` is a [string](/reference/types/string) with the name of the pin * ``name`` is a [string](/types/string) with the name of the pin
you say (`P0` through `P4`, or `P10`) you say (`P0` through `P4`, or `P10`)
### Returns ### Returns
* a [number](/reference/types/number) from `0` through `1023` * a [number](/types/number) from `0` through `1023`
This program reads pin `P1` and shows the number This program reads pin `P1` and shows the number
on the LED screen. on the LED screen.

View File

@ -10,8 +10,8 @@ pins.analogSetPeriod(AnalogPin.P0, 20000)
### Parameters ### Parameters
* ``name``: a [string](/reference/types/string) that specifies the pin to configure (`P0` through `P4`, or `P10`) * ``name``: a [string](/types/string) that specifies the pin to configure (`P0` through `P4`, or `P10`)
* ``micros``: a [number](/reference/types/number) that specifies the analog period in microseconds. * ``micros``: a [number](/types/number) that specifies the analog period in microseconds.
The following code first sets `P0` to analog with **analog write The following code first sets `P0` to analog with **analog write
pin**, and then sets the PWM period of `P0` to 20,000 microseconds. pin**, and then sets the PWM period of `P0` to 20,000 microseconds.

View File

@ -8,7 +8,7 @@ pins.analogSetPitchPin(AnalogPin.P0)
### Parameters ### Parameters
* `name` - [String](/reference/types/string); the pin name ("P0", "P1", or "P2") * `name` - [String](/types/string); the pin name ("P0", "P1", or "P2")
### Example ### Example

View File

@ -9,8 +9,8 @@ pins.analogWritePin(AnalogPin.P0, 400)
### Parameters ### Parameters
* ``name`` is a [string](/reference/types/string) that is the pin name you say (`P0` through `P4`, or `P10`) * ``name`` is a [string](/types/string) that is the pin name you say (`P0` through `P4`, or `P10`)
* ``value`` is a [number](/reference/types/number) from `0` through `1023` * ``value`` is a [number](/types/number) from `0` through `1023`
### Example ### Example

View File

@ -16,11 +16,11 @@ Please read the [page about pins](/device/pins) carefully.
### Parameters ### Parameters
* ``name`` is a [string](/reference/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``) * ``name`` is a [string](/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``)
### Returns ### Returns
* a [number](/reference/types/number) that can be `0` or `1` * a [number](/types/number) that can be `0` or `1`
### Example: football score keeper ### Example: football score keeper

View File

@ -16,8 +16,8 @@ Please read the [page about pins](/device/pins) carefully.
### Parameters ### Parameters
* ``name`` is a [string](/reference/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``) * ``name`` is a [string](/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``)
* ``value`` is a [number](/reference/types/number) that can be either `0` or `1` * ``value`` is a [number](/types/number) that can be either `0` or `1`
### Example: football score keeper ### Example: football score keeper

View File

@ -16,11 +16,11 @@ pins.map(0, 0, 4, 0, 1023);
### Parameters ### Parameters
* ``value``: a [number](/reference/types/number) that specifies the value to map * ``value``: a [number](/types/number) that specifies the value to map
* ``fromLow``: a [number](/reference/types/number) that specifies the lower bound of the origin interval * ``fromLow``: a [number](/types/number) that specifies the lower bound of the origin interval
* ``fromHigh``: a [number](/reference/types/number) that specifies the upper bound of the origin interval * ``fromHigh``: a [number](/types/number) that specifies the upper bound of the origin interval
* ``toLow``: a [number](/reference/types/number) that specifies the lower bound of the target interval * ``toLow``: a [number](/types/number) that specifies the lower bound of the target interval
* ``toHigh``: a [number](/reference/types/number) that specifies the upper bound of the target interval * ``toHigh``: a [number](/types/number) that specifies the upper bound of the target interval
## Example ## Example

View File

@ -16,13 +16,13 @@ Please read the [page about pins](/device/pins) carefully.
### Parameters ### Parameters
* ``name`` is a [string](/reference/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``) * ``name`` is a [string](/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``)
* ``value`` is the value of the pulse, ``high`` or ``low`` * ``value`` is the value of the pulse, ``high`` or ``low``
* ``maxDuration``, maximum duration in micro-seconds. If no pulse is received * ``maxDuration``, maximum duration in micro-seconds. If no pulse is received
### Returns ### Returns
* a [number](/reference/types/number) that represents the pulse duration in micro-seconds * a [number](/types/number) that represents the pulse duration in micro-seconds
### Example: Measuring distance with a sonar ### Example: Measuring distance with a sonar

View File

@ -9,8 +9,8 @@ pins.servoSetPulse(AnalogPin.P1, 1500)
### Parameters ### Parameters
* ``name``: a [string](/reference/types/string) that specifies the pin to configure (`P0` through `P4`, or `P10`) * ``name``: a [string](/types/string) that specifies the pin to configure (`P0` through `P4`, or `P10`)
* ``micros``: a [number](/reference/types/number) that specifies the analog period in microseconds. * ``micros``: a [number](/types/number) that specifies the analog period in microseconds.
### Example ### Example

View File

@ -14,8 +14,8 @@ pins.servoWritePin(AnalogPin.P0, 180)
### Parameters ### Parameters
* ``name``: a [string](/reference/types/string) that specifies the pin name (`P0` through `P4`, or `P10`) * ``name``: a [string](/types/string) that specifies the pin name (`P0` through `P4`, or `P10`)
* ``value``: a [number](/reference/types/number) from `0` through `180` * ``value``: a [number](/types/number) from `0` through `180`
### Examples ### Examples

View File

@ -12,7 +12,7 @@ pins.spiWrite(0);
### Returns ### Returns
* a [number](/reference/types/number) Response from the SPI slave * a [number](/types/number) Response from the SPI slave
### See also ### See also

View File

@ -1,7 +1,7 @@
# On Data Packet Received # On Data Packet Received
Run part of a program when the @boardname@ receives a Run part of a program when the @boardname@ receives a
[number](/reference/types/number) or [string](/reference/types/string) over ``radio``. [number](/types/number) or [string](/types/string) over ``radio``.
```sig ```sig
@ -17,8 +17,8 @@ To add or remove the parts of the packet from the block, try clicking the blue g
### Callback Parameters ### Callback Parameters
* ``packet`` - the [packet](/reference/radio/packet) that was received by the radio. The packet has the following properties: * ``packet`` - the [packet](/reference/radio/packet) that was received by the radio. The packet has the following properties:
* `receivedNumber` - The [number](/reference/types/number) that was sent in this packet or `0` if this packet did not contain a number. See [send number](/reference/radio/send-number) and [send value](/reference/radio/send-value) * `receivedNumber` - The [number](/types/number) that was sent in this packet or `0` if this packet did not contain a number. See [send number](/reference/radio/send-number) and [send value](/reference/radio/send-value)
* `receivedString` - The [string](/reference/types/string) that was sent in this packet or the empty string if this packet did not contain a string. See [send string](/reference/radio/send-string) and [send value](/reference/radio/send-value) * `receivedString` - The [string](/types/string) that was sent in this packet or the empty string if this packet did not contain a string. See [send string](/reference/radio/send-string) and [send value](/reference/radio/send-value)
* `time` - The system time of the @boardname@ that sent this packet at the time the packet was sent. * `time` - The system time of the @boardname@ that sent this packet at the time the packet was sent.
* `serial` - The serial number of the @boardname@ that sent this packet or `0` if the @boardname@ did not include its serial number. * `serial` - The serial number of the @boardname@ that sent this packet or `0` if the @boardname@ did not include its serial number.
* `signal` - How strong the radio signal is from `-128` (weak) to `-42` (strong). * `signal` - How strong the radio signal is from `-128` (weak) to `-42` (strong).

View File

@ -3,7 +3,7 @@
> Note: This API has been deprecated! Use [on data packet received](/reference/radio/on-data-packet-received) instead. > Note: This API has been deprecated! Use [on data packet received](/reference/radio/on-data-packet-received) instead.
Run part of a program when the @boardname@ receives a Run part of a program when the @boardname@ receives a
[number](/reference/types/number) or [string](/reference/types/string) over ``radio``. [number](/types/number) or [string](/types/string) over ``radio``.
```sig ```sig

View File

@ -4,8 +4,8 @@ A packet that was received by the radio.
## Properties ## Properties
* `receivedNumber` - The [number](/reference/types/number) that was sent in this packet or `0` if this packet did not contain a number. See [send number](/reference/radio/send-number) and [send value](/reference/radio/send-value) * `receivedNumber` - The [number](/types/number) that was sent in this packet or `0` if this packet did not contain a number. See [send number](/reference/radio/send-number) and [send value](/reference/radio/send-value)
* `receivedString` - The [string](/reference/types/string) that was sent in this packet or the empty string if this packet did not contain a string. See [send string](/reference/radio/send-string) and [send value](/reference/radio/send-value) * `receivedString` - The [string](/types/string) that was sent in this packet or the empty string if this packet did not contain a string. See [send string](/reference/radio/send-string) and [send value](/reference/radio/send-value)
* `time` - The system time of the @boardname@ that sent this packet at the time the packet was sent. * `time` - The system time of the @boardname@ that sent this packet at the time the packet was sent.
* `serial` - The serial number of the @boardname@ that sent this packet or `0` if the @boardname@ did not include its serial number. * `serial` - The serial number of the @boardname@ that sent this packet or `0` if the @boardname@ did not include its serial number.
* `signal` - How strong the radio signal is from `255` (weak) to `0` (strong). * `signal` - How strong the radio signal is from `255` (weak) to `0` (strong).

View File

@ -10,7 +10,7 @@ radio.receiveNumber();
### Returns ### Returns
* the first [number](/reference/types/number) that the @boardname@ received. If it did not receive any numbers, this function will return `0`. * the first [number](/types/number) that the @boardname@ received. If it did not receive any numbers, this function will return `0`.
### Example: Simple number receiver ### Example: Simple number receiver

View File

@ -10,7 +10,7 @@ radio.receiveString()
### Returns ### Returns
* the first [string](/reference/types/string) that was sent. If no * the first [string](/types/string) that was sent. If no
string was sent, then this function returns an empty (blank) string. string was sent, then this function returns an empty (blank) string.
### Example: Simple receiver ### Example: Simple receiver

View File

@ -16,7 +16,7 @@ radio.receivedSignalStrength();
### Returns ### Returns
* a [number](/reference/types/number) between `-128` and `-42` that means * a [number](/types/number) between `-128` and `-42` that means
how strong the signal is. how strong the signal is.
### Simulator ### Simulator

View File

@ -1,6 +1,6 @@
# Send Number # Send Number
Broadcast a [number](/reference/types/number) to other @boardname@s connected via ``radio``. Broadcast a [number](/types/number) to other @boardname@s connected via ``radio``.
```sig ```sig
radio.sendNumber(0); radio.sendNumber(0);
@ -8,7 +8,7 @@ radio.sendNumber(0);
### Parameters ### Parameters
* ``value`` - a [number](/reference/types/number) to send. * ``value`` - a [number](/types/number) to send.
### Example: Broadcasting acceleration ### Example: Broadcasting acceleration

View File

@ -9,7 +9,7 @@ radio.sendString("Hello!")
### Parameters ### Parameters
* `msg` is a [string](/reference/types/string) to send by radio. * `msg` is a [string](/types/string) to send by radio.
### Example: Two-way radio ### Example: Two-way radio

View File

@ -9,8 +9,8 @@ radio.sendValue("name", 0);
### Parameters ### Parameters
* ``name`` is a [string](/reference/types/string) to send by radio * ``name`` is a [string](/types/string) to send by radio
* ``value`` a [number](/reference/types/number) to send by radio * ``value`` a [number](/types/number) to send by radio
### Example: Broadcasting acceleration ### Example: Broadcasting acceleration

View File

@ -16,7 +16,7 @@ radio.setGroup(0);
### Parameters ### Parameters
* ``id`` is a [number](/reference/types/number) from ``0`` to ``255``. * ``id`` is a [number](/types/number) from ``0`` to ``255``.
### Simulator ### Simulator

View File

@ -20,7 +20,7 @@ can reach as far as 70 meters (about 230 feet).
### Parameters ### Parameters
* ``power`` is a [number](/reference/types/number) between ``0`` and ``7`` that * ``power`` is a [number](/types/number) between ``0`` and ``7`` that
means how strong the signal is. means how strong the signal is.
### Simulator ### Simulator

View File

@ -8,7 +8,7 @@ radio.setTransmitSerialNumber(true);
### Parameters ### Parameters
* ``transmit`` is a [boolean](/reference/types/boolean) that represents whether the serial number needs to be transmitted. * ``transmit`` is a [boolean](/types/boolean) that represents whether the serial number needs to be transmitted.
### Example ### Example

View File

@ -9,7 +9,7 @@ serial.onDataReceived(",", () => {})
### Parameters ### Parameters
* `delimiters` is a [string](/reference/types/string) containing any of the character to match * `delimiters` is a [string](/types/string) containing any of the character to match
### Example ### Example

View File

@ -16,7 +16,7 @@ character. If your terminal software does not terminate lines with
### Returns ### Returns
* a [string](/reference/types/string) containing input from the serial port, such as a response typed by a user * a [string](/types/string) containing input from the serial port, such as a response typed by a user
### Example ### Example

View File

@ -8,7 +8,7 @@ serial.readString();
### Returns ### Returns
* a [string](/reference/types/string) containing input from the serial port. Empty if no data available. * a [string](/types/string) containing input from the serial port. Empty if no data available.
### Example ### Example

View File

@ -8,7 +8,7 @@ serial.readUntil(",");
### Returns ### Returns
* a [string](/reference/types/string) containing input from the serial port, such as a response typed by a user * a [string](/types/string) containing input from the serial port, such as a response typed by a user
### Example ### Example

View File

@ -9,7 +9,7 @@ serial.writeLine("");
### Parameters ### Parameters
* `text` is the [string](/reference/types/string) to write to the serial port * `text` is the [string](/types/string) to write to the serial port
### Example: simple serial ### Example: simple serial

View File

@ -8,7 +8,7 @@ serial.writeNumber(0);
### Parameters ### Parameters
* `value` is the [number](/reference/types/number) to write to the serial port * `value` is the [number](/types/number) to write to the serial port
### Example: one through ten ### Example: one through ten

View File

@ -9,7 +9,7 @@ serial.writeString("");
### Parameters ### Parameters
* `text` is the [string](/reference/types/string) to write to the serial port * `text` is the [string](/types/string) to write to the serial port
### Example: simple serial ### Example: simple serial

View File

@ -8,8 +8,8 @@ serial.writeValue("x", 0);
### Parameters ### Parameters
* `name` is the [string](/reference/types/string) to write to the serial port * `name` is the [string](/types/string) to write to the serial port
* `value` is the [number](/reference/types/number) to write to the serial port * `value` is the [number](/types/number) to write to the serial port

View File

@ -1,11 +0,0 @@
# types
A *type* refers to a class of data and the operations permitted on that class of data.
The following built-in types are supported for the @boardname@:
* **[String](/reference/types/string)**: a sequence of characters
* **[Number](/reference/types/number)**: an integer number (32-bit signed)
* **[Boolean](/blocks/logic/boolean)**: true or false
* **[Image](/reference/images/image)**: a collection of [@boardname@ LED states](/device/screen) (on/off)
TypeScript allows you to create user-defined classes of data.

View File

@ -1,16 +0,0 @@
# Boolean
true or false.
A Boolean has one of two possible values: `true`; `false`. Boolean (logical) operators (*and*, *or*, *not*) take Boolean inputs and yields a Boolean value. Comparison operators on other types ([numbers](/reference/types/number), [strings](/reference/types/string) yields a Boolean value.
The following blocks represent the true and false Boolean values, which can be plugged in anywhere a Boolean value is expected:
```blocks
true;
false;
```
### See Also
[boolean (blocks)](/blocks/logic/boolean)

View File

@ -1,71 +0,0 @@
# Number
An integer number.
### @parent blocks/language
A *Number* is an integer such as `42` or `-42`. More precisely, a *Number* is a signed 32-bit integer (two's complement).
### Declare a number variable
You can assign a number to a variable:
```blocks
let num = 42;
basic.showNumber(42);
```
### Arithmetic operators
The following arithmetic operators work on numbers and return a [Number](/reference/types/number):
* addition: `1 + 3`
* subtraction: `1 - 3 `
* multiplication: `3 * 2`
* integer division: `7 / 3`
* modulo is available through the [math library](/blocks/math)
### Relational operators
The following relational operators work on numbers and return a [Boolean](/blocks/logic/boolean):
* equality: `(3 + 1) = 4`
* inequality: `3 != 4`
* less or equal than: `3 <= 4`
* less than: `3 < 4`
* greater or equal than : `4 >= 3`
* greater than: `4 > 3`
### Show number
The [show number](/reference/basic/show-number) function displays a number on the [LED screen](/device/screen).
For example, this code displays the number 42:
```blocks
basic.showNumber(42);
```
### Functions that return a number
Some functions return a number, which you can store in a variable.
For example the following code gets the display brightness
(using the [brightness function](/reference/led/brightness)) and stores the value in a variable named `brightness`:
```blocks
let brightness = led.brightness()
```
### Math functions
The [math library](/blocks/math) includes math related functions.
For example, the `absolute` function returns the returns the absolute value of input parameter `x`:
```blocks
let abs = Math.abs(-42);
basic.showNumber(abs);
```
### See also
[math](/blocks/math), [var](/blocks/variables/var), [Boolean](/blocks/logic/boolean), [show number](/reference/basic/show-number)

View File

@ -1,3 +0,0 @@
# String functions
TBD

View File

@ -1,45 +0,0 @@
# String
a piece of text.
### @parent blocks/language
A *String* is a sequence of characters. For the @boardname@, ASCII character codes 32 to 126 are supported; letters, digits, punctuation marks, and a few symbols. All other character codes appear as a ? on the [LED screen](/device/screen).
### Create a string variable
```block
let salutation = "Hello";
```
To create a variable that holds a string:
1. Click `Variables` (in the Block drawer).
2. Type a name for your new string variable by clicking the down arrow, then click New Variable. Then type the variable name "salutation"
2. Drag a string block on the right side of the operator.
3. Click `"Hello"` and then type a string like `hello`.
Your code should look something like this:
```block
let salutation = "Hello";
```
### The function `show string`
Use [show string](/reference/basic/show-string) to display a string on the [LED screen](/device/screen).
If the string is multiple characters, the string scrolls right to left. The following example displays `Hello world!` on the @boardname@ screen:
```block
basic.showString("Hello world!");
```
The parameter of `show string` specifies the string
### See also
[string functions](/reference/types/string-functions), [Number](/reference/types/number), [show string](/reference/basic/show-string)

9
docs/types/string.md Normal file
View File

@ -0,0 +1,9 @@
# @extends
## #intro
### ~ hint
For the @boardname@, ASCII character codes 32 to 126 are supported; letters, digits, punctuation marks, and a few symbols. All other character codes appear as a ? on the [LED screen](/device/screen).
### ~

View File

@ -12,12 +12,12 @@ The Bits library includes functions for bit-level manipulation of integers. In t
#### Syntax #### Syntax
bits `->` *and/or/xor* uint32 (x : [Number](/reference/types/number), y : [Number](/reference/types/number)) *returns* [Number](/reference/types/number) bits `->` *and/or/xor* uint32 (x : [Number](/types/number), y : [Number](/types/number)) *returns* [Number](/types/number)
#### Parameters #### Parameters
* x - an unsigned 32 bit integer [Number](/reference/types/number) * x - an unsigned 32 bit integer [Number](/types/number)
* y - another unsigned 32 bit integer [Number](/reference/types/number) * y - another unsigned 32 bit integer [Number](/types/number)
### and uint32 ### and uint32
@ -37,14 +37,14 @@ Rotate bits to the left or the right, by the specified number of positions.
#### Syntax #### Syntax
bits `->` rotate left unint32 (x : [Number](/reference/types/number), bits : [Number](/reference/types/number)) *returns* [Number](/reference/types/number) bits `->` rotate left unint32 (x : [Number](/types/number), bits : [Number](/types/number)) *returns* [Number](/types/number)
bits `->` rotate right unint32 (x : [Number](/reference/types/number), bits : [Number](/reference/types/number)) *returns* [Number](/reference/types/number) bits `->` rotate right unint32 (x : [Number](/types/number), bits : [Number](/types/number)) *returns* [Number](/types/number)
#### Parameters #### Parameters
* x - [Number](/reference/types/number); * x - [Number](/types/number);
* bits - [Number](/reference/types/number); * bits - [Number](/types/number);
## Shift left and shift right ## Shift left and shift right
@ -52,16 +52,16 @@ Shift bits to the left or the right, by the specified number of positions.
#### Syntax #### Syntax
bits `->` shift left unint32 (x : [Number](/reference/types/number), bits : [Number](/reference/types/number)) *returns* [Number](/reference/types/number) bits `->` shift left unint32 (x : [Number](/types/number), bits : [Number](/types/number)) *returns* [Number](/types/number)
bits `->` shift right unint32 (x : [Number](/reference/types/number), bits : [Number](/reference/types/number)) *returns* [Number](/reference/types/number) bits `->` shift right unint32 (x : [Number](/types/number), bits : [Number](/types/number)) *returns* [Number](/types/number)
#### Parameters #### Parameters
* x - [Number](/reference/types/number); * x - [Number](/types/number);
* bits - [Number](/reference/types/number); * bits - [Number](/types/number);
### See also ### See also
[statements and operators](/javascript/statements), [math functions](/javascript/math), [Number](/reference/types/number) [statements and operators](/javascript/statements), [math functions](/javascript/math), [Number](/types/number)

View File

@ -19,7 +19,7 @@ Type a function name in your code to call an existing [function](/javascript/fun
### Example: the square function ### Example: the square function
Here's a function called `square`, with a [Number](/reference/types/number) input parameter: Here's a function called `square`, with a [Number](/types/number) input parameter:
``` ```
/** /**

View File

@ -31,9 +31,9 @@ Welcome to the Touch Develop home page for the @boardname@. Below you will find
### Types ### Types
* [Number](/reference/types/number) * [Number](/types/number)
* [Boolean](/reference/types/boolean) * [Boolean](/types/boolean)
* [String](/reference/types/string) * [String](/types/string)
* [Image](/reference/images/image) * [Image](/reference/images/image)
### Statements and control structures ### Statements and control structures
@ -50,19 +50,19 @@ Welcome to the Touch Develop home page for the @boardname@. Below you will find
### Maths ### Maths
* arithmetic operators (`+`, `-`, `*`, `/`, mod) on [Numbers](/reference/types/number) * arithmetic operators (`+`, `-`, `*`, `/`, mod) on [Numbers](/types/number)
* comparison operators (such as `>`, `=`) on [Numbers](/reference/types/number) * comparison operators (such as `>`, `=`) on [Numbers](/types/number)
* the [math](/js/math) library * the [math](/js/math) library
* the [bits](/js/bits) library * the [bits](/js/bits) library
### Logical ### Logical
* [Boolean](/reference/types/boolean) values `true` and `false` * [Boolean](/types/boolean) values `true` and `false`
* Operations (`not`, `or`, `and`) on [Booleans](/reference/types/boolean) * Operations (`not`, `or`, `and`) on [Booleans](/types/boolean)
### Strings ### Strings
* [string functions](/reference/types/string-functions) * [string functions](/types/string-functions)
### Functions ### Functions

View File

@ -61,8 +61,8 @@ export function square(x: number) : number {
In the above code... In the above code...
* ``x `` is the [input parameter](/js/functionparameters) ([Number](/reference/types/number) type) * ``x `` is the [input parameter](/js/functionparameters) ([Number](/types/number) type)
* ``result`` is the [output parameter](/js/functionparameters) ([Number](/reference/types/number) type) * ``result`` is the [output parameter](/js/functionparameters) ([Number](/types/number) type)
* `return x * x` is the function body (which returns the value of the expression `x * x`) * `return x * x` is the function body (which returns the value of the expression `x * x`)
### Add function parameters ### Add function parameters

Some files were not shown because too many files have changed in this diff Show More