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//|
6464STATIC 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//|
8181STATIC 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}
8686MP_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//|
9999STATIC 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//|
121120STATIC 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}
140139MP_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//|
159158STATIC 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}
179178MP_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//|
190188typedef 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//|
232229STATIC 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//|
266262STATIC 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//|
314309STATIC 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 );
0 commit comments