Skip to content

Commit 7ff9b9b

Browse files
committed
Did first 3
1 parent a2a32fe commit 7ff9b9b

File tree

9 files changed

+351
-313
lines changed

9 files changed

+351
-313
lines changed

shared-bindings/analogio/AnalogIn.c

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

39-
//|class AnalogIn:
40-
//|""":class:`AnalogIn` -- read analog voltage
41-
//|============================================
39+
//| class AnalogIn:
40+
//| """.. currentmodule:: analogio
4241
//|
43-
//|Usage::
42+
//| :class:`AnalogIn` -- read analog voltage
43+
//| ============================================
4444
//|
45-
//|import analogio
46-
//|from board import *
45+
//| Usage::
4746
//|
48-
//|adc = analogio.AnalogIn(A1)
49-
//|val = adc.value"""
47+
//| import analogio
48+
//| from board import *
5049
//|
51-
//|def __init__(self, pin: microcontroller.Pin):
50+
//| adc = analogio.AnalogIn(A1)
51+
//| val = adc.value"""
5252
//|
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+
//| ...
5560
//|
56-
//|:param ~microcontroller.Pin pin: the pin to read from"""
57-
//|...
5861
STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type,
5962
mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
6063
// check number of arguments
@@ -70,9 +73,10 @@ STATIC mp_obj_t analogio_analogin_make_new(const mp_obj_type_t *type,
7073
return MP_OBJ_FROM_PTR(self);
7174
}
7275

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+
//|
7680
STATIC mp_obj_t analogio_analogin_deinit(mp_obj_t self_in) {
7781
analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
7882
common_hal_analogio_analogin_deinit(self);
@@ -85,28 +89,30 @@ STATIC void check_for_deinit(analogio_analogin_obj_t *self) {
8589
raise_deinited_error();
8690
}
8791
}
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+
//|
9196
// Provided by context manager helper.
9297

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+
//|
97103
STATIC mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) {
98104
(void)n_args;
99105
common_hal_analogio_analogin_deinit(args[0]);
100106
return mp_const_none;
101107
}
102108
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogin___exit___obj, 4, 4, analogio_analogin___exit__);
103109

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."""
106115
//|
107-
//|Even if the underlying analog to digital converter (ADC) is lower
108-
//|resolution, the value is 16-bit."""
109-
//|...
110116
STATIC mp_obj_t analogio_analogin_obj_get_value(mp_obj_t self_in) {
111117
analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
112118
check_for_deinit(self);
@@ -121,10 +127,10 @@ const mp_obj_property_t analogio_analogin_value_obj = {
121127
(mp_obj_t)&mp_const_none_obj},
122128
};
123129

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+
//|
128134
STATIC mp_obj_t analogio_analogin_obj_get_reference_voltage(mp_obj_t self_in) {
129135
analogio_analogin_obj_t *self = MP_OBJ_TO_PTR(self_in);
130136
check_for_deinit(self);

shared-bindings/analogio/AnalogOut.c

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

39-
//|class AnalogOut:
40-
//|""".. currentmodule:: analogio
39+
//| class AnalogOut:
40+
//| """.. currentmodule:: analogio
4141
//|
42-
//|:class:`AnalogOut` -- output analog voltage
43-
//|============================================
42+
//| :class:`AnalogOut` -- output analog voltage
43+
//| ============================================
4444
//|
45-
//|The AnalogOut is used to output analog values (a specific voltage).
45+
//| The AnalogOut is used to output analog values (a specific voltage).
4646
//|
47-
//|Example usage::
47+
//| Example usage::
4848
//|
49-
//|import analogio
50-
//|from microcontroller import pin
49+
//| import analogio
50+
//| from microcontroller import pin
5151
//|
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):
55-
//|"""Use the AnalogOut on the given pin.
52+
//| dac = analogio.AnalogOut(pin.PA02) # output on pin PA02
53+
//| dac.value = 32768 # makes PA02 1.65V"""
54+
//|
55+
//| def __init__(self, pin: microcontroller.Pin):
56+
//| """Use the AnalogOut on the given pin.
57+
//|
58+
//| :param ~microcontroller.Pin pin: the pin to output to"""
59+
//| ...
5660
//|
57-
//|:param ~microcontroller.Pin pin: the pin to output to"""
58-
//|...
5961
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) {
6062
// check arguments
6163
mp_arg_check_num(n_args, kw_args, 1, 1, false);
@@ -69,9 +71,10 @@ STATIC mp_obj_t analogio_analogout_make_new(const mp_obj_type_t *type, mp_uint_t
6971
return MP_OBJ_FROM_PTR(self);
7072
}
7173

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

@@ -81,28 +84,30 @@ STATIC mp_obj_t analogio_analogout_deinit(mp_obj_t self_in) {
8184
}
8285
STATIC MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogout_deinit_obj, analogio_analogout_deinit);
8386

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

89-
//|def __exit__(self, ) -> Any:
90-
//|"""Automatically deinitializes the hardware when exiting a context. See
91-
//|:ref:`lifetime-and-contextmanagers` for more info."""
92-
//|...
93+
//| def __exit__(self, ) -> Any:
94+
//| """Automatically deinitializes the hardware when exiting a context. See
95+
//| :ref:`lifetime-and-contextmanagers` for more info."""
96+
//| ...
97+
//|
9398
STATIC mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) {
9499
(void)n_args;
95100
common_hal_analogio_analogout_deinit(args[0]);
96101
return mp_const_none;
97102
}
98103
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4, analogio_analogout___exit__);
99104

100-
//|value: Any =
101-
//|"""The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only)
105+
//| value: Any = ...
106+
//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only)
107+
//|
108+
//| Even if the underlying digital to analog converter (DAC) is lower
109+
//| resolution, the value is 16-bit."""
102110
//|
103-
//|Even if the underlying digital to analog converter (DAC) is lower
104-
//|resolution, the value is 16-bit."""
105-
//|...
106111
STATIC mp_obj_t analogio_analogout_obj_set_value(mp_obj_t self_in, mp_obj_t value) {
107112
analogio_analogout_obj_t *self = MP_OBJ_TO_PTR(self_in);
108113
if (common_hal_analogio_analogout_deinited(self)) {

shared-bindings/analogio/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include "shared-bindings/analogio/AnalogIn.h"
3535
#include "shared-bindings/analogio/AnalogOut.h"
3636

37-
//| :mod:`analogio` --- Analog hardware support
37+
//| """:mod:`analogio` --- Analog hardware support
3838
//| =================================================
3939
//|
4040
//| .. module:: analogio
@@ -70,7 +70,7 @@
7070
//| This example will initialize the the device, read
7171
//| :py:data:`~analogio.AnalogIn.value` and then
7272
//| :py:meth:`~analogio.AnalogIn.deinit` the hardware. The last step is optional
73-
//| because CircuitPython will do it automatically after the program finishes.
73+
//| because CircuitPython will do it automatically after the program finishes."""
7474
//|
7575

7676
STATIC const mp_rom_map_elem_t analogio_module_globals_table[] = {

0 commit comments

Comments
 (0)