Skip to content

Commit 25078a2

Browse files
committed
Attempt to fix Build-Docs and Pre-Commit
1 parent 5498b3a commit 25078a2

File tree

2 files changed

+44
-40
lines changed

2 files changed

+44
-40
lines changed

ports/raspberrypi/common-hal/analogbufio/BufferedIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void common_hal_analogbufio_bufferedin_construct(analogbufio_bufferedin_obj_t *s
8080
// If buffer is 16-bit, then values are not shifted and error bit is present.
8181
// Number of transfers is always the number of samples which is the array
8282
// byte length divided by the bytes_per_sample.
83-
83+
8484
// self->bytes_per_sample == 1
8585
uint dma_size = DMA_SIZE_8;
8686
bool show_error_bit = false;

shared-bindings/analogbufio/BufferedIn.c

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -38,46 +38,47 @@
3838
#include "shared-bindings/util.h"
3939

4040
//| class BufferedIn:
41-
//| """Capture multiple analog voltage levels to the supplied buffer"""
41+
//| """Capture multiple analog voltage levels to the supplied buffer
4242
//|
43+
//| Usage::
44+
//|
45+
//| import board
46+
//| import analogbufio
47+
//| import array
48+
//|
49+
//| length = 1000
50+
//| mybuffer = array.array("H", 0x0000 for i in range(length))
51+
//| rate = 500000
52+
//| adcbuf = analogbufio.BufferedIn(board.GP26, mybuffer, rate)
53+
//| adcbuf.read()
54+
//| adcbuf.deinit()
55+
//| for i in range(length):
56+
//| print(i, mybuffer[i])
57+
//|
58+
//| (TODO) The reference voltage varies by platform so use
59+
//| ``reference_voltage`` to read the configured setting.
60+
//| (TODO) Provide mechanism to read CPU Temperature."""
61+
//|
62+
4363
//| def __init__(self, pin: microcontroller.Pin, buffer: WriteableBuffer, *, sample_rate: int = 500000) -> None:
4464
//| """Create a `BufferedIn` on the given pin. ADC values will be read
4565
//| into the given buffer at the supplied sample_rate. Depending on the
4666
//| buffer typecode, 'b', 'B', 'h', 'H', samples are 8-bit byte-arrays or
4767
//| 16-bit half-words and are signed or unsigned.
48-
//| The ADC most significant bits of the ADC are kept. Please see:
49-
//| `https://docs.circuitpython.org/en/latest/docs/library/array.html`
68+
//| The ADC most significant bits of the ADC are kept. (See
69+
//| https://docs.circuitpython.org/en/latest/docs/library/array.html)
5070
//|
5171
//| :param ~microcontroller.Pin pin: the pin to read from
5272
//| :param ~circuitpython_typing.WriteableBuffer buffer: buffer: A buffer for samples
53-
//| :param ~int sample_rate: rate: sampling frequency, in samples per second
54-
//|
55-
//| Usage::
56-
//|
57-
//| import board
58-
//| import analogbufio
59-
//| import array
60-
//|
61-
//| length = 1000
62-
//| mybuffer = array.array("H", 0x0000 for i in range(length))
63-
//| rate = 500000
64-
//| adcbuf = analogbufio.BufferedIn(board.GP26, mybuffer, rate)
65-
//| adcbuf.read()
66-
//| adcbuf.deinit()
67-
//| for i in range(length):
68-
//| print(i, mybuffer[i])
69-
//|
70-
//| (TODO) The reference voltage varies by platform so use
71-
//| ``reference_voltage`` to read the configured setting.
72-
//| (TODO) Provide mechanism to read CPU Temperature."""
73-
//| ...
73+
//| :param ~int sample_rate: rate: sampling frequency, in samples per second"""
74+
//| ...
7475
//|
7576
STATIC mp_obj_t analogbufio_bufferedin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
7677
enum { ARG_pin, ARG_buffer, ARG_sample_rate };
7778
static const mp_arg_t allowed_args[] = {
78-
{ MP_QSTR_pin, MP_ARG_OBJ | MP_ARG_REQUIRED },
79-
{ MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED },
80-
{ MP_QSTR_sample_rate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 500000} },
79+
{ MP_QSTR_pin, MP_ARG_OBJ | MP_ARG_REQUIRED },
80+
{ MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED },
81+
{ MP_QSTR_sample_rate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 500000} },
8182
};
8283
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
8384
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
@@ -95,7 +96,7 @@ STATIC mp_obj_t analogbufio_bufferedin_make_new(const mp_obj_type_t *type, size_
9596

9697
// Bytes Per Sample
9798
if (bufinfo.typecode == 'h' || bufinfo.typecode == 'H') {
98-
bytes_per_sample = 2;
99+
bytes_per_sample = 2;
99100
} else if (bufinfo.typecode != 'b' && bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) {
100101
mp_raise_ValueError_varg(translate("%q must`` be a bytearray or array of type 'h', 'H', 'b' or 'B'"), MP_QSTR_buffer);
101102
}
@@ -109,13 +110,13 @@ STATIC mp_obj_t analogbufio_bufferedin_make_new(const mp_obj_type_t *type, size_
109110

110111
// Call local intereface in ports/common-hal/analogbufio
111112
common_hal_analogbufio_bufferedin_construct(self,
112-
pin,
113-
((uint8_t *)bufinfo.buf),
114-
bufinfo.len,
115-
bytes_per_sample,
116-
signed_samples,
117-
sample_rate
118-
);
113+
pin,
114+
((uint8_t *)bufinfo.buf),
115+
bufinfo.len,
116+
bytes_per_sample,
117+
signed_samples,
118+
sample_rate
119+
);
119120

120121
return MP_OBJ_FROM_PTR(self);
121122
}
@@ -133,12 +134,15 @@ MP_DEFINE_CONST_FUN_OBJ_1(analogbufio_bufferedin_deinit_obj, analogbufio_buffere
133134

134135
STATIC void check_for_deinit(analogbufio_bufferedin_obj_t *self) {
135136
if (common_hal_analogbufio_bufferedin_deinited(self)) {
136-
raise_deinited_error();
137+
raise_deinited_error();
137138
}
138139
}
139-
140-
//| Provided by context manager helper.
140+
//| def __enter__(self) -> AnalogIn:
141+
//| """No-op used by Context Managers."""
142+
//| ...
141143
//|
144+
// Provided by context manager helper.
145+
142146
//| def __exit__(self) -> None:
143147
//| """Automatically deinitializes the hardware when exiting a context. See
144148
//| :ref:`lifetime-and-contextmanagers` for more info."""
@@ -151,9 +155,9 @@ STATIC mp_obj_t analogbufio_bufferedin___exit__(size_t n_args, const mp_obj_t *a
151155
}
152156
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogbufio_bufferedin___exit___obj, 4, 4, analogbufio_bufferedin___exit__);
153157

154-
//|
155158
//| def read(self) -> None:
156159
//| """Fills the provided buffer with ADC voltage values."""
160+
//| ...
157161
//|
158162
STATIC mp_obj_t analogbufio_bufferedin_obj_read(mp_obj_t self_in) {
159163
analogbufio_bufferedin_obj_t *self = MP_OBJ_TO_PTR(self_in);

0 commit comments

Comments
 (0)