Skip to content

Commit 724dcda

Browse files
committed
Fixed whitespace in busio
1 parent 78ea3ff commit 724dcda

File tree

4 files changed

+311
-311
lines changed

4 files changed

+311
-311
lines changed

shared-bindings/busio/I2C.c

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -37,32 +37,32 @@
3737
#include "supervisor/shared/translate.h"
3838

3939
//|class I2C:
40-
//| """.. currentmodule:: busio
40+
//|""".. currentmodule:: busio
4141
//|
42-
//| :class:`I2C` --- Two wire serial protocol
43-
//| ------------------------------------------"""
44-
//| def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int = 255):
45-
//| """I2C is a two-wire protocol for communicating between devices. At the
46-
//| physical level it consists of 2 wires: SCL and SDA, the clock and data
47-
//| lines respectively.
42+
//|:class:`I2C` --- Two wire serial protocol
43+
//|------------------------------------------"""
44+
//|def __init__(self, scl: microcontroller.Pin, sda: microcontroller.Pin, *, frequency: int = 400000, timeout: int = 255):
45+
//|"""I2C is a two-wire protocol for communicating between devices. At the
46+
//|physical level it consists of 2 wires: SCL and SDA, the clock and data
47+
//|lines respectively.
4848
//|
49-
//| .. seealso:: Using this class directly requires careful lock management.
50-
//| Instead, use :class:`~adafruit_bus_device.i2c_device.I2CDevice` to
51-
//| manage locks.
49+
//|.. seealso:: Using this class directly requires careful lock management.
50+
//|Instead, use :class:`~adafruit_bus_device.i2c_device.I2CDevice` to
51+
//|manage locks.
5252
//|
53-
//| .. seealso:: Using this class to directly read registers requires manual
54-
//| bit unpacking. Instead, use an existing driver or make one with
55-
//| :ref:`Register <register-module-reference>` data descriptors.
53+
//|.. seealso:: Using this class to directly read registers requires manual
54+
//|bit unpacking. Instead, use an existing driver or make one with
55+
//|:ref:`Register <register-module-reference>` data descriptors.
5656
//|
57-
//| :param ~microcontroller.Pin scl: The clock pin
58-
//| :param ~microcontroller.Pin sda: The data pin
59-
//| :param int frequency: The clock frequency in Hertz
60-
//| :param int timeout: The maximum clock stretching timeut - (used only for bitbangio.I2C; ignored for busio.I2C)
57+
//|:param ~microcontroller.Pin scl: The clock pin
58+
//|:param ~microcontroller.Pin sda: The data pin
59+
//|:param int frequency: The clock frequency in Hertz
60+
//|:param int timeout: The maximum clock stretching timeut - (used only for bitbangio.I2C; ignored for busio.I2C)
6161
//|
62-
//| .. note:: On the nRF52840, only one I2C object may be created,
63-
//| except on the Circuit Playground Bluefruit, which allows two,
64-
//| one for the onboard accelerometer, and one for offboard use."""
65-
//| ...
62+
//|.. note:: On the nRF52840, only one I2C object may be created,
63+
//|except on the Circuit Playground Bluefruit, which allows two,
64+
//|one for the onboard accelerometer, and one for offboard use."""
65+
//|...
6666
STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
6767
busio_i2c_obj_t *self = m_new_obj(busio_i2c_obj_t);
6868
self->base.type = &busio_i2c_type;
@@ -83,9 +83,9 @@ STATIC mp_obj_t busio_i2c_make_new(const mp_obj_type_t *type, size_t n_args, con
8383
return (mp_obj_t)self;
8484
}
8585

86-
//| def deinit(self, ) -> Any:
87-
//| """Releases control of the underlying hardware so other classes can use it."""
88-
//| ...
86+
//|def deinit(self, ) -> Any:
87+
//|"""Releases control of the underlying hardware so other classes can use it."""
88+
//|...
8989
STATIC mp_obj_t busio_i2c_obj_deinit(mp_obj_t self_in) {
9090
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
9191
common_hal_busio_i2c_deinit(self);
@@ -99,15 +99,15 @@ STATIC void check_for_deinit(busio_i2c_obj_t *self) {
9999
}
100100
}
101101

102-
//| def __enter__(self, ) -> Any:
103-
//| """No-op used in Context Managers."""
104-
//| ...
102+
//|def __enter__(self, ) -> Any:
103+
//|"""No-op used in Context Managers."""
104+
//|...
105105
// Provided by context manager helper.
106106

