Fix some titles, sigs in ref docs (#2128)

* Fix some title and sigs in ref docs

* better buffer source
This commit is contained in:
Galen Nickel 2019-06-05 16:28:56 -07:00 committed by GitHub
parent 14418569d1
commit 3f106307ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 53 additions and 66 deletions

View File

@ -233,7 +233,7 @@
* [delete](/reference/game/delete) * [delete](/reference/game/delete)
* [move](/reference/game/move) * [move](/reference/game/move)
* [turn](/reference/game/turn) * [turn](/reference/game/turn)
* [in on edge bounce](/reference/game/if-on-edge-bounce) * [if on edge bounce](/reference/game/if-on-edge-bounce)
* [get](/reference/game/get) * [get](/reference/game/get)
* [set](/reference/game/set) * [set](/reference/game/set)
* [change](/reference/game/change) * [change](/reference/game/change)

View File

@ -1,21 +1,19 @@
# change Sprite Property # change (Sprite Property)
Change the kind of [number](/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; game.createSprite(0,0).change(LedSpriteProperty.X, 0);
item.change(LedSpriteProperty.X, 0);
``` ```
## Parameters ## Parameters
* the **sprite** you want to change * **property**: the property of the **Sprite** you want to change, 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) >* ``brightness`` - how bright the LED sprite is (this works the same way as the [brightness](/reference/led/brightness) function)
* ``brightness``, how bright the LED sprite is (this works the same way as the [brightness](/reference/led/brightness) function) >* ``blink`` - how fast the sprite is blinking (the bigger the number is, the faster the sprite is blinking)
* ``blink``, how fast the sprite is blinking (the bigger the number is, the faster the sprite is blinking)
## Example ## Example

View File

@ -17,6 +17,10 @@ game.createSprite(2, 2);
`0` and `4` mean the edges of the screen, and `2` means in the middle. `0` and `4` mean the edges of the screen, and `2` means in the middle.
## Returns
* a new **LedSprite** at the location you say.
## ~ hint ## ~ hint
Once the game engine is started, it will render the sprites to the screen and potentially override any kind of animation you are trying to show. Once the game engine is started, it will render the sprites to the screen and potentially override any kind of animation you are trying to show.

View File

@ -3,15 +3,10 @@
Delete a sprite from the game. Delete a sprite from the game.
```sig ```sig
let item: game.LedSprite = null; game.createSprite(0,0).delete()
item.delete();
``` ```
### Parameters ## Example
* the **sprite** you want to delete from the game
### Example
This program makes a sprite and shows the number of its brightness on the screen. Then, it deletes the sprite. This program makes a sprite and shows the number of its brightness on the screen. Then, it deletes the sprite.
@ -21,6 +16,6 @@ basic.showNumber(ball.get(LedSpriteProperty.Brightness));
ball.delete(); ball.delete();
``` ```
### See also ## See also
[create sprite](/reference/game/create-sprite) [create sprite](/reference/game/create-sprite)

View File

@ -1,25 +1,23 @@
# Get Sprite Property # get (Sprite Property)
Find something out about a [sprite](/reference/game/create-sprite). Find something out about a [sprite](/reference/game/create-sprite).
```sig ```sig
let item: game.LedSprite = null; game.createSprite(0,0).get(LedSpriteProperty.X);
item.get(LedSpriteProperty.X);
``` ```
## Parameters ## Parameters
* the **sprite** you want to know something about * **property**: the property of the **Sprite** you want to know about, 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) >* ``brightness`` - how bright the LED sprite is (this works the same way as the [brightness](/reference/led/brightness) function)
* ``brightness``, how bright the LED sprite is (this works the same way as the [brightness](/reference/led/brightness) function) >* ``blink`` - how fast the sprite is blinking (the bigger the number is, the faster the sprite is blinking)
* ``blink``, how fast the sprite is blinking (the bigger the number is, the faster the sprite is blinking)
## Returns ## Returns
The [number](/types/number) you asked for. * a [number](/types/number) value of the property you asked for.
## Example ## Example

View File

@ -4,8 +4,7 @@ Make a [sprite](/reference/game/create-sprite) on the edge of the
[LED screen](/device/screen) bounce away. [LED screen](/device/screen) bounce away.
```sig ```sig
let item = game.createSprite(0, 2); game.createSprite(0, 2).ifOnEdgeBounce();
item.ifOnEdgeBounce();
``` ```
## Parameters ## Parameters

View File

@ -6,17 +6,16 @@ Sprites are touching the edge if they overlap with an LED on the edge
of the screen. of the screen.
```sig ```sig
let item: game.LedSprite = null; game.createSprite(0, 2).isTouchingEdge();
item.isTouchingEdge();
``` ```
## Parameters ## Parameters
* a **sprite** that might be touching the edge of the screen * a **sprite** that might be touching the edge of the screen.
## Returns ## Returns
`true` if the sprite is touching the edge of the screen * `true` if the sprite is touching the edge of the screen.
## Example ## Example

View File

@ -5,18 +5,16 @@ Find whether the sprite is touching another sprite you say.
Sprites are touching if they share the same LED. Sprites are touching if they share the same LED.
```sig ```sig
let item: game.LedSprite = null; game.createSprite(0, 2).isTouching(null);
item.isTouching(null);
``` ```
## Parameters ## Parameters
* a **sprite** you are checking * another **sprite** that might be touching the one you are checking.
* another **sprite** that might be touching the one you are checking
## Returns ## Returns
`true` if the two sprites are touching. * `true` if the two sprites are touching.
## Example ## Example

View File

