Merge branch 'master' of github.com:Microsoft/pxt-microbit
This commit is contained in:
commit
299efaf0f2
31
docs/reference/serial/redirect-to.md
Normal file
31
docs/reference/serial/redirect-to.md
Normal 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)
|
||||||
|
|
@ -9,7 +9,7 @@ serial.writeLine("");
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
* `line` is the [string](/reference/types/string) to write to the serial port
|
* `text` is the [string](/reference/types/string) to write to the serial port
|
||||||
|
|
||||||
### Example: simple serial
|
### Example: simple serial
|
||||||
|
|
||||||
@ -48,4 +48,5 @@ basic.forever(() => {
|
|||||||
|
|
||||||
[serial](/device/serial),
|
[serial](/device/serial),
|
||||||
[serial write number](/reference/serial/write-number),
|
[serial write number](/reference/serial/write-number),
|
||||||
|
[serial write string](/reference/serial/write-string),
|
||||||
[serial write value](/reference/serial/write-value)
|
[serial write value](/reference/serial/write-value)
|
||||||
|
@ -8,7 +8,7 @@ serial.writeNumber(0);
|
|||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
||||||
* `number` is the [number](/reference/types/number) to write to the serial port
|
* `value` is the [number](/reference/types/number) to write to the serial port
|
||||||
|
|
||||||
### Example: one through ten
|
### Example: one through ten
|
||||||
|
|
||||||
|
31
docs/reference/serial/write-string.md
Normal file
31
docs/reference/serial/write-string.md
Normal 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)
|
@ -6,6 +6,14 @@ Write a name/value pair and a newline character (`\r\n`) to the [serial](/device
|
|||||||
serial.writeValue("x", 0);
|
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
|
### Example: streaming data
|
||||||
|
|
||||||
Every 10 seconds, the example below sends the temperature and light level
|
Every 10 seconds, the example below sends the temperature and light level
|
||||||
|
Loading…
Reference in New Issue
Block a user