From 3e5f55259180aac6c1c8c66936085500cf63ff58 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Mon, 3 Feb 2020 10:37:32 +0100 Subject: [PATCH] api/iodevices: update i2c doc and sample Reflect that we read one byte by default. By popular request, also allow a second way to send one byte, by specifying a register with no data. --- pybricks-projects | 2 +- pybricks/iodevices.py | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pybricks-projects b/pybricks-projects index f7f1ce5..8d9bb6e 160000 --- a/pybricks-projects +++ b/pybricks-projects @@ -1 +1 @@ -Subproject commit f7f1ce576866456e5865e33059c0be22e57c2314 +Subproject commit 8d9bb6e11a4f0e59f8af0eea3777ea8eaec86e65 diff --git a/pybricks/iodevices.py b/pybricks/iodevices.py index 4470402..e2c7886 100644 --- a/pybricks/iodevices.py +++ b/pybricks/iodevices.py @@ -110,26 +110,26 @@ class I2CDevice(): """ pass - def read(self, reg, length): + def read(self, reg, length=1): """Read bytes, starting at a given register. Arguments: reg (``int``): Register at which to begin reading: 0--255 or 0x00--0xFF. - length (``int``): How many bytes to read. + length (``int``): How many bytes to read (*Default*: ``1``). Returns: ``bytes``: Bytes returned from the device. """ pass - def write(self, reg, data): + def write(self, reg, data=None): """Write bytes, starting at a given register. Arguments: reg (``int``): Register at which to begin writing: 0--255 or 0x00--0xFF. - data (``bytes``): Bytes to be written. + data (``bytes``): Bytes to be written (*Default*: ``None``). """ pass @@ -157,7 +157,7 @@ class UARTDevice(): exception is raised. Arguments: - length (``int``): How many bytes to read (*Default*: 1). + length (``int``): How many bytes to read (*Default*: ``1``). Returns: ``bytes``: Bytes returned from the device.