@ -3,13 +3,12 @@
Move the sprite the number of LEDs you say. Move the sprite the number of LEDs you say.
```sig ```sig
let item: game.LedSprite = null; game.createSprite(0, 2).move(1);
item.move(1);
``` ```
## Parameters ## Parameters
* a [number](/types/number) that means how many LEDs the sprite should move * **leds**: a [number](/types/number) that means how many LEDs the sprite should move.
## Example ## Example

View File

@ -1,21 +1,19 @@
# Set Sprite Property # set (Sprite Property)
Make a [sprite](/reference/game/create-sprite) store the kind of [number](/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; game.createSprite(0,0).set(LedSpriteProperty.X, 0);
item.set(LedSpriteProperty.X, 0);
``` ```
## Parameters ## Parameters
* the **sprite** you want to make store the number you say * **property**: the property of the **Sprite** you want to store a value for, 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) >* ``brightness`` - how bright the LED sprite is (this works the same way as the [brightness](/reference/led/brightness) function)
* ``brightness``, how bright the LED sprite is (this works the same way as the [brightness](/reference/led/brightness) function) >* ``blink`` - how fast the sprite is blinking (the bigger the number is, the faster the sprite is blinking)
* ``blink``, how fast the sprite is blinking (the bigger the number is, the faster the sprite is blinking)
## Example ## Example

View File

@ -3,15 +3,14 @@
Turn the sprite as much as you say in the direction you say. Turn the sprite as much as you say in the direction you say.
```sig ```sig
let item: game.LedSprite = null; game.createSprite(0, 2).turn(Direction.Right, 45);
item.turn(Direction.Right, 45);
``` ```
## Parameters ## Parameters
* a choice whether the sprite should turn **left** or **right** * **direction**: a choice whether the sprite should turn **left** or **right**
* a [number](/types/number) that means how much the sprite should turn. * **degrees**: a [number](/types/number) degrees of angle that the sprite should turn.
This number is in **degrees**, so a straight left or right turn is 90 degrees. A straight left or right turn is 90 degrees.
## Example ## Example

View File

@ -19,7 +19,7 @@ serial.onDataReceived(",", () => {})
```cards ```cards
serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200); serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200);
serial.redirectToUSB(); serial.redirectToUSB();
serial.writeBuffer(pins.createBuffer(0)); serial.writeBuffer(serial.readBuffer(64));
serial.readBuffer(64); serial.readBuffer(64);
serial.setRxBufferSize(64); serial.setRxBufferSize(64);
serial.setTxBufferSize(64); serial.setTxBufferSize(64);

View File

@ -26,7 +26,7 @@ The need to pause for more data is set by the @boardname@ **[serial mode](https:
Read character data from the serial port one row at a time. Write the rows to an LED display connected to the I2C pins. Read character data from the serial port one row at a time. Write the rows to an LED display connected to the I2C pins.
```blocks ```typescript
let rowData: Buffer = null; let rowData: Buffer = null;
for (let i = 0; i < 24; i++) { for (let i = 0; i < 24; i++) {
rowData = serial.readBuffer(80); rowData = serial.readBuffer(80);

View File

@ -16,7 +16,7 @@ You place your data characters into an existing buffer. All of the data, the len
Read some characters of data from a device connected to the I2C pins. Write the data to the serial port. Read some characters of data from a device connected to the I2C pins. Write the data to the serial port.
```blocks ```typescript
pins.i2cWriteNumber(132, NumberFormat.UInt8LE, 0); pins.i2cWriteNumber(132, NumberFormat.UInt8LE, 0);
let i2cBuffer = pins.i2cReadBuffer(132, 16, false); let i2cBuffer = pins.i2cReadBuffer(132, 16, false);
serial.writeBuffer(i2cBuffer); serial.writeBuffer(i2cBuffer);

View File

@ -196,7 +196,7 @@ namespace serial {
* Sets the size of the RX buffer in bytes * Sets the size of the RX buffer in bytes
* @param size length of the rx buffer in bytes, eg: 32 * @param size length of the rx buffer in bytes, eg: 32
*/ */
//% help=serial/set-rx-buffer-size //% help=reference/serial/set-rx-buffer-size
void setRxBufferSize(uint8_t size) { void setRxBufferSize(uint8_t size) {
uBit.serial.setRxBufferSize(size); uBit.serial.setRxBufferSize(size);
} }
@ -205,7 +205,7 @@ namespace serial {
* Sets the size of the TX buffer in bytes * Sets the size of the TX buffer in bytes
* @param size length of the tx buffer in bytes, eg: 32 * @param size length of the tx buffer in bytes, eg: 32
*/ */
//% help=serial/set-tx-buffer-size //% help=reference/serial/set-tx-buffer-size
void setTxBufferSize(uint8_t size) { void setTxBufferSize(uint8_t size) {
uBit.serial.setTxBufferSize(size); uBit.serial.setTxBufferSize(size);
} }

View File

@ -869,14 +869,14 @@ declare namespace serial {
* Sets the size of the RX buffer in bytes * Sets the size of the RX buffer in bytes
* @param size length of the rx buffer in bytes, eg: 32 * @param size length of the rx buffer in bytes, eg: 32
*/ */
//% help=serial/set-rx-buffer-size shim=serial::setRxBufferSize //% help=reference/serial/set-rx-buffer-size shim=serial::setRxBufferSize
function setRxBufferSize(size: uint8): void; function setRxBufferSize(size: uint8): void;
/** /**
* Sets the size of the TX buffer in bytes * Sets the size of the TX buffer in bytes
* @param size length of the tx buffer in bytes, eg: 32 * @param size length of the tx buffer in bytes, eg: 32
*/ */
//% help=serial/set-tx-buffer-size shim=serial::setTxBufferSize //% help=reference/serial/set-tx-buffer-size shim=serial::setTxBufferSize
function setTxBufferSize(size: uint8): void; function setTxBufferSize(size: uint8): void;
} }