|
63 | 63 | //| device.readinto(bytes_read)
|
64 | 64 | //| # A second transaction
|
65 | 65 | //| with device:
|
66 |
| -//| device.write(bytes_read)""" |
| 66 | +//| device.write(bytes_read) |
| 67 | +//| """ |
67 | 68 | //| ...
|
68 | 69 | //|
|
69 | 70 | STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
@@ -109,16 +110,18 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_obj___exit__(size_t n_args, const
|
109 | 110 | }
|
110 | 111 | STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_i2cdevice___exit___obj, 4, 4, adafruit_bus_device_i2cdevice_obj___exit__);
|
111 | 112 |
|
112 |
| -//| def readinto(self, buf: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: |
113 |
| -//| """Read into ``buf`` from the device. The number of bytes read will be the |
114 |
| -//| length of ``buf``. |
| 113 | +//| import sys |
| 114 | +//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: |
| 115 | +//| """Read into ``buffer`` from the device. |
| 116 | +//| |
115 | 117 | //| If ``start`` or ``end`` is provided, then the buffer will be sliced
|
116 |
| -//| as if ``buf[start:end]``. This will not cause an allocation like |
117 |
| -//| ``buf[start:end]`` will so it saves memory. |
| 118 | +//| as if ``buffer[start:end]`` were passed. |
| 119 | +//| The number of bytes read will be the length of ``buffer[start:end]``. |
118 | 120 | //|
|
119 |
| -//| :param bytearray buf: buffer to write into |
120 |
| -//| :param int start: Index to start writing at |
121 |
| -//| :param int end: Index to write up to but not include; if None, use ``len(buf)``""" |
| 121 | +//| :param WriteableBuffer buffer: read bytes into this buffer |
| 122 | +//| :param int start: beginning of buffer slice |
| 123 | +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` |
| 124 | +//| """ |
122 | 125 | //| ...
|
123 | 126 | //|
|
124 | 127 | STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
@@ -152,17 +155,19 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_o
|
152 | 155 |
|
153 | 156 | return mp_const_none;
|
154 | 157 | }
|
155 |
| -STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 2, adafruit_bus_device_i2cdevice_readinto); |
| 158 | +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 1, adafruit_bus_device_i2cdevice_readinto); |
156 | 159 |
|
157 |
| -//| def write(self, buf: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None: |
| 160 | +//| import sys |
| 161 | +//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None: |
158 | 162 | //| """Write the bytes from ``buffer`` to the device, then transmit a stop bit.
|
| 163 | +//| |
159 | 164 | //| If ``start`` or ``end`` is provided, then the buffer will be sliced
|
160 |
| -//| as if ``buffer[start:end]``. This will not cause an allocation like |
161 |
| -//| ``buffer[start:end]`` will so it saves memory. |
| 165 | +//| as if ``buffer[start:end]`` were passed, but without copying the data. |
| 166 | +//| The number of bytes written will be the length of ``buffer[start:end]``. |
162 | 167 | //|
|
163 |
| -//| :param bytearray buf: buffer containing the bytes to write |
164 |
| -//| :param int start: Index to start writing from |
165 |
| -//| :param int end: Index to read up to but not include; if None, use ``len(buf)`` |
| 168 | +//| :param ReadableBuffer buffer: write out bytes from this buffer |
| 169 | +//| :param int start: beginning of buffer slice |
| 170 | +//| :param int end: end of buffer slice; if not specified, use ``len(buffer)`` |
166 | 171 | //| """
|
167 | 172 | //| ...
|
168 | 173 | //|
|
@@ -196,28 +201,28 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write(size_t n_args, const mp_obj_
|
196 | 201 |
|
197 | 202 | return mp_const_none;
|
198 | 203 | }
|
199 |
| -MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 2, adafruit_bus_device_i2cdevice_write); |
| 204 | +MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 1, adafruit_bus_device_i2cdevice_write); |
200 | 205 |
|
201 | 206 |
|
202 |
| -//| def write_then_readinto(self, out_buffer: WriteableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None: |
| 207 | +//| import sys |
| 208 | +//| def write_then_readinto(self, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None: |
203 | 209 | //| """Write the bytes from ``out_buffer`` to the device, then immediately
|
204 |
| -//| reads into ``in_buffer`` from the device. The number of bytes read |
205 |
| -//| will be the length of ``in_buffer``. |
206 |
| -//| If ``out_start`` or ``out_end`` is provided, then the output buffer |
207 |
| -//| will be sliced as if ``out_buffer[out_start:out_end]``. This will |
208 |
| -//| not cause an allocation like ``buffer[out_start:out_end]`` will so |
209 |
| -//| it saves memory. |
210 |
| -//| If ``in_start`` or ``in_end`` is provided, then the input buffer |
211 |
| -//| will be sliced as if ``in_buffer[in_start:in_end]``. This will not |
212 |
| -//| cause an allocation like ``in_buffer[in_start:in_end]`` will so |
213 |
| -//| it saves memory. |
| 210 | +//| reads into ``in_buffer`` from the device. |
| 211 | +//| |
| 212 | +//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced |
| 213 | +//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data. |
| 214 | +//| The number of bytes written will be the length of ``out_buffer[out_start:out_end]``. |
| 215 | +//| |
| 216 | +//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced |
| 217 | +//| as if ``in_buffer[in_start:in_end]`` were passed, |
| 218 | +//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``. |
214 | 219 | //|
|
215 |
| -//| :param bytearray out_buffer: buffer containing the bytes to write |
216 |
| -//| :param bytearray in_buffer: buffer containing the bytes to read into |
217 |
| -//| :param int out_start: Index to start writing from |
218 |
| -//| :param int out_end: Index to read up to but not include; if None, use ``len(out_buffer)`` |
219 |
| -//| :param int in_start: Index to start writing at |
220 |
| -//| :param int in_end: Index to write up to but not include; if None, use ``len(in_buffer)`` |
| 220 | +//| :param ReadableBuffer out_buffer: write out bytes from this buffer |
| 221 | +//| :param WriteableBuffer in_buffer: read bytes into this buffer |
| 222 | +//| :param int out_start: beginning of ``out_buffer`` slice |
| 223 | +//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)`` |
| 224 | +//| :param int in_start: beginning of ``in_buffer`` slice |
| 225 | +//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)`` |
221 | 226 | //| """
|
222 | 227 | //| ...
|
223 | 228 | //|
|
@@ -263,7 +268,7 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write_then_readinto(size_t n_args,
|
263 | 268 |
|
264 | 269 | return mp_const_none;
|
265 | 270 | }
|
266 |
| -MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_then_readinto_obj, 3, adafruit_bus_device_i2cdevice_write_then_readinto); |
| 271 | +MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_then_readinto_obj, 1, adafruit_bus_device_i2cdevice_write_then_readinto); |
267 | 272 |
|
268 | 273 | STATIC const mp_rom_map_elem_t adafruit_bus_device_i2cdevice_locals_dict_table[] = {
|
269 | 274 | { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&adafruit_bus_device_i2cdevice___enter___obj) },
|
|
0 commit comments