Attempt to fix Build-Docs and Pre-Commit

This commit is contained in:
latkinso42 2022-09-06 18:58:57 -04:00
parent 5498b3ac91
commit 25078a24a3
2 changed files with 44 additions and 40 deletions

View File

@ -80,7 +80,7 @@ void common_hal_analogbufio_bufferedin_construct(analogbufio_bufferedin_obj_t *s
// If buffer is 16-bit, then values are not shifted and error bit is present.
// Number of transfers is always the number of samples which is the array
// byte length divided by the bytes_per_sample.
// self->bytes_per_sample == 1
uint dma_size = DMA_SIZE_8;
bool show_error_bit = false;

View File

@ -38,46 +38,47 @@
#include "shared-bindings/util.h"
//| class BufferedIn:
//| """Capture multiple analog voltage levels to the supplied buffer"""
//| """Capture multiple analog voltage levels to the supplied buffer
//|
//| Usage::
//|
//| import board
//| import analogbufio
//| import array
//|
//| length = 1000
//| mybuffer = array.array("H", 0x0000 for i in range(length))
//| rate = 500000
//| adcbuf = analogbufio.BufferedIn(board.GP26, mybuffer, rate)
//| adcbuf.read()
//| adcbuf.deinit()
//| for i in range(length):
//| print(i, mybuffer[i])
//|
//| (TODO) The reference voltage varies by platform so use
//| ``reference_voltage`` to read the configured setting.
//| (TODO) Provide mechanism to read CPU Temperature."""
//|
//| def __init__(self, pin: microcontroller.Pin, buffer: WriteableBuffer, *, sample_rate: int = 500000) -> None:
//| """Create a `BufferedIn` on the given pin. ADC values will be read
//| into the given buffer at the supplied sample_rate. Depending on the
//| buffer typecode, 'b', 'B', 'h', 'H', samples are 8-bit byte-arrays or
//| 16-bit half-words and are signed or unsigned.
//| The ADC most significant bits of the ADC are kept. Please see:
//| `https://docs.circuitpython.org/en/latest/docs/library/array.html`
//| The ADC most significant bits of the ADC are kept. (See
//| https://docs.circuitpython.org/en/latest/docs/library/array.html)
//|
//| :param ~microcontroller.Pin pin: the pin to read from
//| :param ~circuitpython_typing.WriteableBuffer buffer: buffer: A buffer for samples
//| :param ~int sample_rate: rate: sampling frequency, in samples per second
//|
//| Usage::
//|
//| import board
//| import analogbufio
//| import array
//|
//| length = 1000
//| mybuffer = array.array("H", 0x0000 for i in range(length))
//| rate = 500000
//| adcbuf = analogbufio.BufferedIn(board.GP26, mybuffer, rate)
//| adcbuf.read()
//| adcbuf.deinit()
//| for i in range(length):
//| print(i, mybuffer[i])
//|
//| (TODO) The reference voltage varies by platform so use
//| ``reference_voltage`` to read the configured setting.
//| (TODO) Provide mechanism to read CPU Temperature."""
//| ...
//| :param ~int sample_rate: rate: sampling frequency, in samples per second"""
//| ...
//|
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) {
enum { ARG_pin, ARG_buffer, ARG_sample_rate };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_pin, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_sample_rate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 500000} },
{ MP_QSTR_pin, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_sample_rate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 500000} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
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_
// Bytes Per Sample
if (bufinfo.typecode == 'h' || bufinfo.typecode == 'H') {
bytes_per_sample = 2;
bytes_per_sample = 2;
} else if (bufinfo.typecode != 'b' && bufinfo.typecode != 'B' && bufinfo.typecode != BYTEARRAY_TYPECODE) {
mp_raise_ValueError_varg(translate("%q must`` be a bytearray or array of type 'h', 'H', 'b' or 'B'"), MP_QSTR_buffer);
}
@ -109,13 +110,13 @@ STATIC mp_obj_t analogbufio_bufferedin_make_new(const mp_obj_type_t *type, size_
// Call local intereface in ports/common-hal/analogbufio
common_hal_analogbufio_bufferedin_construct(self,
pin,
((uint8_t *)bufinfo.buf),
bufinfo.len,
bytes_per_sample,
signed_samples,
sample_rate
);
pin,
((uint8_t *)bufinfo.buf),
bufinfo.len,
bytes_per_sample,
signed_samples,
sample_rate
);
return MP_OBJ_FROM_PTR(self);
}
@ -133,12 +134,15 @@ MP_DEFINE_CONST_FUN_OBJ_1(analogbufio_bufferedin_deinit_obj, analogbufio_buffere
STATIC void check_for_deinit(analogbufio_bufferedin_obj_t *self) {
if (common_hal_analogbufio_bufferedin_deinited(self)) {
raise_deinited_error();
raise_deinited_error();
}
}
//| Provided by context manager helper.
//| def __enter__(self) -> AnalogIn:
//| """No-op used by Context Managers."""
//| ...
//|
// Provided by context manager helper.
//| def __exit__(self) -> None:
//| """Automatically deinitializes the hardware when exiting a context. See
//| :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
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogbufio_bufferedin___exit___obj, 4, 4, analogbufio_bufferedin___exit__);
//|
//| def read(self) -> None:
//| """Fills the provided buffer with ADC voltage values."""
//| ...
//|
STATIC mp_obj_t analogbufio_bufferedin_obj_read(mp_obj_t self_in) {
analogbufio_bufferedin_obj_t *self = MP_OBJ_TO_PTR(self_in);