Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Thomas Denney 2016-07-13 09:17:32 +01:00
commit 84a29eec65
11 changed files with 205 additions and 34 deletions

View File

@ -33,9 +33,16 @@ If you are using the Google Chrome browser, you can use our extension to get ser
### Windows
You must install a device driver (for the computer to recognize the serial interface of the micro:bit); then, you must also install a terminal emulator (which is going to connect to the micro:bit and read its output). Here's how to do it:
You must install a device driver (for the computer to recognize the
serial interface of the micro:bit); then, you must also install a
terminal emulator (which is going to connect to the micro:bit and read
its output).
* Follow instructions at https://developer.mbed.org/handbook/Windows-serial-configuration in order to install the device driver
* Follow the instructions at
https://developer.mbed.org/handbook/Windows-serial-configuration to
install the device driver.
* Instructions for installing a terminal emulator are below.
#### Windows > Tera Term
@ -66,14 +73,16 @@ If you prefer another terminal emulator (such as [PuTTY](http://www.putty.org/))
### Linux
(Untested).
* Install the program `screen` if it is not already installed.
* Plug in the micro:bit.
* Open a terminal.
* Find which device node the micro:bit was assigned to with the command `ls /dev/ttyACM*`.
* If it was `/dev/ttyACM0`, type the command `screen /dev/ttyACM0 115200`. If it was some other device node,
use that one in the command instead. **Note:** You may need root access to run `screen`
successfully. You can probably use the command `sudo` like this: `sudo screen /dev/ttyACM0 115200`.
* To exit `screen`, type `Ctrl-A` `Ctrl-D`.
* Plug in the micro:bit
* Open a terminal
* `dmesg | tail` will show you which `/dev/` node the micro:bit was assigned (e.g. `/dev/ttyUSB0`)
* Then, do: `screen /dev/ttyUSB0 115200` (install the `screen` program if you don't have it). To exit, run `Ctrl-A` `Ctrl-D`.
Alternative programs include minicom, etc.
Alternative programs include `minicom` and so on.
### Mac OS

View File

@ -2,7 +2,12 @@
Reports true if sprite is touching specified sprite
```blocks
let matter = game.createSprite(2, 2);
let antimatter = game.createSprite(2, 2);
if (matter.isTouching(antimatter)) {
basic.pause(500);
basic.clearScreen();
basic.showString("BOOM!");
}
```
export function isTouching(_this: micro_bitSprites.LedSprite, other: micro_bitSprites.LedSprite) : boolean
```

View File

@ -1,8 +1,22 @@
# Stop Animation
Cancels the current animation and clears other pending animations .
Stop the animation that is playing and any animations that are waiting to
play.
```sig
led.stopAnimation()
```
### Example
This program...
```blocks
basic.showString("STOP ME! STOP ME! PLEASE, WON'T SOMEBODY STOP ME?");
input.onButtonPressed(Button.B, () => {
led.stopAnimation();
});
'```
### See Also

View File

@ -0,0 +1,31 @@
# Serial Redirect To
Dynamically configure the serial instance to use pins other than
``USBTX`` and ``USBRX``.
```sig
serial.redirect(SerialPin.P0, SerialPin.P0, BaudRate.BaudRate115200);
```
### Parameters
* ``tx``: the [serial pin](/device/pins) on which to transmit data
* ``rx``: the [serial pin](/device/pins) on which to receive data
* ``rate``: the baud rate at which to transmit and receive data (either `9600` or ``115200``)
### Example
When button ``A`` is pressed, the following example reconfigures the
serial instance. The new configuration uses pin ``P1`` to transmit and
``P2`` to receive, at a baud rate of `9600`.
```blocks
input.onButtonPressed(Button.A, () => {
serial.redirect(SerialPin.P1, SerialPin.P2, BaudRate.BaudRate9600);
});
```
### See also
[serial](/device/serial)

View File

@ -1,14 +1,32 @@
# Write Line
# Serial Write Line
Writes a string and a new line character (`\r\n`) to [serial](/device/serial).
Write a string to the [serial](/device/serial) port and start a new line of text
by writing `\r\n`.
```sig
serial.writeLine("");
```
### Parameters
* `text` is the [string](/reference/types/string) to write to the serial port
### Example: simple serial
This program writes the word `BOFFO` to the serial port repeatedly.
```blocks
basic.forever(() => {
serial.writeLine("BOFFO");
basic.pause(5000);
});
```
### Example: streaming data
The following example constantly checks the [compass heading](/reference/input/compass-heading) and sends the direction to serial.
This program checks the
[compass heading](/reference/input/compass-heading) and sends the
direction to the serial port repeatedly.
```blocks
basic.forever(() => {
@ -26,8 +44,9 @@ basic.forever(() => {
}
})
```
### See also
[serial](/device/serial), [write value](/reference/serial/write-value)
[serial](/device/serial),
[serial write number](/reference/serial/write-number),
[serial write string](/reference/serial/write-string),
[serial write value](/reference/serial/write-value)

View File

@ -0,0 +1,41 @@
# Serial Write Number
Write a number to the [serial](/device/serial) port.
```sig
serial.writeNumber(0);
```
### Parameters
* `value` is the [number](/reference/types/number) to write to the serial port
### Example: one through ten
This program repeatedly writes a 10-digit number to the serial port.
```blocks
basic.forever(() => {
serial.writeNumber(1234567890);
basic.pause(5000);
});
```
### Example: plot bar graph does serial
If you use the ``led.plotBarGraph`` function, it writes the number
being plotted to the serial port too.
```blocks
basic.forever(() => {
led.plotBarGraph(input.lightLevel(), 255)
basic.pause(10000);
})
```
### See also
[serial](/device/serial),
[serial write line](/reference/serial/write-line),
[serial write value](/reference/serial/write-value)

View File

@ -0,0 +1,31 @@
# Serial Write String
Write a string to the [serial](/device/serial) port,
without starting a new line afterward.
```sig
serial.writeString("");
```
### Parameters
* `text` is the [string](/reference/types/string) to write to the serial port
### Example: simple serial
This program writes the word `JUMBO` to the serial port repeatedly,
without any new lines.
```blocks
basic.forever(() => {
serial.writeString("JUMBO");
basic.pause(1000);
});
```
### See also
[serial](/device/serial),
[serial write line](/reference/serial/write-line),
[serial write number](/reference/serial/write-number),
[serial write value](/reference/serial/write-value)

View File

@ -1,14 +1,23 @@
# Write Value
Writes name/value pair and a new line character (`\r\n`) to [serial](/device/serial).
Write a name/value pair and a newline character (`\r\n`) to the [serial](/device/serial) port.
```sig
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
### Example: streaming data
The sample below sends the temperature and light level every 10 seconds.
Every 10 seconds, the example below sends the temperature and light level
to the serial port.
```blocks
basic.forever(() => {
@ -18,19 +27,17 @@ basic.forever(() => {
})
```
### Plot bar graph does serial!
#### ~hint
If you use the `led.plotBarGraph` function, it automatically writes the value to the serial as well.
```blocks
basic.forever(() => {
led.plotBarGraph(input.lightLevel(), 255)
basic.pause(10000);
})
```
The [send value](/reference/radio/send-value) function broadcasts
string/number pairs. You can use a second micro:bit to receive them,
and then send them directly to the serial port with ``write value``.
#### ~
### See also
[serial](/device/serial), [write line](/reference/serial/write-line)
[serial](/device/serial),
[serial write line](/reference/serial/write-line),
[serial write number](/reference/serial/write-number),
[send value](/reference/radio/send-value)

View File

@ -36,6 +36,7 @@
"public": true,
"dependencies": {},
"yotta": {
"configIsJustDefaults": true,
"config": {
"microbit-dal": {
"bluetooth": {

View File

@ -1,6 +1,6 @@
{
"name": "pxt-microbit",
"version": "0.2.185",
"version": "0.2.186",
"description": "BBC micro:bit target for PXT",
"keywords": [
"JavaScript",
@ -29,6 +29,6 @@
"typescript": "^1.8.7"
},
"dependencies": {
"pxt-core": "0.2.193"
"pxt-core": "0.2.194"
}
}

13
ptrcheck-ignore Normal file
View File

@ -0,0 +1,13 @@
microbit
microbit-appx
microbit-beta
microbit-git-*
microbit-latest
microbit-logo-svg
microbit-portraitlogo-svg
microbit-splashscreen-svg
microbit-squarelogo-svg
microbit-test
microbit-theme-json
microbit-uploader-exe
microbit-uploader-zip