Skip to content

Commit 2ebe303

Browse files
committed
Did board, digitalio, displayio
1 parent 0e465e6 commit 2ebe303

19 files changed

+610
-627
lines changed

shared-bindings/board/__init__.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "shared-bindings/board/__init__.h"
3131

32-
//| :mod:`board` --- Board specific pin names
32+
//| """:mod:`board` --- Board specific pin names
3333
//| ========================================================
3434
//|
3535
//| .. module:: board
@@ -39,11 +39,11 @@
3939
//| board so don't expect portability when using this module.
4040
//|
4141
//| .. warning:: The board module varies by board. The APIs documented here may or may not be
42-
//| available on a specific board.
42+
//| available on a specific board."""
4343

44-
//| .. function:: I2C()
45-
//|
46-
//| Returns the `busio.I2C` object for the board designated SDA and SCL pins. It is a singleton.
44+
//| def I2C() -> Any:
45+
//| """Returns the `busio.I2C` object for the board designated SDA and SCL pins. It is a singleton."""
46+
//| ...
4747
//|
4848

4949
#if BOARD_I2C
@@ -65,10 +65,10 @@ mp_obj_t board_i2c(void) {
6565
MP_DEFINE_CONST_FUN_OBJ_0(board_i2c_obj, board_i2c);
6666

6767

68-
//| .. function:: SPI()
69-
//|
70-
//| Returns the `busio.SPI` object for the board designated SCK, MOSI and MISO pins. It is a
71-
//| singleton.
68+
//| def SPI() -> Any:
69+
//| """Returns the `busio.SPI` object for the board designated SCK, MOSI and MISO pins. It is a
70+
//| singleton."""
71+
//| ...
7272
//|
7373
#if BOARD_SPI
7474
mp_obj_t board_spi(void) {
@@ -89,15 +89,14 @@ mp_obj_t board_spi(void) {
8989
#endif
9090
MP_DEFINE_CONST_FUN_OBJ_0(board_spi_obj, board_spi);
9191

92-
//| .. function:: UART()
93-
//|
94-
//| Returns the `busio.UART` object for the board designated TX and RX pins. It is a singleton.
95-
//|
96-
//| The object created uses the default parameter values for `busio.UART`. If you need to set
97-
//| parameters that are not changeable after creation, such as ``receiver_buffer_size``,
98-
//| do not use `board.UART()`; instead create a `busio.UART` object explicitly with the
99-
//| desired parameters.
92+
//| def UART() -> Any:
93+
//| """Returns the `busio.UART` object for the board designated TX and RX pins. It is a singleton.
10094
//|
95+
//| The object created uses the default parameter values for `busio.UART`. If you need to set
96+
//| parameters that are not changeable after creation, such as ``receiver_buffer_size``,
97+
//| do not use `board.UART()`; instead create a `busio.UART` object explicitly with the
98+
//| desired parameters."""
99+
//| ...
101100
//|
102101
#if BOARD_UART
103102
mp_obj_t board_uart(void) {

shared-bindings/digitalio/DigitalInOut.c

Lines changed: 52 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,23 @@
4343
#include "shared-bindings/util.h"
4444
#include "supervisor/shared/translate.h"
4545

46-
//| .. currentmodule:: digitalio
46+
//| class DigitalInOut:
47+
//| """.. currentmodule:: digitalio
4748
//|
48-
//| :class:`DigitalInOut` -- digital input and output
49-
//| =========================================================
49+
//| :class:`DigitalInOut` -- digital input and output
50+
//| =========================================================
5051
//|
51-
//| A DigitalInOut is used to digitally control I/O pins. For analog control of
52-
//| a pin, see the :py:class:`analogio.AnalogIn` and
53-
//| :py:class:`analogio.AnalogOut` classes.
52+
//| A DigitalInOut is used to digitally control I/O pins. For analog control of
53+
//| a pin, see the :py:class:`analogio.AnalogIn` and
54+
//| :py:class:`analogio.AnalogOut` classes."""
5455
//|
55-
56-
//| .. class:: DigitalInOut(pin)
57-
//|
58-
//| Create a new DigitalInOut object associated with the pin. Defaults to input
59-
//| with no pull. Use :py:meth:`switch_to_input` and
60-
//| :py:meth:`switch_to_output` to change the direction.
56+
//| def __init__(self, pin: microcontroller.Pin):
57+
//| """Create a new DigitalInOut object associated with the pin. Defaults to input
58+
//| with no pull. Use :py:meth:`switch_to_input` and
59+
//| :py:meth:`switch_to_output` to change the direction.
6160
//|
62-
//| :param ~microcontroller.Pin pin: The pin to control
61+
//| :param ~microcontroller.Pin pin: The pin to control"""
62+
//| ...
6363
//|
6464
STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type,
6565
mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
@@ -74,9 +74,9 @@ STATIC mp_obj_t digitalio_digitalinout_make_new(const mp_obj_type_t *type,
7474
return MP_OBJ_FROM_PTR(self);
7575
}
7676

77-
//| .. method:: deinit()
78-
//|
79-
//| Turn off the DigitalInOut and release the pin for other use.
77+
//| def deinit(self, ) -> Any:
78+
//| """Turn off the DigitalInOut and release the pin for other use."""
79+
//| ...
8080
//|
8181
STATIC mp_obj_t digitalio_digitalinout_obj_deinit(mp_obj_t self_in) {
8282
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -85,16 +85,16 @@ STATIC mp_obj_t digitalio_digitalinout_obj_deinit(mp_obj_t self_in) {
8585
}
8686
MP_DEFINE_CONST_FUN_OBJ_1(digitalio_digitalinout_deinit_obj, digitalio_digitalinout_obj_deinit);
8787

88-
//| .. method:: __enter__()
89-
//|
90-
//| No-op used by Context Managers.
88+
//| def __enter__(self, ) -> Any:
89+
//| """No-op used by Context Managers."""
90+
//| ...
9191
//|
9292
// Provided by context manager helper.
9393

94-
//| .. method:: __exit__()
95-
//|
96-
//| Automatically deinitializes the hardware when exiting a context. See
97-
//| :ref:`lifetime-and-contextmanagers` for more info.
94+
//| def __exit__(self, ) -> Any:
95+
//| """Automatically deinitializes the hardware when exiting a context. See
96+
//| :ref:`lifetime-and-contextmanagers` for more info."""
97+
//| ...
9898
//|
9999
STATIC mp_obj_t digitalio_digitalinout_obj___exit__(size_t n_args, const mp_obj_t *args) {
100100
(void)n_args;
@@ -109,14 +109,13 @@ STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) {
109109
}
110110
}
111111

112+
//| def switch_to_output(self, value: bool = False, drive_mode: digitalio.DriveMode = digitalio.DriveMode.PUSH_PULL) -> Any:
113+
//| """Set the drive mode and value and then switch to writing out digital
114+
//| values.
112115
//|
113-
//| .. method:: switch_to_output(value=False, drive_mode=digitalio.DriveMode.PUSH_PULL)
114-
//|
115-
//| Set the drive mode and value and then switch to writing out digital
116-
//| values.
117-
//|
118-
//| :param bool value: default value to set upon switching
119-
//| :param ~digitalio.DriveMode drive_mode: drive mode for the output
116+
//| :param bool value: default value to set upon switching
117+
//| :param ~digitalio.DriveMode drive_mode: drive mode for the output"""
118+
//| ...
120119
//|
121120
STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
122121
enum { ARG_value, ARG_drive_mode };
@@ -139,22 +138,22 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_output(size_t n_args, const mp_
139138
}
140139
MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_output_obj, 1, digitalio_digitalinout_switch_to_output);
141140

142-
//| .. method:: switch_to_input(pull=None)
143-
//|
144-
//| Set the pull and then switch to read in digital values.
141+
//| def switch_to_input(self, pull: Pull = None) -> Any:
142+
//| """Set the pull and then switch to read in digital values.
145143
//|
146-
//| :param Pull pull: pull configuration for the input
144+
//| :param Pull pull: pull configuration for the input
147145
//|
148-
//| Example usage::
146+
//| Example usage::
149147
//|
150-
//| import digitalio
151-
//| import board
148+
//| import digitalio
149+
//| import board
152150
//|
153-
//| switch = digitalio.DigitalInOut(board.SLIDE_SWITCH)
154-
//| switch.switch_to_input(pull=digitalio.Pull.UP)
155-
//| # Or, after switch_to_input
156-
//| switch.pull = digitalio.Pull.UP
157-
//| print(switch.value)
151+
//| switch = digitalio.DigitalInOut(board.SLIDE_SWITCH)
152+
//| switch.switch_to_input(pull=digitalio.Pull.UP)
153+
//| # Or, after switch_to_input
154+
//| switch.pull = digitalio.Pull.UP
155+
//| print(switch.value)"""
156+
//| ...
158157
//|
159158
STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
160159
enum { ARG_pull };
@@ -178,14 +177,13 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o
178177
}
179178
MP_DEFINE_CONST_FUN_OBJ_KW(digitalio_digitalinout_switch_to_input_obj, 1, digitalio_digitalinout_switch_to_input);
180179

181-
//| .. attribute:: direction
182-
//|
183-
//| The direction of the pin.
180+
//| direction: Any = ...
181+
//| """The direction of the pin.
184182
//|
185183
//| Setting this will use the defaults from the corresponding
186184
//| :py:meth:`switch_to_input` or :py:meth:`switch_to_output` method. If
187185
//| you want to set pull, value or drive mode prior to switching, then use
188-
//| those methods instead.
186+
//| those methods instead."""
189187
//|
190188
typedef struct {
191189
mp_obj_base_t base;
@@ -225,9 +223,8 @@ const mp_obj_property_t digitalio_digitalio_direction_obj = {
225223
(mp_obj_t)&mp_const_none_obj},
226224
};
227225

228-
//| .. attribute:: value
229-
//|
230-
//| The digital logic level of the pin.
226+
//| value: Any = ...
227+
//| """The digital logic level of the pin."""
231228
//|
232229
STATIC mp_obj_t digitalio_digitalinout_obj_get_value(mp_obj_t self_in) {
233230
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -256,12 +253,11 @@ const mp_obj_property_t digitalio_digitalinout_value_obj = {
256253
(mp_obj_t)&mp_const_none_obj},
257254
};
258255

259-
//| .. attribute:: drive_mode
260-
//|
261-
//| The pin drive mode. One of:
256+
//| drive_mode: Any = ...
257+
//| """The pin drive mode. One of:
262258
//|
263259
//| - `digitalio.DriveMode.PUSH_PULL`
264-
//| - `digitalio.DriveMode.OPEN_DRAIN`
260+
//| - `digitalio.DriveMode.OPEN_DRAIN`"""
265261
//|
266262
STATIC mp_obj_t digitalio_digitalinout_obj_get_drive_mode(mp_obj_t self_in) {
267263
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -301,15 +297,14 @@ const mp_obj_property_t digitalio_digitalio_drive_mode_obj = {
301297
(mp_obj_t)&mp_const_none_obj},
302298
};
303299

304-
//| .. attribute:: pull
305-
//|
306-
//| The pin pull direction. One of:
300+
//| pull: Any = ...
301+
//| """The pin pull direction. One of:
307302
//|
308303
//| - `digitalio.Pull.UP`
309304
//| - `digitalio.Pull.DOWN`
310305
//| - `None`
311306
//|
312-
//| :raises AttributeError: if `direction` is :py:data:`~digitalio.Direction.OUTPUT`.
307+
//| :raises AttributeError: if `direction` is :py:data:`~digitalio.Direction.OUTPUT`."""
313308
//|
314309
STATIC mp_obj_t digitalio_digitalinout_obj_get_pull(mp_obj_t self_in) {
315310
digitalio_digitalinout_obj_t *self = MP_OBJ_TO_PTR(self_in);

shared-bindings/digitalio/Direction.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,22 @@
3838
#include "shared-bindings/microcontroller/Pin.h"
3939
#include "shared-bindings/digitalio/DigitalInOut.h"
4040

41-
//| .. currentmodule:: digitalio
41+
//| class Direction:
42+
//| """.. currentmodule:: digitalio
4243
//|
43-
//| :class:`Direction` -- defines the direction of a digital pin
44-
//| =============================================================
44+
//| :class:`Direction` -- defines the direction of a digital pin
45+
//| ============================================================="""
4546
//|
46-
//| .. class:: Direction
47+
//| def __init__(self, ):
48+
//| """Enum-like class to define which direction the digital values are
49+
//| going."""
50+
//| ...
4751
//|
48-
//| Enum-like class to define which direction the digital values are
49-
//| going.
52+
//| INPUT: Any = ...
53+
//| """Read digital data in"""
5054
//|
51-
//| .. data:: INPUT
52-
//|
53-
//| Read digital data in
54-
//|
55-
//| .. data:: OUTPUT
56-
//|
57-
//| Write digital data out
55+
//| OUTPUT: Any = ...
56+
//| """Write digital data out"""
5857
//|
5958
const mp_obj_type_t digitalio_direction_type;
6059

shared-bindings/digitalio/DriveMode.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,23 @@
2626

2727
#include "shared-bindings/digitalio/DriveMode.h"
2828

29-
//| .. currentmodule:: digitalio
29+
//| class DriveMode:
30+
//| """.. currentmodule:: digitalio
3031
//|
31-
//| :class:`DriveMode` -- defines the drive mode of a digital pin
32-
//| =============================================================
32+
//| :class:`DriveMode` -- defines the drive mode of a digital pin
33+
//| ============================================================="""
3334
//|
34-
//| .. class:: DriveMode
35+
//| def __init__(self, ):
36+
//| """Enum-like class to define the drive mode used when outputting
37+
//| digital values."""
38+
//| ...
3539
//|
36-
//| Enum-like class to define the drive mode used when outputting
37-
//| digital values.
40+
//| PUSH_PULL: Any = ...
41+
//| """Output both high and low digital values"""
3842
//|
39-
//| .. data:: PUSH_PULL
40-
//|
41-
//| Output both high and low digital values
42-
//|
43-
//| .. data:: OPEN_DRAIN
44-
//|
45-
//| Output low digital values but go into high z for digital high. This is
46-
//| useful for i2c and other protocols that share a digital line.
43+
//| OPEN_DRAIN: Any = ...
44+
//| """Output low digital values but go into high z for digital high. This is
45+
//| useful for i2c and other protocols that share a digital line."""
4746
//|
4847
const mp_obj_type_t digitalio_drive_mode_type;
4948

shared-bindings/digitalio/Pull.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,24 @@
2626

2727
#include "shared-bindings/digitalio/Pull.h"
2828

29-
//| .. currentmodule:: digitalio
29+
//| class Pull:
30+
//| """.. currentmodule:: digitalio
3031
//|
31-
//| :class:`Pull` -- defines the pull of a digital input pin
32-
//| =============================================================
32+
//| :class:`Pull` -- defines the pull of a digital input pin
33+
//| ============================================================="""
3334
//|
34-
//| .. class:: Pull
35+
//| def __init__(self, ):
36+
//| """Enum-like class to define the pull value, if any, used while reading
37+
//| digital values in."""
38+
//| ...
3539
//|
36-
//| Enum-like class to define the pull value, if any, used while reading
37-
//| digital values in.
40+
//| UP: Any = ...
41+
//| """When the input line isn't being driven the pull up can pull the state
42+
//| of the line high so it reads as true."""
3843
//|
39-
//| .. data:: UP
40-
//|
41-
//| When the input line isn't being driven the pull up can pull the state
42-
//| of the line high so it reads as true.
43-
//|
44-
//| .. data:: DOWN
45-
//|
46-
//| When the input line isn't being driven the pull down can pull the
47-
//| state of the line low so it reads as false.
44+
//| DOWN: Any = ...
45+
//| """When the input line isn't being driven the pull down can pull the
46+
//| state of the line low so it reads as false."""
4847
//|
4948
const mp_obj_type_t digitalio_pull_type;
5049

shared-bindings/digitalio/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
#include "py/runtime.h"
4040

41-
//| :mod:`digitalio` --- Basic digital pin support
41+
//| """:mod:`digitalio` --- Basic digital pin support
4242
//| =================================================
4343
//|
4444
//| .. module:: digitalio
@@ -86,7 +86,7 @@
8686
//| led.value = True
8787
//| time.sleep(0.1)
8888
//| led.value = False
89-
//| time.sleep(0.1)
89+
//| time.sleep(0.1)"""
9090
//|
9191

9292
STATIC const mp_rom_map_elem_t digitalio_module_globals_table[] = {

0 commit comments

Comments
 (0)