37
37
#include "shared-bindings/adcbuffer/BufferedInput.h"
38
38
#include "shared-bindings/util.h"
39
39
40
- /// class BufferedInput:
41
- /// """Input analog voltage level to supplied buffer using DMA Capture"""
42
- ///
43
- /// def __init__(self, pin: microcontroller.Pin, buffer: WriteableBuffer, *, sample_rate: int = 500000) -> None:
44
- /// """Use the BufferedInput on the given pin. Fill the given buffer from ADC read values at the supplied
45
- /// sample_rate.
46
- ///
47
- /// :param ~microcontroller.Pin pin: the pin to read from"""
48
- /// :param ~circuitpython_typing.WriteableBuffer buffer: buffer: A buffer for samples
49
- /// :param ~int sample_rate: rate: The desired playback sample rate
50
- ///
51
- /// Usage::
52
- ///
53
- /// import board
54
- /// import adcbuffer
55
- /// import array
56
- ///
57
- /// length = 1000
58
- /// mybuffer = array.array("H", [0] * length)
59
- /// rate = 500000
60
- /// adcbuf = adcbuffer.BufferedInput(board.GP26, mybuffer, rate)
61
- /// adcbuf.readmultiple()
62
- /// adcbuf.deinit()
63
- /// for i in range(length):
64
- /// print(i, mybuffer[i])
65
- ///
66
- /// (TODO) The reference voltage varies by platform so use ``reference_voltage`` to read the configured setting.
67
- /// (TODO) Provide mechanism to read CPU Temperature
68
- /// """
69
- /// ...
70
- ///
40
+ //| class BufferedInput:
41
+ //| """Input analog voltage level to supplied buffer using DMA Capture"""
42
+ //|
43
+ //| def __init__(self, pin: microcontroller.Pin, buffer: WriteableBuffer, *, sample_rate: int = 500000) -> None:
44
+ //| """Use the BufferedInput on the given pin. Fill the given buffer from ADC read values at the supplied
45
+ //| sample_rate.
46
+ //|
47
+ //| :param ~microcontroller.Pin pin: the pin to read from"""
48
+ //| :param ~circuitpython_typing.WriteableBuffer buffer: buffer: A buffer for samples
49
+ //| :param ~int sample_rate: rate: The desired playback sample rate
50
+ //|
51
+ //| Usage::
52
+ //|
53
+ //| import board
54
+ //| import adcbuffer
55
+ //| import array
56
+ //|
57
+ //| length = 1000
58
+ //| mybuffer = array.array("H", [0] * length)
59
+ //| rate = 500000
60
+ //| adcbuf = adcbuffer.BufferedInput(board.GP26, mybuffer, rate)
61
+ //| adcbuf.readmultiple()
62
+ //| adcbuf.deinit()
63
+ //| for i in range(length):
64
+ //| print(i, mybuffer[i])
65
+ //|
66
+ //| (TODO) The reference voltage varies by platform so use ``reference_voltage`` to read the configured setting.
67
+ //| (TODO) Provide mechanism to read CPU Temperature
68
+ //| """
69
+ //| ...
70
+ //|
71
71
STATIC mp_obj_t adcbuffer_bufferedinput_make_new (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args ) {
72
72
enum { ARG_pin , ARG_buffer , ARG_sample_rate };
73
73
static const mp_arg_t allowed_args [] = {
@@ -116,10 +116,10 @@ STATIC mp_obj_t adcbuffer_bufferedinput_make_new(const mp_obj_type_t *type, size
116
116
return MP_OBJ_FROM_PTR (self );
117
117
}
118
118
119
- /// def deinit(self) -> None:
120
- /// """Turn off the BufferedInput and release the pin for other use."""
121
- /// ...
122
- ///
119
+ //| def deinit(self) -> None:
120
+ //| """Turn off the BufferedInput and release the pin for other use."""
121
+ //| ...
122
+ //|
123
123
STATIC mp_obj_t adcbuffer_bufferedinput_deinit (mp_obj_t self_in ) {
124
124
adcbuffer_bufferedinput_obj_t * self = MP_OBJ_TO_PTR (self_in );
125
125
common_hal_adcbuffer_bufferedinput_deinit (self );
@@ -132,46 +132,36 @@ STATIC void check_for_deinit(adcbuffer_bufferedinput_obj_t *self) {
132
132
raise_deinited_error ();
133
133
}
134
134
}
135
- /// def __enter__(self) -> BufferedInput:
136
- /// """No-op used by Context Managers."""
137
- /// ...
138
- ///
139
- /// Provided by context manager helper.
140
- ///
141
- /// def __exit__(self) -> None:
142
- /// """Automatically deinitializes the hardware when exiting a context. See
143
- /// :ref:`lifetime-and-contextmanagers` for more info."""
144
- /// ...
145
- ///
135
+
136
+ //| Provided by context manager helper.
137
+ //|
138
+ //| def __exit__(self) -> None:
139
+ //| """Automatically deinitializes the hardware when exiting a context. See
140
+ //| :ref:`lifetime-and-contextmanagers` for more info."""
141
+ //| ...
142
+ //|
146
143
STATIC mp_obj_t adcbuffer_bufferedinput___exit__ (size_t n_args , const mp_obj_t * args ) {
147
144
(void )n_args ;
148
145
common_hal_adcbuffer_bufferedinput_deinit (args [0 ]);
149
146
return mp_const_none ;
150
147
}
151
148
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (adcbuffer_bufferedinput___exit___obj , 4 , 4 , adcbuffer_bufferedinput___exit__ );
152
149
153
- /// value: int
154
- /// """The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only)
155
- ///
156
- /// Even if the underlying analog to digital converter (ADC) is lower
157
- /// resolution, the value is 16-bit."""
158
- ///
150
+ //| value: --> None
151
+ //| """Fills the supplied buffer with ADC values using DMA transfer.
152
+ //| If the buffer is 8-bit, then values are 8-bit shifted and error bit is off.
153
+ //| If buffer is 16-bit, then values are not shifted and error bit is present.
154
+ //| Number of transfers is always the number of samples which is the array
155
+ //| byte length divided by the byte_per_sample. """
156
+ //| ...
157
+ //|
159
158
STATIC mp_obj_t adcbuffer_bufferedinput_obj_readmultiple (mp_obj_t self_in ) {
160
159
adcbuffer_bufferedinput_obj_t * self = MP_OBJ_TO_PTR (self_in );
161
160
check_for_deinit (self );
162
161
return MP_OBJ_NEW_SMALL_INT (common_hal_adcbuffer_bufferedinput_readmultiple (self ));
163
162
}
164
163
MP_DEFINE_CONST_FUN_OBJ_1 (adcbuffer_bufferedinput_readmultiple_obj , adcbuffer_bufferedinput_obj_readmultiple );
165
164
166
- /// MP_PROPERTY_GETTER(adcbuffer_bufferedinput_value_obj,
167
- /// (mp_obj_t)&adcbuffer_bufferedinput_get_value_obj);
168
- ///
169
- /// reference_voltage: float
170
- /// """The maximum voltage measurable (also known as the reference voltage) as a
171
- /// `float` in Volts. Note the ADC value may not scale to the actual voltage linearly
172
- /// at ends of the analog range."""
173
- ///
174
-
175
165
STATIC const mp_rom_map_elem_t adcbuffer_bufferedinput_locals_dict_table [] = {
176
166
{ MP_ROM_QSTR (MP_QSTR_deinit ), MP_ROM_PTR (& adcbuffer_bufferedinput_deinit_obj ) },
177
167
{ MP_ROM_QSTR (MP_QSTR___enter__ ), MP_ROM_PTR (& default___enter___obj ) },
0 commit comments