3434#include "shared-bindings/busio/OneWire.h"
3535#include "shared-bindings/util.h"
3636
37- //| .. currentmodule:: busio
37+ //|class OneWire:
38+ //| """.. currentmodule:: busio
3839//|
39- //| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol
40- //| =================================================================
40+ //| :class:`OneWire` -- Lowest-level of the Maxim OneWire protocol
41+ //| ================================================================="""
4142//|
42- //| :class:`~busio.OneWire` implements the timing-sensitive foundation of the Maxim
43- //| (formerly Dallas Semi) OneWire protocol.
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.
4446//|
45- //| 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
4648//|
47- //| .. class:: OneWire(pin)
49+ //| .. class:: OneWire(pin)
4850//|
49- //| Create a OneWire object associated with the given pin. The object
50- //| 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.
5153//|
52- //| :param ~microcontroller.Pin pin: Pin connected to the OneWire bus
54+ //| :param ~microcontroller.Pin pin: Pin connected to the OneWire bus
5355//|
54- //| Read a short series of pulses::
56+ //| Read a short series of pulses::
5557//|
56- //| import busio
57- //| import board
58- //|
59- //| onewire = busio.OneWire(board.D7)
60- //| onewire.reset()
61- //| onewire.write_bit(True)
62- //| onewire.write_bit(False)
63- //| print(onewire.read_bit())
58+ //| import busio
59+ //| import board
6460//|
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+ //| ...
6567STATIC 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 ) {
6668 enum { ARG_pin };
6769 static const mp_arg_t allowed_args [] = {
@@ -78,10 +80,9 @@ STATIC mp_obj_t busio_onewire_make_new(const mp_obj_type_t *type, size_t n_args,
7880 return MP_OBJ_FROM_PTR (self );
7981}
8082
81- //| .. method:: deinit()
82- //|
83- //| Deinitialize the OneWire bus and release any hardware resources for reuse.
84- //|
83+ //| def deinit(self, ) -> Any:
84+ //| """Deinitialize the OneWire bus and release any hardware resources for reuse."""
85+ //| ...
8586STATIC mp_obj_t busio_onewire_deinit (mp_obj_t self_in ) {
8687 busio_onewire_obj_t * self = MP_OBJ_TO_PTR (self_in );
8788 common_hal_busio_onewire_deinit (self );
@@ -95,31 +96,28 @@ STATIC void check_for_deinit(busio_onewire_obj_t *self) {
9596 }
9697}
9798
98- //| .. method:: __enter__()
99- //|
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- //| .. method:: __exit__()
105- //|
106- //| Automatically deinitializes the hardware when exiting a context. See
107- //| :ref:`lifetime-and-contextmanagers` for more info.
108- //|
104+ //| def __exit__(self, ) -> Any:
105+ //| """Automatically deinitializes the hardware when exiting a context. See
106+ //| :ref:`lifetime-and-contextmanagers` for more info."""
107+ //| ...
109108STATIC mp_obj_t busio_onewire_obj___exit__ (size_t n_args , const mp_obj_t * args ) {
110109 (void )n_args ;
111110 common_hal_busio_onewire_deinit (args [0 ]);
112111 return mp_const_none ;
113112}
114113STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (busio_onewire___exit___obj , 4 , 4 , busio_onewire_obj___exit__ );
115114
116- //| .. method:: reset()
117- //|
118- //| Reset the OneWire bus and read presence
119- //|
120- //| :returns: False when at least one device is present
121- //| :rtype: bool
115+ //| def reset(self, ) -> Any:
116+ //| """Reset the OneWire bus and read presence
122117//|
118+ //| :returns: False when at least one device is present
119+ //| :rtype: bool"""
120+ //| ...
123121STATIC mp_obj_t busio_onewire_obj_reset (mp_obj_t self_in ) {
124122 busio_onewire_obj_t * self = MP_OBJ_TO_PTR (self_in );
125123 check_for_deinit (self );
@@ -128,13 +126,12 @@ STATIC mp_obj_t busio_onewire_obj_reset(mp_obj_t self_in) {
128126}
129127MP_DEFINE_CONST_FUN_OBJ_1 (busio_onewire_reset_obj , busio_onewire_obj_reset );
130128
131- //| .. method:: read_bit()
132- //|
133- //| Read in a bit
134- //|
135- //| :returns: bit state read
136- //| :rtype: bool
129+ //| def read_bit(self, ) -> Any:
130+ //| """Read in a bit
137131//|
132+ //| :returns: bit state read
133+ //| :rtype: bool"""
134+ //| ...
138135STATIC mp_obj_t busio_onewire_obj_read_bit (mp_obj_t self_in ) {
139136 busio_onewire_obj_t * self = MP_OBJ_TO_PTR (self_in );
140137 check_for_deinit (self );
@@ -143,10 +140,9 @@ STATIC mp_obj_t busio_onewire_obj_read_bit(mp_obj_t self_in) {
143140}
144141MP_DEFINE_CONST_FUN_OBJ_1 (busio_onewire_read_bit_obj , busio_onewire_obj_read_bit );
145142
146- //| .. method:: write_bit(value)
147- //|
148- //| Write out a bit based on value.
149- //|
143+ //| def write_bit(self, value: Any) -> Any:
144+ //| """Write out a bit based on value."""
145+ //| ...
150146STATIC mp_obj_t busio_onewire_obj_write_bit (mp_obj_t self_in , mp_obj_t bool_obj ) {
151147 busio_onewire_obj_t * self = MP_OBJ_TO_PTR (self_in );
152148 check_for_deinit (self );
0 commit comments