diff --git a/docs/device/serial.md b/docs/device/serial.md index 4d5cd48f..f6fecc7a 100644 --- a/docs/device/serial.md +++ b/docs/device/serial.md @@ -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 diff --git a/docs/reference/game/touching.md b/docs/reference/game/touching.md index ea526b94..afe6962a 100644 --- a/docs/reference/game/touching.md +++ b/docs/reference/game/touching.md @@ -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 -``` - diff --git a/docs/reference/led/stop-animation.md b/docs/reference/led/stop-animation.md index e07599ae..af7d9d4b 100644 --- a/docs/reference/led/stop-animation.md +++ b/docs/reference/led/stop-animation.md @@ -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 + + diff --git a/docs/reference/serial/redirect-to.md b/docs/reference/serial/redirect-to.md new file mode 100644 index 00000000..0cfb6671 --- /dev/null +++ b/docs/reference/serial/redirect-to.md @@ -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) + diff --git a/docs/reference/serial/write-line.md b/docs/reference/serial/write-line.md index b0aca910..c9b3171d 100644 --- a/docs/reference/serial/write-line.md +++ b/docs/reference/serial/write-line.md @@ -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) diff --git a/docs/reference/serial/write-number.md b/docs/reference/serial/write-number.md new file mode 100644 index 00000000..7e29cfbc --- /dev/null +++ b/docs/reference/serial/write-number.md @@ -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) + diff --git a/docs/reference/serial/write-string.md b/docs/reference/serial/write-string.md new file mode 100644 index 00000000..4c673ff4 --- /dev/null +++ b/docs/reference/serial/write-string.md @@ -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) diff --git a/docs/reference/serial/write-value.md b/docs/reference/serial/write-value.md index a764ae54..bdc60607 100644 --- a/docs/reference/serial/write-value.md +++ b/docs/reference/serial/write-value.md @@ -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) diff --git a/libs/microbit/pxt.json b/libs/microbit/pxt.json index 9e06c1e9..d45a0a08 100644 --- a/libs/microbit/pxt.json +++ b/libs/microbit/pxt.json @@ -36,6 +36,7 @@ "public": true, "dependencies": {}, "yotta": { + "configIsJustDefaults": true, "config": { "microbit-dal": { "bluetooth": { diff --git a/package.json b/package.json index b0da9a68..ad22fb76 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/ptrcheck-ignore b/ptrcheck-ignore new file mode 100644 index 00000000..3fd6c12d --- /dev/null +++ b/ptrcheck-ignore @@ -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