43
43
#include "shared-bindings/util.h"
44
44
#include "supervisor/shared/translate.h"
45
45
46
- //| .. currentmodule:: digitalio
46
+ //| class DigitalInOut:
47
+ //| """.. currentmodule:: digitalio
47
48
//|
48
- //| :class:`DigitalInOut` -- digital input and output
49
- //| =========================================================
49
+ //| :class:`DigitalInOut` -- digital input and output
50
+ //| =========================================================
50
51
//|
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."""
54
55
//|
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.
61
60
//|
62
- //| :param ~microcontroller.Pin pin: The pin to control
61
+ //| :param ~microcontroller.Pin pin: The pin to control"""
62
+ //| ...
63
63
//|
64
64
STATIC mp_obj_t digitalio_digitalinout_make_new (const mp_obj_type_t * type ,
65
65
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,
74
74
return MP_OBJ_FROM_PTR (self );
75
75
}
76
76
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
+ //| .. .
80
80
//|
81
81
STATIC mp_obj_t digitalio_digitalinout_obj_deinit (mp_obj_t self_in ) {
82
82
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) {
85
85
}
86
86
MP_DEFINE_CONST_FUN_OBJ_1 (digitalio_digitalinout_deinit_obj , digitalio_digitalinout_obj_deinit );
87
87
88
- //| .. method:: __enter__()
89
- //|
90
- //| No-op used by Context Managers .
88
+ //| def __enter__(self, ) -> Any:
89
+ //| """No-op used by Context Managers."""
90
+ //| .. .
91
91
//|
92
92
// Provided by context manager helper.
93
93
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
+ //| .. .
98
98
//|
99
99
STATIC mp_obj_t digitalio_digitalinout_obj___exit__ (size_t n_args , const mp_obj_t * args ) {
100
100
(void )n_args ;
@@ -109,14 +109,13 @@ STATIC void check_for_deinit(digitalio_digitalinout_obj_t *self) {
109
109
}
110
110
}
111
111
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.
112
115
//|
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
+ //| ...
120
119
//|
121
120
STATIC mp_obj_t digitalio_digitalinout_switch_to_output (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
122
121
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_
139
138
}
140
139
MP_DEFINE_CONST_FUN_OBJ_KW (digitalio_digitalinout_switch_to_output_obj , 1 , digitalio_digitalinout_switch_to_output );
141
140
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.
145
143
//|
146
- //| :param Pull pull: pull configuration for the input
144
+ //| :param Pull pull: pull configuration for the input
147
145
//|
148
- //| Example usage::
146
+ //| Example usage::
149
147
//|
150
- //| import digitalio
151
- //| import board
148
+ //| import digitalio
149
+ //| import board
152
150
//|
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
+ //| ...
158
157
//|
159
158
STATIC mp_obj_t digitalio_digitalinout_switch_to_input (size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
160
159
enum { ARG_pull };
@@ -178,14 +177,13 @@ STATIC mp_obj_t digitalio_digitalinout_switch_to_input(size_t n_args, const mp_o
178
177
}
179
178
MP_DEFINE_CONST_FUN_OBJ_KW (digitalio_digitalinout_switch_to_input_obj , 1 , digitalio_digitalinout_switch_to_input );
180
179
181
- //| .. attribute:: direction
182
- //|
183
- //| The direction of the pin.
180
+ //| direction: Any = ...
181
+ //| """The direction of the pin.
184
182
//|
185
183
//| Setting this will use the defaults from the corresponding
186
184
//| :py:meth:`switch_to_input` or :py:meth:`switch_to_output` method. If
187
185
//| you want to set pull, value or drive mode prior to switching, then use
188
- //| those methods instead.
186
+ //| those methods instead."""
189
187
//|
190
188
typedef struct {
191
189
mp_obj_base_t base ;
@@ -225,9 +223,8 @@ const mp_obj_property_t digitalio_digitalio_direction_obj = {
225
223
(mp_obj_t )& mp_const_none_obj },
226
224
};
227
225
228
- //| .. attribute:: value
229
- //|
230
- //| The digital logic level of the pin.
226
+ //| value: Any = ...
227
+ //| """The digital logic level of the pin."""
231
228
//|
232
229
STATIC mp_obj_t digitalio_digitalinout_obj_get_value (mp_obj_t self_in ) {
233
230
digitalio_digitalinout_obj_t * self = MP_OBJ_TO_PTR (self_in );
@@ -256,12 +253,11 @@ const mp_obj_property_t digitalio_digitalinout_value_obj = {
256
253
(mp_obj_t )& mp_const_none_obj },
257
254
};
258
255
259
- //| .. attribute:: drive_mode
260
- //|
261
- //| The pin drive mode. One of:
256
+ //| drive_mode: Any = ...
257
+ //| """The pin drive mode. One of:
262
258
//|
263
259
//| - `digitalio.DriveMode.PUSH_PULL`
264
- //| - `digitalio.DriveMode.OPEN_DRAIN`
260
+ //| - `digitalio.DriveMode.OPEN_DRAIN`"""
265
261
//|
266
262
STATIC mp_obj_t digitalio_digitalinout_obj_get_drive_mode (mp_obj_t self_in ) {
267
263
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 = {
301
297
(mp_obj_t )& mp_const_none_obj },
302
298
};
303
299
304
- //| .. attribute:: pull
305
- //|
306
- //| The pin pull direction. One of:
300
+ //| pull: Any = ...
301
+ //| """The pin pull direction. One of:
307
302
//|
308
303
//| - `digitalio.Pull.UP`
309
304
//| - `digitalio.Pull.DOWN`
310
305
//| - `None`
311
306
//|
312
- //| :raises AttributeError: if `direction` is :py:data:`~digitalio.Direction.OUTPUT`.
307
+ //| :raises AttributeError: if `direction` is :py:data:`~digitalio.Direction.OUTPUT`."""
313
308
//|
314
309
STATIC mp_obj_t digitalio_digitalinout_obj_get_pull (mp_obj_t self_in ) {
315
310
digitalio_digitalinout_obj_t * self = MP_OBJ_TO_PTR (self_in );
0 commit comments