107-
//| def __exit__(self, ) -> Any:
108-
//| """Automatically deinitializes the hardware on context exit. See
109-
//| :ref:`lifetime-and-contextmanagers` for more info."""
110-
//| ...
107+
//|def __exit__(self, ) -> Any:
108+
//|"""Automatically deinitializes the hardware on context exit. See
109+
//|:ref:`lifetime-and-contextmanagers` for more info."""
110+
//|...
111111
STATIC mp_obj_t busio_i2c_obj___exit__(size_t n_args, const mp_obj_t *args) {
112112
(void)n_args;
113113
common_hal_busio_i2c_deinit(args[0]);
@@ -122,13 +122,13 @@ static void check_lock(busio_i2c_obj_t *self) {
122122
}
123123
}
124124

125-
//| def scan(self, ) -> Any:
126-
//| """Scan all I2C addresses between 0x08 and 0x77 inclusive and return a
127-
//| list of those that respond.
125+
//|def scan(self, ) -> Any:
126+
//|"""Scan all I2C addresses between 0x08 and 0x77 inclusive and return a
127+
//|list of those that respond.
128128
//|
129-
//| :return: List of device ids on the I2C bus
130-
//| :rtype: list"""
131-
//| ...
129+
//|:return: List of device ids on the I2C bus
130+
//|:rtype: list"""
131+
//|...
132132
STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) {
133133
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
134134
check_for_deinit(self);
@@ -145,21 +145,21 @@ STATIC mp_obj_t busio_i2c_scan(mp_obj_t self_in) {
145145
}
146146
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_scan_obj, busio_i2c_scan);
147147

148-
//| def try_lock(self, ) -> Any:
149-
//| """Attempts to grab the I2C lock. Returns True on success.
150-
//| :return: True when lock has been grabbed
151-
//| :rtype: bool"""
152-
//| ...
148+
//|def try_lock(self, ) -> Any:
149+
//|"""Attempts to grab the I2C lock. Returns True on success.
150+
//|:return: True when lock has been grabbed
151+
//|:rtype: bool"""
152+
//|...
153153
STATIC mp_obj_t busio_i2c_obj_try_lock(mp_obj_t self_in) {
154154
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
155155
check_for_deinit(self);
156156
return mp_obj_new_bool(common_hal_busio_i2c_try_lock(self));
157157
}
158158
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_try_lock_obj, busio_i2c_obj_try_lock);
159159

160-
//| def unlock(self, ) -> Any:
161-
//| """Releases the I2C lock."""
162-
//| ...
160+
//|def unlock(self, ) -> Any:
161+
//|"""Releases the I2C lock."""
162+
//|...
163163
STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) {
164164
busio_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
165165
check_for_deinit(self);
@@ -168,20 +168,20 @@ STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) {
168168
}
169169
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock);
170170

171-
//| def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any:
172-
//| """Read into ``buffer`` from the slave specified by ``address``.
173-
//| The number of bytes read will be the length of ``buffer``.
174-
//| At least one byte must be read.
171+
//|def readfrom_into(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None) -> Any:
172+
//|"""Read into ``buffer`` from the slave specified by ``address``.
173+
//|The number of bytes read will be the length of ``buffer``.
174+
//|At least one byte must be read.
175175
//|
176-
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
177-
//| as if ``buffer[start:end]``. This will not cause an allocation like
178-
//| ``buf[start:end]`` will so it saves memory.
176+
//|If ``start`` or ``end`` is provided, then the buffer will be sliced
177+
//|as if ``buffer[start:end]``. This will not cause an allocation like
178+
//|``buf[start:end]`` will so it saves memory.
179179
//|
180-
//| :param int address: 7-bit device address
181-
//| :param bytearray buffer: buffer to write into
182-
//| :param int start: Index to start writing at
183-
//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``"""
184-
//| ...
180+
//|:param int address: 7-bit device address
181+
//|:param bytearray buffer: buffer to write into
182+
//|:param int start: Index to start writing at
183+
//|:param int end: Index to write up to but not include. Defaults to ``len(buffer)``"""
184+
//|...
185185
// Shared arg parsing for readfrom_into and writeto_then_readfrom.
186186
STATIC void readfrom(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end) {
187187
mp_buffer_info_t bufinfo;
@@ -219,26 +219,26 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args,
219219
}
220220
MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into);
221221

