36
36
#include "shared-bindings/analogio/AnalogIn.h"
37
37
#include "shared-bindings/util.h"
38
38
39
- //|class AnalogIn:
40
- //|""":class:`AnalogIn` -- read analog voltage
41
- //|============================================
39
+ //| class AnalogIn:
40
+ //| """.. currentmodule:: analogio
42
41
//|
43
- //|Usage::
42
+ //| :class:`AnalogIn` -- read analog voltage
43
+ //| ============================================
44
44
//|
45
- //|import analogio
46
- //|from board import *
45
+ //| Usage::
47
46
//|
48
- //|adc = analogio.AnalogIn(A1)
49
- //|val = adc.value"""
47
+ //| import analogio
48
+ //| from board import *
50
49
//|
51
- //|def __init__(self, pin: microcontroller.Pin):
50
+ //| adc = analogio.AnalogIn(A1)
51
+ //| val = adc.value"""
52
52
//|
53
- //|"""Use the AnalogIn on the given pin. The reference voltage varies by
54
- //|platform so use ``reference_voltage`` to read the configured setting.
53
+
54
+ //| def __init__(self, pin: microcontroller.Pin):
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"""
59
+ //| ...
55
60
//|
56
- //|:param ~microcontroller.Pin pin: the pin to read from"""
57
- //|...
58
61
STATIC mp_obj_t analogio_analogin_make_new (const mp_obj_type_t * type ,
59
62
mp_uint_t n_args , const mp_obj_t * args , mp_map_t * kw_args ) {
60
63
// check number of arguments
@@ -70,9 +73,10 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type,
70
73
return MP_OBJ_FROM_PTR (self );
71
74
}
72
75
73
- //|def deinit(self, ) -> Any:
74
- //|"""Turn off the AnalogIn and release the pin for other use."""
75
- //|...
76
+ //| def deinit(self, ) -> Any:
77
+ //| """Turn off the AnalogIn and release the pin for other use."""
78
+ //| ...
79
+ //|
76
80
STATIC mp_obj_t analogio_analogin_deinit (mp_obj_t self_in ) {
77
81
analogio_analogin_obj_t * self = MP_OBJ_TO_PTR (self_in );
78
82
common_hal_analogio_analogin_deinit (self );
@@ -85,28 +89,30 @@ STATIC void check_for_deinit(analogio_analogin_obj_t *self) {
85
89
raise_deinited_error ();
86
90
}
87
91
}
88
- //|def __enter__(self, ) -> Any:
89
- //|"""No-op used by Context Managers."""
90
- //|...
92
+ //| def __enter__(self, ) -> Any:
93
+ //| """No-op used by Context Managers."""
94
+ //| ...
95
+ //|
91
96
// Provided by context manager helper.
92
97
93
- //|def __exit__(self, ) -> Any:
94
- //|"Automatically deinitializes the hardware when exiting a context. See
95
- //|:ref:`lifetime-and-contextmanagers` for more info."""
96
- //|...
98
+ //| def __exit__(self, ) -> Any:
99
+ //| """Automatically deinitializes the hardware when exiting a context. See
100
+ //| :ref:`lifetime-and-contextmanagers` for more info."""
101
+ //| ...
102
+ //|
97
103
STATIC mp_obj_t analogio_analogin___exit__ (size_t n_args , const mp_obj_t * args ) {
98
104
(void )n_args ;
99
105
common_hal_analogio_analogin_deinit (args [0 ]);
100
106
return mp_const_none ;
101
107
}
102
108
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (analogio_analogin___exit___obj , 4 , 4 , analogio_analogin___exit__ );
103
109
104
- //|value: Any =
105
- //|"""The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only)
110
+ //| value: Any = ...
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."""
106
115
//|
107
- //|Even if the underlying analog to digital converter (ADC) is lower
108
- //|resolution, the value is 16-bit."""
109
- //|...
110
116
STATIC mp_obj_t analogio_analogin_obj_get_value (mp_obj_t self_in ) {
111
117
analogio_analogin_obj_t * self = MP_OBJ_TO_PTR (self_in );
112
118
check_for_deinit (self );
@@ -121,10 +127,10 @@ const mp_obj_property_t analogio_analogin_value_obj = {
121
127
(mp_obj_t )& mp_const_none_obj },
122
128
};
123
129
124
- //|reference_voltage: Any =
125
- //|"""The maximum voltage measurable (also known as the reference voltage) as a
126
- //|`float` in Volts."""
127
- //|...
130
+ //| reference_voltage: Any = ...
131
+ //| """The maximum voltage measurable (also known as the reference voltage) as a
132
+ //| `float` in Volts."""
133
+ //|
128
134
STATIC mp_obj_t analogio_analogin_obj_get_reference_voltage (mp_obj_t self_in ) {
129
135
analogio_analogin_obj_t * self = MP_OBJ_TO_PTR (self_in );
130
136
check_for_deinit (self );
0 commit comments