Skip to content

Commit 8344fce

Browse files
committed
Added inline pyi to analogio
1 parent 27e085e commit 8344fce

2 files changed

Lines changed: 61 additions & 72 deletions

File tree

shared-bindings/analogio/AnalogIn.c

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,25 @@
3636
#include "shared-bindings/analogio/AnalogIn.h"
3737
#include "shared-bindings/util.h"
3838

39-
//| .. currentmodule:: analogio
39+
//|class AnalogIn:
40+
//| """:class:`AnalogIn` -- read analog voltage
41+
//| ============================================
4042
//|
41-
//| :class:`AnalogIn` -- read analog voltage
42-
//| ============================================
43+
//| Usage::
4344
//|
44-
//| Usage::
45+
//| import analogio
46+
//| from board import *
4547
//|
46-
//| import analogio
47-
//| from board import *
48+
//| adc = analogio.AnalogIn(A1)
49+
//| val = adc.value"""
4850
//|
49-
//| adc = analogio.AnalogIn(A1)
50-
//| val = adc.value
51+
//| def __init__(self, pin: microcontroller.Pin):
5152
//|
52-
53-
//| .. class:: AnalogIn(pin)
54-
//|
55-
//| Use the AnalogIn on the given pin. The reference voltage varies by
56-
//| platform so use ``reference_voltage`` to read the configured setting.
57-
//|
58-
//| :param ~microcontroller.Pin pin: the pin to read from
53+
//| """Use the AnalogIn on the given pin. The reference voltage varies by
54+
//| platform so use ``reference_voltage`` to read the configured setting.
5955
//|
56+
//| :param ~microcontroller.Pin pin: the pin to read from"""
57+
//| ...
6058
STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type,
6159
mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
6260
// check number of arguments
@@ -72,10 +70,9 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type,
7270
return MP_OBJ_FROM_PTR(self);
7371
}
7472

75-
//| .. method:: deinit()
76-
//|
77-
//| Turn off the AnalogIn and release the pin for other use.
78-
//|
73+
//| def deinit(self, ) -> Any:
74+
//| """Turn off the AnalogIn and release the pin for other use."""
75+
//| ...
7976
STATIC mp_obj_t analogio_analogin_deinit(mp_obj_t self_in) {
8077
analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
8178
common_hal_analogio_analogin_deinit(self);
@@ -88,31 +85,28 @@ STATIC void check_for_deinit(analogio_analogin_obj_t *self) {
8885
raise_deinited_error();
8986
}
9087
}
91-
//| .. method:: __enter__()
92-
//|
93-
//| No-op used by Context Managers.
94-
//|
88+
//| def __enter__(self, ) -> Any:
89+
//| """No-op used by Context Managers."""
90+
//| ...
9591
// Provided by context manager helper.
9692

97-
//| .. method:: __exit__()
98-
//|
99-
//| Automatically deinitializes the hardware when exiting a context. See
100-
//| :ref:`lifetime-and-contextmanagers` for more info.
101-
//|
93+
//| def __exit__(self, ) -> Any:
94+
//| """Automatically deinitializes the hardware when exiting a context. See
95+
//| :ref:`lifetime-and-contextmanagers` for more info."""
96+
//| ...
10297
STATIC mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) {
10398
(void)n_args;
10499
common_hal_analogio_analogin_deinit(args[0]);
105100
return mp_const_none;
106101
}
107102
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogin___exit___obj, 4, 4, analogio_analogin___exit__);
108103

109-
//| .. attribute:: value
110-
//|
111-
//| The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only)
112-
//|
113-
//| Even if the underlying analog to digital converter (ADC) is lower
114-
//| resolution, the value is 16-bit.
104+
//| value: Any =
105+
//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only)
115106
//|
107+
//| Even if the underlying analog to digital converter (ADC) is lower
108+
//| resolution, the value is 16-bit."""
109+
//| ...
116110
STATIC mp_obj_t analogio_analogin_obj_get_value(mp_obj_t self_in) {
117111
analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
118112
check_for_deinit(self);
@@ -127,11 +121,10 @@ const mp_obj_property_t analogio_analogin_value_obj = {
127121
(mp_obj_t)&mp_const_none_obj},
128122
};
129123