222-
//| def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any:
223-
//| """Write the bytes from ``buffer`` to the slave specified by ``address``.
224-
//| Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be
225-
//| removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and
226-
//| repeated start before a read.
222+
//|def writeto(self, address: int, buffer: bytearray, *, start: int = 0, end: int = None, stop: bool = True) -> Any:
223+
//|"""Write the bytes from ``buffer`` to the slave specified by ``address``.
224+
//|Transmits a stop bit when stop is True. Setting stop=False is deprecated and stop will be
225+
//|removed in CircuitPython 6.x. Use `writeto_then_readfrom` when needing a write, no stop and
226+
//|repeated start before a read.
227227
//|
228-
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
229-
//| as if ``buffer[start:end]``. This will not cause an allocation like
230-
//| ``buffer[start:end]`` will so it saves memory.
228+
//|If ``start`` or ``end`` is provided, then the buffer will be sliced
229+
//|as if ``buffer[start:end]``. This will not cause an allocation like
230+
//|``buffer[start:end]`` will so it saves memory.
231231
//|
232-
//| Writing a buffer or slice of length zero is permitted, as it can be used
233-
//| to poll for the existence of a device.
232+
//|Writing a buffer or slice of length zero is permitted, as it can be used
233+
//|to poll for the existence of a device.
234234
//|
235-
//| :param int address: 7-bit device address
236-
//| :param bytearray buffer: buffer containing the bytes to write
237-
//| :param int start: Index to start writing from
238-
//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)``
239-
//| :param bool stop: If true, output an I2C stop condition after the buffer is written.
240-
//| Deprecated. Will be removed in 6.x and act as stop=True."""
241-
//| ...
235+
//|:param int address: 7-bit device address
236+
//|:param bytearray buffer: buffer containing the bytes to write
237+
//|:param int start: Index to start writing from
238+
//|:param int end: Index to read up to but not include. Defaults to ``len(buffer)``
239+
//|:param bool stop: If true, output an I2C stop condition after the buffer is written.
240+
//|Deprecated. Will be removed in 6.x and act as stop=True."""
241+
//|...
242242
// Shared arg parsing for writeto and writeto_then_readfrom.
243243
STATIC void writeto(busio_i2c_obj_t *self, mp_int_t address, mp_obj_t buffer, int32_t start, mp_int_t end, bool stop) {
244244
// get the buffer to write the data from
@@ -277,23 +277,23 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma
277277
}
278278
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto);
279279

280-
//| def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any:
281-
//| """Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop
282-
//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
283-
//| ``in_buffer`` can be the same buffer because they are used sequentially.
280+
//|def writeto_then_readfrom(self, address: int, out_buffer: bytearray, in_buffer: bytearray, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> Any:
281+
//|"""Write the bytes from ``out_buffer`` to the slave specified by ``address``, generate no stop
282+
//|bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
283+
//|``in_buffer`` can be the same buffer because they are used sequentially.
284284
//|
285-
//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced
286-
//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]``
287-
//| will so it saves memory.
285+
//|If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced
286+
//|as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]``
287+
//|will so it saves memory.
288288
//|
289-
//| :param int address: 7-bit device address
290-
//| :param bytearray out_buffer: buffer containing the bytes to write
291-
//| :param bytearray in_buffer: buffer to write into
292-
//| :param int out_start: Index to start writing from
293-
//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)``
294-
//| :param int in_start: Index to start writing at
295-
//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``"""
296-
//| ...
289+
//|:param int address: 7-bit device address
290+
//|:param bytearray out_buffer: buffer containing the bytes to write
291+
//|:param bytearray in_buffer: buffer to write into
292+
//|:param int out_start: Index to start writing from
293+
//|:param int out_end: Index to read up to but not include. Defaults to ``len(buffer)``
294+
//|:param int in_start: Index to start writing at
295+
//|:param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``"""
296+
//|...
297297
STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
298298
enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end };
299299
static const mp_arg_t allowed_args[] = {

shared-bindings/busio/OneWire.c

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,35 @@
3535
#include "shared-bindings/util.h"
3636

3737
//|class OneWire:
38-
//| """.. currentmodule:: busio
38+
//|""".. currentmodule:: busio
3939
//|
40-
//| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol
41-
//| ================================================================="""
40+
//|:class:`OneWire` -- Lowest-level of the Maxim OneWire protocol
41+
//|================================================================="""
4242
//|
43-
//| def __init__(self, pin: microcontroller.Pin):
44-
//| """:class:`~busio.OneWire` implements the timing-sensitive foundation of the Maxim
45-
//| (formerly Dallas Semi) OneWire protocol.
43+
//|__init__(self, pin: microcontroller.Pin):
44+
//|""":class:`~busio.OneWire` implements the timing-sensitive foundation of the Maxim
45+
//|(formerly Dallas Semi) OneWire protocol.
4646
//|
47-
//| Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126
47+
//|Protocol definition is here: https://www.maximintegrated.com/en/app-notes/index.mvp/id/126
4848
//|
49-
//| .. class:: OneWire(pin)
49+
//|.. class:: OneWire(pin)
5050
//|
51-
//| Create a OneWire object associated with the given pin. The object
52-
//| implements the lowest level timing-sensitive bits of the protocol.
51+
//|Create a OneWire object associated with the given pin. The object
52+
//|implements the lowest level timing-sensitive bits of the protocol.
5353
//|
54-
//| :param ~microcontroller.Pin pin: Pin connected to the OneWire bus
54+
//|:param ~microcontroller.Pin pin: Pin connected to the OneWire bus
5555
//|
56-
//| Read a short series of pulses::
56+
//|Read a short series of pulses::
5757
//|
58-
//| import busio
59-
//| import board
58+
//|import busio
59+
//|import board
6060
//|
61-
//| onewire = busio.OneWire(board.D7)
62-
//| onewire.reset()
63-
//| onewire.write_bit(True)
64-
//| onewire.write_bit(False)
65-
//| print(onewire.read_bit())"""
66-
//| ...
61+
//|onewire = busio.OneWire(board.D7)
62+
//|onewire.reset()
63+
//|onewire.write_bit(True)
64+
//|onewire.write_bit(False)
65+
//|print(onewire.read_bit())"""
66+
//|...
6767
STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
6868
enum { ARG_pin };
6969
static const mp_arg_t allowed_args[] = {
@@ -80,9 +80,9 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
8080
return MP_OBJ_FROM_PTR(self);
8181
}
8282

83-
//| def deinit(self, ) -> Any:
84-
//| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
85-
//| ...
83+
//|def deinit(self, ) -> Any:
84+
//|"""Deinitialize the OneWire bus and release any hardware resources for reuse."""
85+
//|...
8686
STATIC mp_obj_t busio_onewire_deinit(mp_obj_t self_in) {
8787
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
8888
common_hal_busio_onewire_deinit(self);
@@ -96,28 +96,28 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) {
9696
}
9797
}
9898

