I2C ref doc 'repeated' description (#1589)

* I2C ref doc 'repeated' description

* Note the non-endianness for one byte formats

* trigger rebuild
This commit is contained in:
Galen Nickel
2018-11-15 21:57:39 -08:00
committed by Peli de Halleux
parent ac9f9d1553
commit a6e4f63dea
5 changed files with 73 additions and 10 deletions

View File

@ -7,6 +7,7 @@ pins.i2cWriteNumber(0, 0, NumberFormat.Int8LE, true);
```
### ~hint
**Simulator**
This function needs real hardware to work with. It's not supported in the simulator.
@ -18,9 +19,17 @@ This function needs real hardware to work with. It's not supported in the simula
* **address**: the 7-bit I2C address of the device to send to send **value** to.
* **value**: the number to send to **address**.
* **format**: the [NumberFormat](/types/buffer/number-format) for **value**.
* **repeated**: if `true`, a [repeated start condition](http://www.i2c-bus.org/repeated-start-condition/) is set to help make sure the number is written to the device with out an interruption. If set to `false` (the default), the data is written without setting a start condition more than once.
* **repeated**: if `true`, don't send a stop condition after the write. Otherwise, a stop condition is sent when `false` (the default).
## Example
### ~ hint
A [repeated start condition](http://www.i2c-bus.org/repeated-start-condition/) is set to help make sure that when you want to write multiple numbers from the device at one time, it can happen without interruption. A start conditon is sent (if **repeated** is `true`) each time a number is written without a matching stop condition. When the last number is written, the stop conditon can be sent by setting **repeated** to `false`. For single writes, don't use **repeated** or set it to `false`.
### ~
## Examples
### Write a big endian number to a device
Send the value `2055` to the 7-bit I2C address as a 32-bit number. The `32`, big-endian, and integer chosen for the format.
@ -28,6 +37,18 @@ Send the value `2055` to the 7-bit I2C address as a 32-bit number. The `32`, big
pins.i2cWriteNumber(32, 2055, NumberFormat.Int32BE, false);
```
### Reapeted writes
Send three byte values to a device at address `33`.
```blocks
pins.i2cWriteNumber(33, 19, NumberFormat.Int32BE, true);
pins.i2cWriteNumber(33, 61, NumberFormat.Int32BE, true);
pins.i2cWriteNumber(33, 87, NumberFormat.Int32BE, false);
```
## See also
[i2c read number](/reference/pins/i2c-read-number)
[What's I2C?](http://www.i2c-bus.org/), [number format](/types/buffer/number-format)