130-
//| .. attribute:: reference_voltage
131-
//|
132-
//| The maximum voltage measurable (also known as the reference voltage) as a
133-
//| `float` in Volts.
134-
//|
124+
//| reference_voltage: Any =
125+
//| """The maximum voltage measurable (also known as the reference voltage) as a
126+
//| `float` in Volts."""
127+
//| ...
135128
STATIC mp_obj_t analogio_analogin_obj_get_reference_voltage(mp_obj_t self_in) {
136129
analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
137130
check_for_deinit(self);

shared-bindings/analogio/AnalogOut.c

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,27 @@
3636
#include "shared-bindings/util.h"
3737
#include "supervisor/shared/translate.h"
3838

39-
//| .. currentmodule:: analogio
39+
//|class AnalogOut:
40+
//| """.. currentmodule:: analogio
4041
//|
41-
//| :class:`AnalogOut` -- output analog voltage
42-
//| ============================================
42+
//| :class:`AnalogOut` -- output analog voltage
43+
//| ============================================
4344
//|
44-
//| The AnalogOut is used to output analog values (a specific voltage).
45+
//| The AnalogOut is used to output analog values (a specific voltage).
4546
//|
46-
//| Example usage::
47+
//| Example usage::
4748
//|
48-
//| import analogio
49-
//| from microcontroller import pin
49+
//| import analogio
50+
//| from microcontroller import pin
5051
//|
51-
//| dac = analogio.AnalogOut(pin.PA02) # output on pin PA02
52-
//| dac.value = 32768 # makes PA02 1.65V
52+
//| dac = analogio.AnalogOut(pin.PA02) # output on pin PA02
53+
//| dac.value = 32768 # makes PA02 1.65V"""
54+
//| def __init__(self, pin: microcontroller.Pin):
5355
//|
54-
55-
//| .. class:: AnalogOut(pin)
56-
//|
57-
//| Use the AnalogOut on the given pin.
58-
//|
59-
//| :param ~microcontroller.Pin pin: the pin to output to
56+
//| """Use the AnalogOut on the given pin.
6057
//|
58+
//| :param ~microcontroller.Pin pin: the pin to output to"""
59+
//| ...
6160
STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
6261
// check arguments
6362
mp_arg_check_num(n_args, kw_args, 1, 1, false);
@@ -71,10 +70,9 @@ STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t
7170
return MP_OBJ_FROM_PTR(self);
7271
}
7372

74-
//| .. method:: deinit()
75-
//|
76-
//| Turn off the AnalogOut and release the pin for other use.
77-
//|
73+
//| def deinit(self, ) -> Any:
74+
//| """Turn off the AnalogOut and release the pin for other use."""
75+
//| ...
7876
STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) {
7977
analogio_analogout_obj_t *self = self_in;
8078

@@ -84,30 +82,28 @@ STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) {
8482
}
8583
STATIC MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogout_deinit_obj, analogio_analogout_deinit);
8684

87-
//| .. method:: __enter__()
88-
//|
89-
//| No-op used by Context Managers.
90-
//|
85+
//| def __enter__(self, ) -> Any:
86+
//| """No-op used by Context Managers."""
87+
//| ...
9188
// Provided by context manager helper.
9289

93-
//| .. method:: __exit__()
94-
//|
95-
//| Automatically deinitializes the hardware when exiting a context. See
96-
//| :ref:`lifetime-and-contextmanagers` for more info.
97-
//|
90+
//| def __exit__(self, ) -> Any:
91+
//| """Automatically deinitializes the hardware when exiting a context. See
92+
//| :ref:`lifetime-and-contextmanagers` for more info."""
93+
//| ...
9894
STATIC mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) {
9995
(void)n_args;
10096
common_hal_analogio_analogout_deinit(args[0]);
10197
return mp_const_none;
10298
}
10399
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4, analogio_analogout___exit__);
104100

105-
//| .. attribute:: value
106-
//|
107-
//| The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only)
101+
//| value: Any =
102+
//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only)
108103
//|
109-
//| Even if the underlying digital to analog converter (DAC) is lower
110-
//| resolution, the value is 16-bit.
104+
//| Even if the underlying digital to analog converter (DAC) is lower
105+
//| resolution, the value is 16-bit."""
106+
//| ...
111107
STATIC mp_obj_t analogio_analogout_obj_set_value(mp_obj_t self_in, mp_obj_t value) {
112108
analogio_analogout_obj_t *self = MP_OBJ_TO_PTR(self_in);
113109
if (common_hal_analogio_analogout_deinited(self)) {

0 commit comments

Comments
 (0)