99-
//| def __enter__(self, ) -> Any:
100-
//| """No-op used by Context Managers."""
101-
//| ...
99+
//|def __enter__(self, ) -> Any:
100+
//|"""No-op used by Context Managers."""
101+
//|...
102102
// Provided by context manager helper.
103103

104-
//| def __exit__(self, ) -> Any:
105-
//| """Automatically deinitializes the hardware when exiting a context. See
106-
//| :ref:`lifetime-and-contextmanagers` for more info."""
107-
//| ...
104+
//|def __exit__(self, ) -> Any:
105+
//|"""Automatically deinitializes the hardware when exiting a context. See
106+
//|:ref:`lifetime-and-contextmanagers` for more info."""
107+
//|...
108108
STATIC mp_obj_t busio_onewire_obj___exit__(size_t n_args, const mp_obj_t *args) {
109109
(void)n_args;
110110
common_hal_busio_onewire_deinit(args[0]);
111111
return mp_const_none;
112112
}
113113
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(busio_onewire___exit___obj, 4, 4, busio_onewire_obj___exit__);
114114

115-
//| def reset(self, ) -> Any:
116-
//| """Reset the OneWire bus and read presence
115+
//|def reset(self, ) -> Any:
116+
//|"""Reset the OneWire bus and read presence
117117
//|
118-
//| :returns: False when at least one device is present
119-
//| :rtype: bool"""
120-
//| ...
118+
//|:returns: False when at least one device is present
119+
//|:rtype: bool"""
120+
//|...
121121
STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) {
122122
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
123123
check_for_deinit(self);
@@ -126,12 +126,12 @@ STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) {
126126
}
127127
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_reset_obj, busio_onewire_obj_reset);
128128

129-
//| def read_bit(self, ) -> Any:
130-
//| """Read in a bit
129+
//|def read_bit(self, ) -> Any:
130+
//|"""Read in a bit
131131
//|
132-
//| :returns: bit state read
133-
//| :rtype: bool"""
134-
//| ...
132+
//|:returns: bit state read
133+
//|:rtype: bool"""
134+
//|...
135135
STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) {
136136
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
137137
check_for_deinit(self);
@@ -140,9 +140,9 @@ STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) {
140140
}
141141
MP_DEFINE_CONST_FUN_OBJ_1(busio_onewire_read_bit_obj, busio_onewire_obj_read_bit);
142142

143-
//| def write_bit(self, value: Any) -> Any:
144-
//| """Write out a bit based on value."""
145-
//| ...
143+
//|def write_bit(self, value: Any) -> Any:
144+
//|"""Write out a bit based on value."""
145+
//|...
146146
STATIC mp_obj_t busio_onewire_obj_write_bit(mp_obj_t self_in, mp_obj_t bool_obj) {
147147
busio_onewire_obj_t *self = MP_OBJ_TO_PTR(self_in);
148148
check_for_deinit(self);

0 commit comments

Comments
 (0)