/reference/types -> /types
This commit is contained in:
parent
69bd0225ad
commit
00e9217e73
@ -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.
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Assignment Operator
|
||||
|
||||
Use an equals sign to make a [variable](/blocks/variables/var) store the [number](/reference/types/number)
|
||||
or [string](/reference/types/string) you say.
|
||||
Use an equals sign to make a [variable](/blocks/variables/var) store the [number](/types/number)
|
||||
or [string](/types/string) you say.
|
||||
|
||||
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*.
|
||||
@ -27,10 +27,10 @@ basic.showString(name);
|
||||
### Notes
|
||||
|
||||
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.
|
||||
|
||||
### See also
|
||||
|
||||
[variable](/blocks/variables/var), [types](/reference/types)
|
||||
[variable](/blocks/variables/var), [types](/types)
|
||||
|
||||
|
@ -4,7 +4,7 @@ How to define and use local variables.
|
||||
|
||||
### @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
|
||||
* *type* refers to the kind of data a variable can store
|
||||
@ -83,5 +83,5 @@ if (led.brightness() > 128) {
|
||||
|
||||
### See also
|
||||
|
||||
[types](/reference/types), [assignment operator](/blocks/variables/assign)
|
||||
[types](/types), [assignment operator](/blocks/variables/assign)
|
||||
|
||||
|
@ -35,7 +35,7 @@ basic.showLeds(`
|
||||
```
|
||||
|
||||
* **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)
|
||||
* **show number** : [read more...](/reference/basic/show-number)
|
||||
|
||||
|
@ -44,4 +44,4 @@ bluetooth
|
||||
|
||||
### 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)
|
||||
|
@ -33,7 +33,7 @@ basic.forever(() => {
|
||||
|
||||
### Example: counter
|
||||
|
||||
The following example keeps showing the [number](/reference/types/number) stored in a global variable.
|
||||
The following example keeps showing the [number](/types/number) stored in a global variable.
|
||||
When you press button `A`, the number gets bigger.
|
||||
You can use a program like this to count things with your @boardname@.
|
||||
|
||||
|
@ -14,8 +14,8 @@ basic.showAnimation(`
|
||||
|
||||
### Parameters
|
||||
|
||||
* `leds` is a [String](/reference/types/string) that shows which LEDs are on and off, in groups one after another.
|
||||
* `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds to pause after each image frame.
|
||||
* `leds` is a [String](/types/string) that shows which LEDs are on and off, in groups one after another.
|
||||
* `interval` is an optional [Number](/types/number). It means the number of milliseconds to pause after each image frame.
|
||||
|
||||
### Example: Animating a group of image frames
|
||||
|
||||
|
@ -15,8 +15,8 @@ basic.showLeds(`
|
||||
|
||||
### Parameters
|
||||
|
||||
* `leds` is a [string](/reference/types/string) that controls which LEDs are on and off.
|
||||
* `interval` is an optional [number](/reference/types/number) that means how many milliseconds to wait after showing a picture.
|
||||
* `leds` is a [string](/types/string) that controls which LEDs are on and off.
|
||||
* `interval` is an optional [number](/types/number) that means how many milliseconds to wait after showing a picture.
|
||||
If you are programming with blocks, `interval` is set at 400 milliseconds.
|
||||
|
||||
### Example
|
||||
|
@ -8,8 +8,8 @@ basic.showNumber(2)
|
||||
|
||||
### Parameters
|
||||
|
||||
* `value` is a [Number](/reference/types/number).
|
||||
* `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
|
||||
* `value` is a [Number](/types/number).
|
||||
* `interval` is an optional [Number](/types/number). It means the number of milliseconds before sliding the `value` left by one LED each time. Bigger intervals make the sliding slower.
|
||||
|
||||
### Examples:
|
||||
|
||||
@ -39,10 +39,10 @@ for (let i = 0; i < 6; i++) {
|
||||
|
||||
### Other show functions
|
||||
|
||||
* Use [show string](/reference/basic/show-string) to show a [String](/reference/types/string) with letters on the screen.
|
||||
* Use [show string](/reference/basic/show-string) to show a [String](/types/string) with letters on the screen.
|
||||
* Use [show animation](/reference/basic/show-animation) to show a group of pictures on the screen, one after another.
|
||||
|
||||
### See also
|
||||
|
||||
[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)
|
||||
|
||||
|
@ -8,8 +8,8 @@ basic.showString("Hello!")
|
||||
|
||||
### Parameters
|
||||
|
||||
* `text` is a [String](/reference/types/string). It can contain letters, numbers, and punctuation.
|
||||
* `interval` is an optional [Number](/reference/types/number). It means the number of milliseconds before sliding the [String](/reference/types/string) left by one LED each time. Bigger intervals make the sliding slower.
|
||||
* `text` is a [String](/types/string). It can contain letters, numbers, and punctuation.
|
||||
* `interval` is an optional [Number](/types/number). It means the number of milliseconds before sliding the [String](/types/string) left by one LED each time. Bigger intervals make the sliding slower.
|
||||
|
||||
### Examples:
|
||||
|
||||
@ -19,7 +19,7 @@ To show the word **Hello**:
|
||||
basic.showString("Hello")
|
||||
```
|
||||
|
||||
To show what is stored in a [String](/reference/types/string) variable:
|
||||
To show what is stored in a [String](/types/string) variable:
|
||||
|
||||
```blocks
|
||||
let s = "Hi"
|
||||
@ -33,5 +33,5 @@ basic.showString(s)
|
||||
|
||||
### 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)
|
||||
|
||||
|
@ -24,7 +24,7 @@ bluetooth.advertiseUidBuffer(pins.createBuffer(16), 7, true);
|
||||
### Parameters
|
||||
|
||||
* ``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.
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ bluetooth.advertiseUid(42, 1, 7, true);
|
||||
|
||||
* ``namespace`` last 4 bytes of the namespace uid (6 to 9)
|
||||
* ``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.
|
||||
|
||||
## Encoding
|
||||
|
@ -23,8 +23,8 @@ bluetooth.advertiseUrl("https://pxt.microbit.org/", 7, true);
|
||||
|
||||
### 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.
|
||||
* ``power`` - a [number](/reference/types/number) representing the power level between 0 (short) and 7 (maximum range).
|
||||
* ``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](/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.
|
||||
|
||||
### Example: Broadcast a secret code
|
||||
|
@ -15,7 +15,7 @@ bluetooth.setTransmitPower(7);
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -7,7 +7,7 @@ game.addScore(1)
|
||||
```
|
||||
### 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
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 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
|
||||
let item: game.LedSprite = null;
|
||||
@ -10,7 +10,7 @@ item.set(LedSpriteProperty.X, 0);
|
||||
### Parameters
|
||||
|
||||
* 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`)
|
||||
* ``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)
|
||||
|
@ -10,7 +10,7 @@ item.get(LedSpriteProperty.X);
|
||||
### Parameters
|
||||
|
||||
* 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`)
|
||||
* ``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)
|
||||
@ -19,7 +19,7 @@ item.get(LedSpriteProperty.X);
|
||||
|
||||
### Returns
|
||||
|
||||
The [number](/reference/types/number) you asked for.
|
||||
The [number](/types/number) you asked for.
|
||||
|
||||
### Example
|
||||
|
||||
|
@ -9,7 +9,7 @@ item.move(1);
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -7,7 +7,7 @@ game.setScore(1)
|
||||
```
|
||||
### Parameters
|
||||
|
||||
* a [number](/reference/types/number) that represents the new score.
|
||||
* a [number](/types/number) that represents the new score.
|
||||
|
||||
### Examples
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 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
|
||||
let item: game.LedSprite = null;
|
||||
@ -10,7 +10,7 @@ item.set(LedSpriteProperty.X, 0);
|
||||
### Parameters
|
||||
|
||||
* 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`)
|
||||
* ``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)
|
||||
|
@ -8,7 +8,7 @@ game.startCountdown(1000)
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -10,7 +10,7 @@ item.turn(Direction.Right, 45);
|
||||
### Parameters
|
||||
|
||||
* 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.
|
||||
|
||||
### Example
|
||||
|
@ -16,7 +16,7 @@ images.createBigImage(`
|
||||
|
||||
### 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.
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ images.createImage(`
|
||||
|
||||
### 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.
|
||||
|
||||
### Example: Flip-flopping arrow
|
||||
|
@ -12,8 +12,8 @@ export function pixel(_this: micro_bit.Image, x: number, y: number) : boolean
|
||||
|
||||
### Parameters
|
||||
|
||||
* x - [Number](/reference/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)
|
||||
* x - [Number](/types/number); the *x coordinate* or horizontal 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?
|
||||
|
||||
|
@ -12,7 +12,7 @@ export function plotFrame(_this: micro_bit.Image, index: number)
|
||||
|
||||
### 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`
|
||||
|
||||
|
@ -12,7 +12,7 @@ export function plotImage(_this: micro_bit.Image, xOffset: number)
|
||||
|
||||
### 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`
|
||||
|
||||
|
@ -10,7 +10,7 @@ item.scrollImage(5, 200);
|
||||
|
||||
### 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
|
||||
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.
|
||||
@ -20,7 +20,7 @@ item.scrollImage(5, 200);
|
||||
image. It is a square with five LEDs on a side). This is
|
||||
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
|
||||
``offset`` says. (1000 milliseconds is one second.) The bigger you
|
||||
make this number, the slower the image will scroll.
|
||||
|
@ -12,8 +12,8 @@ export function setPixel(_this: micro_bit.Image, x: number, y: number, value: bo
|
||||
|
||||
### Parameters
|
||||
|
||||
* x - [Number](/reference/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 *x coordinate* or horizontal 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
|
||||
|
||||
### x, y coordinates?
|
||||
|
@ -12,7 +12,7 @@ export function showFrame(img: micro_bit.Image, frame: number)
|
||||
|
||||
### 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`
|
||||
|
||||
|
@ -12,7 +12,7 @@ item.showImage(0);
|
||||
### Parameters
|
||||
|
||||
* 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
|
||||
|
||||
|
@ -14,7 +14,7 @@ images.createImage().width();
|
||||
|
||||
### 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:
|
||||
|
||||
|
@ -23,7 +23,7 @@ A **g** is as much acceleration as you get from Earth's gravity.
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -8,7 +8,7 @@ input.buttonIsPressed(Button.A);
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -12,7 +12,7 @@ input.compassHeading();
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -16,7 +16,7 @@ input.lightLevel();
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -22,7 +22,7 @@ The @boardname@ measures magnetic force with **microteslas**.
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -19,7 +19,7 @@ instead of the USB cable.
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -19,7 +19,7 @@ check how the @boardname@ is moving.
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -8,7 +8,7 @@ input.runningTime();
|
||||
|
||||
### 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.)
|
||||
|
||||
### Example: elapsed time
|
||||
|
@ -9,7 +9,7 @@ input.temperature();
|
||||
|
||||
### Returns
|
||||
|
||||
* a [Number](/reference/types/number) that means the Celsius temperature.
|
||||
* a [Number](/types/number) that means the Celsius temperature.
|
||||
|
||||
### How does it work?
|
||||
|
||||
|
@ -8,7 +8,7 @@ led.brightness();
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -8,7 +8,7 @@ led.enable(false);
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -8,7 +8,7 @@ led.fadeIn(700);
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -8,7 +8,7 @@ led.fadeOut(700);
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -9,11 +9,11 @@ led.plotBarGraph(2, 20);
|
||||
|
||||
### 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
|
||||
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
|
||||
* ``high`` is a [number](/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.
|
||||
|
||||
|
@ -14,10 +14,10 @@ Use [unplot](/reference/led/unplot) to turn **off** an LED.
|
||||
|
||||
### 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
|
||||
|
@ -9,10 +9,10 @@ led.point(0,0);
|
||||
|
||||
### 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
|
||||
|
@ -9,7 +9,7 @@ led.setBrightness(121)
|
||||
|
||||
### 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.
|
||||
|
@ -8,8 +8,8 @@ led.toggle(0,0)
|
||||
|
||||
### 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.
|
||||
|
||||
|
@ -14,10 +14,10 @@ Use [plot](/reference/led/plot) to turn **on** an LED.
|
||||
|
||||
### 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
|
||||
|
@ -16,7 +16,7 @@ music.beat(BeatFraction.Whole)
|
||||
|
||||
### 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
|
||||
|
@ -13,7 +13,7 @@ music.changeTempoBy(20)
|
||||
|
||||
### 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
|
||||
the music that the @boardname@ is playing).
|
||||
|
||||
|
@ -12,8 +12,8 @@ music.playTone(440, 120)
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``frequency`` is the [number](/reference/types/number) of Hertz (how high or low the tone is).
|
||||
* ``ms`` is the [number](/reference/types/number) of milliseconds that the tone lasts
|
||||
* ``frequency`` is the [number](/types/number) of Hertz (how high or low the tone is).
|
||||
* ``ms`` is the [number](/types/number) of milliseconds that the tone lasts
|
||||
|
||||
## Example
|
||||
|
||||
|
@ -12,7 +12,7 @@ music.rest(400)
|
||||
|
||||
### 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.
|
||||
|
||||
|
@ -13,7 +13,7 @@ music.ringTone(440)
|
||||
|
||||
### 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
|
||||
number is in **Hz** (**Hertz**), which is a measurement of frequency
|
||||
or pitch.
|
||||
|
@ -11,7 +11,7 @@ This function only works on the @boardname@ and in some browsers.
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -8,7 +8,7 @@ music.tempo()
|
||||
|
||||
### 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).
|
||||
|
||||
### See also
|
||||
|
@ -9,8 +9,8 @@ pins.analogPitch(440, 300)
|
||||
|
||||
### Parameters
|
||||
|
||||
* `frequency` : [Number](/reference/types/number)
|
||||
* `ms`: [Number](/reference/types/number)
|
||||
* `frequency` : [Number](/types/number)
|
||||
* `ms`: [Number](/types/number)
|
||||
|
||||
### Example
|
||||
|
||||
|
@ -9,12 +9,12 @@ pins.analogReadPin(AnalogPin.P0)
|
||||
|
||||
### 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`)
|
||||
|
||||
### 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
|
||||
on the LED screen.
|
||||
|
@ -10,8 +10,8 @@ pins.analogSetPeriod(AnalogPin.P0, 20000)
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``name``: a [string](/reference/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.
|
||||
* ``name``: a [string](/types/string) that specifies the pin to configure (`P0` through `P4`, or `P10`)
|
||||
* ``micros``: a [number](/types/number) that specifies the analog period in microseconds.
|
||||
|
||||
The following code first sets `P0` to analog with **analog write
|
||||
pin**, and then sets the PWM period of `P0` to 20,000 microseconds.
|
||||
|
@ -8,7 +8,7 @@ pins.analogSetPitchPin(AnalogPin.P0)
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -9,8 +9,8 @@ pins.analogWritePin(AnalogPin.P0, 400)
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``name`` is a [string](/reference/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`
|
||||
* ``name`` is a [string](/types/string) that is the pin name you say (`P0` through `P4`, or `P10`)
|
||||
* ``value`` is a [number](/types/number) from `0` through `1023`
|
||||
|
||||
### Example
|
||||
|
||||
|
@ -16,11 +16,11 @@ Please read the [page about pins](/device/pins) carefully.
|
||||
|
||||
### 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
|
||||
|
||||
* 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
|
||||
|
||||
|
@ -16,8 +16,8 @@ Please read the [page about pins](/device/pins) carefully.
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``name`` is a [string](/reference/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`
|
||||
* ``name`` is a [string](/types/string) that stores the name of the pin (``P0``, ``P1``, or ``P2``, up through ``P20``)
|
||||
* ``value`` is a [number](/types/number) that can be either `0` or `1`
|
||||
|
||||
### Example: football score keeper
|
||||
|
||||
|
@ -16,11 +16,11 @@ pins.map(0, 0, 4, 0, 1023);
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``value``: a [number](/reference/types/number) that specifies the value to map
|
||||
* ``fromLow``: a [number](/reference/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
|
||||
* ``toLow``: a [number](/reference/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
|
||||
* ``value``: a [number](/types/number) that specifies the value to map
|
||||
* ``fromLow``: a [number](/types/number) that specifies the lower bound of the origin interval
|
||||
* ``fromHigh``: a [number](/types/number) that specifies the upper bound of the origin interval
|
||||
* ``toLow``: a [number](/types/number) that specifies the lower bound of the target interval
|
||||
* ``toHigh``: a [number](/types/number) that specifies the upper bound of the target interval
|
||||
|
||||
## Example
|
||||
|
||||
|
@ -16,13 +16,13 @@ Please read the [page about pins](/device/pins) carefully.
|
||||
|
||||
### 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``
|
||||
* ``maxDuration``, maximum duration in micro-seconds. If no pulse is received
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -9,8 +9,8 @@ pins.servoSetPulse(AnalogPin.P1, 1500)
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``name``: a [string](/reference/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.
|
||||
* ``name``: a [string](/types/string) that specifies the pin to configure (`P0` through `P4`, or `P10`)
|
||||
* ``micros``: a [number](/types/number) that specifies the analog period in microseconds.
|
||||
|
||||
### Example
|
||||
|
||||
|
@ -14,8 +14,8 @@ pins.servoWritePin(AnalogPin.P0, 180)
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``name``: a [string](/reference/types/string) that specifies the pin name (`P0` through `P4`, or `P10`)
|
||||
* ``value``: a [number](/reference/types/number) from `0` through `180`
|
||||
* ``name``: a [string](/types/string) that specifies the pin name (`P0` through `P4`, or `P10`)
|
||||
* ``value``: a [number](/types/number) from `0` through `180`
|
||||
|
||||
### Examples
|
||||
|
||||
|
@ -12,7 +12,7 @@ pins.spiWrite(0);
|
||||
|
||||
### Returns
|
||||
|
||||
* a [number](/reference/types/number) Response from the SPI slave
|
||||
* a [number](/types/number) Response from the SPI slave
|
||||
|
||||
### See also
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# On Data Packet Received
|
||||
|
||||
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
|
||||
@ -17,8 +17,8 @@ To add or remove the parts of the packet from the block, try clicking the blue g
|
||||
### Callback Parameters
|
||||
|
||||
* ``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)
|
||||
* `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)
|
||||
* `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](/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.
|
||||
* `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).
|
||||
|
@ -3,7 +3,7 @@
|
||||
> 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
|
||||
[number](/reference/types/number) or [string](/reference/types/string) over ``radio``.
|
||||
[number](/types/number) or [string](/types/string) over ``radio``.
|
||||
|
||||
|
||||
```sig
|
||||
|
@ -4,8 +4,8 @@ A packet that was received by the radio.
|
||||
|
||||
## 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)
|
||||
* `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)
|
||||
* `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](/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.
|
||||
* `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).
|
||||
|
@ -10,7 +10,7 @@ radio.receiveNumber();
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -10,7 +10,7 @@ radio.receiveString()
|
||||
|
||||
### 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.
|
||||
|
||||
### Example: Simple receiver
|
||||
|
@ -16,7 +16,7 @@ radio.receivedSignalStrength();
|
||||
|
||||
### 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.
|
||||
|
||||
### Simulator
|
||||
|
@ -1,6 +1,6 @@
|
||||
# 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
|
||||
radio.sendNumber(0);
|
||||
@ -8,7 +8,7 @@ radio.sendNumber(0);
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``value`` - a [number](/reference/types/number) to send.
|
||||
* ``value`` - a [number](/types/number) to send.
|
||||
|
||||
|
||||
### Example: Broadcasting acceleration
|
||||
|
@ -9,7 +9,7 @@ radio.sendString("Hello!")
|
||||
|
||||
### 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
|
||||
|
@ -9,8 +9,8 @@ radio.sendValue("name", 0);
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``name`` is a [string](/reference/types/string) to send by radio
|
||||
* ``value`` a [number](/reference/types/number) to send by radio
|
||||
* ``name`` is a [string](/types/string) to send by radio
|
||||
* ``value`` a [number](/types/number) to send by radio
|
||||
|
||||
### Example: Broadcasting acceleration
|
||||
|
||||
|
@ -16,7 +16,7 @@ radio.setGroup(0);
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``id`` is a [number](/reference/types/number) from ``0`` to ``255``.
|
||||
* ``id`` is a [number](/types/number) from ``0`` to ``255``.
|
||||
|
||||
### Simulator
|
||||
|
||||
|
@ -20,7 +20,7 @@ can reach as far as 70 meters (about 230 feet).
|
||||
|
||||
### 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.
|
||||
|
||||
### Simulator
|
||||
|
@ -8,7 +8,7 @@ radio.setTransmitSerialNumber(true);
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -9,7 +9,7 @@ serial.onDataReceived(",", () => {})
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -16,7 +16,7 @@ character. If your terminal software does not terminate lines with
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -8,7 +8,7 @@ serial.readString();
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -8,7 +8,7 @@ serial.readUntil(",");
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -9,7 +9,7 @@ serial.writeLine("");
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -8,7 +8,7 @@ serial.writeNumber(0);
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -9,7 +9,7 @@ serial.writeString("");
|
||||
|
||||
### 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
|
||||
|
||||
|
@ -8,8 +8,8 @@ serial.writeValue("x", 0);
|
||||
|
||||
### Parameters
|
||||
|
||||
* `name` is the [string](/reference/types/string) to write to the serial port
|
||||
* `value` is the [number](/reference/types/number) to write to the serial port
|
||||
* `name` is the [string](/types/string) to write to the serial port
|
||||
* `value` is the [number](/types/number) to write to the serial port
|
||||
|
||||
|
||||
|
||||
|
@ -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.
|
@ -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)
|
@ -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)
|
||||
|
@ -1,3 +0,0 @@
|
||||
# String functions
|
||||
|
||||
TBD
|
@ -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
9
docs/types/string.md
Normal 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).
|
||||
|
||||
### ~
|
@ -12,12 +12,12 @@ The Bits library includes functions for bit-level manipulation of integers. In t
|
||||
|
||||
#### 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
|
||||
|
||||
* x - an unsigned 32 bit integer [Number](/reference/types/number)
|
||||
* y - another unsigned 32 bit integer [Number](/reference/types/number)
|
||||
* x - an unsigned 32 bit integer [Number](/types/number)
|
||||
* y - another unsigned 32 bit integer [Number](/types/number)
|
||||
|
||||
### and uint32
|
||||
|
||||
@ -37,14 +37,14 @@ Rotate bits to the left or the right, by the specified number of positions.
|
||||
|
||||
#### 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
|
||||
|
||||
* x - [Number](/reference/types/number);
|
||||
* bits - [Number](/reference/types/number);
|
||||
* x - [Number](/types/number);
|
||||
* bits - [Number](/types/number);
|
||||
|
||||
## Shift left and shift right
|
||||
|
||||
@ -52,16 +52,16 @@ Shift bits to the left or the right, by the specified number of positions.
|
||||
|
||||
#### 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
|
||||
|
||||
* x - [Number](/reference/types/number);
|
||||
* bits - [Number](/reference/types/number);
|
||||
* x - [Number](/types/number);
|
||||
* bits - [Number](/types/number);
|
||||
|
||||
### 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)
|
||||
|
||||
|
@ -19,7 +19,7 @@ Type a function name in your code to call an existing [function](/javascript/fun
|
||||
|
||||
### 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:
|
||||
|
||||
```
|
||||
/**
|
||||
|
@ -31,9 +31,9 @@ Welcome to the Touch Develop home page for the @boardname@. Below you will find
|
||||
|
||||
### Types
|
||||
|
||||
* [Number](/reference/types/number)
|
||||
* [Boolean](/reference/types/boolean)
|
||||
* [String](/reference/types/string)
|
||||
* [Number](/types/number)
|
||||
* [Boolean](/types/boolean)
|
||||
* [String](/types/string)
|
||||
* [Image](/reference/images/image)
|
||||
|
||||
### Statements and control structures
|
||||
@ -50,19 +50,19 @@ Welcome to the Touch Develop home page for the @boardname@. Below you will find
|
||||
|
||||
### Maths
|
||||
|
||||
* arithmetic operators (`+`, `-`, `*`, `/`, mod) on [Numbers](/reference/types/number)
|
||||
* comparison operators (such as `>`, `=`) on [Numbers](/reference/types/number)
|
||||
* arithmetic operators (`+`, `-`, `*`, `/`, mod) on [Numbers](/types/number)
|
||||
* comparison operators (such as `>`, `=`) on [Numbers](/types/number)
|
||||
* the [math](/js/math) library
|
||||
* the [bits](/js/bits) library
|
||||
|
||||
### Logical
|
||||
|
||||
* [Boolean](/reference/types/boolean) values `true` and `false`
|
||||
* Operations (`not`, `or`, `and`) on [Booleans](/reference/types/boolean)
|
||||
* [Boolean](/types/boolean) values `true` and `false`
|
||||
* Operations (`not`, `or`, `and`) on [Booleans](/types/boolean)
|
||||
|
||||
### Strings
|
||||
|
||||
* [string functions](/reference/types/string-functions)
|
||||
* [string functions](/types/string-functions)
|
||||
|
||||
### Functions
|
||||
|
||||
|
@ -61,8 +61,8 @@ export function square(x: number) : number {
|
||||
|
||||
In the above code...
|
||||
|
||||
* ``x `` is the [input parameter](/js/functionparameters) ([Number](/reference/types/number) type)
|
||||
* ``result`` is the [output 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](/types/number) type)
|
||||
* `return x * x` is the function body (which returns the value of the expression `x * x`)
|
||||
|
||||
### Add function parameters
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user