Update countio to python stub docs
This commit is contained in:
parent
7546d47f77
commit
3ffa5604fc
@ -346,13 +346,11 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(busio_uart_reset_input_buffer_obj, busio_uart_o
|
|||||||
//| class Parity:
|
//| class Parity:
|
||||||
//| """Enum-like class to define the parity used to verify correct data transfer."""
|
//| """Enum-like class to define the parity used to verify correct data transfer."""
|
||||||
//|
|
//|
|
||||||
//| def __init__(self, ):
|
//| ODD: Any = ...
|
||||||
//| ODD: Any = ...
|
//| """Total number of ones should be odd."""
|
||||||
//| """Total number of ones should be odd."""
|
|
||||||
//|
|
//|
|
||||||
//| EVEN: Any = ...
|
//| EVEN: Any = ...
|
||||||
//| """Total number of ones should be even."""
|
//| """Total number of ones should be even."""
|
||||||
//| ...
|
|
||||||
//|
|
//|
|
||||||
const mp_obj_type_t busio_uart_parity_type;
|
const mp_obj_type_t busio_uart_parity_type;
|
||||||
|
|
||||||
|
@ -9,45 +9,41 @@
|
|||||||
#include "shared-bindings/countio/Counter.h"
|
#include "shared-bindings/countio/Counter.h"
|
||||||
#include "shared-bindings/util.h"
|
#include "shared-bindings/util.h"
|
||||||
|
|
||||||
//| .. currentmodule:: countio
|
//| class Counter:
|
||||||
|
//| """Counter will keep track of the number of falling edge transistions (pulses) on a
|
||||||
|
//| given pin"""
|
||||||
//|
|
//|
|
||||||
//| :class:`Counter` -- Track the count of falling edge transistions (pulses) on a given pin
|
//| def __init__(self, pin_a):
|
||||||
//| ========================================================================================
|
//| """Create a Counter object associated with the given pin. It tracks the number of
|
||||||
|
//| falling pulses relative when the object is constructed.
|
||||||
//|
|
//|
|
||||||
//| Counter will keep track of the number of falling edge transistions (pulses) on a given pin
|
//| :param ~microcontroller.Pin pin_a: Pin to read pulses from.
|
||||||
//|
|
//|
|
||||||
//| .. class:: Counter(pin_a)
|
|
||||||
//|
|
//|
|
||||||
//| Create a Counter object associated with the given pin. It tracks the number of
|
//| For example::
|
||||||
//| falling pulses relative when the object is constructed.
|
|
||||||
//|
|
//|
|
||||||
//| :param ~microcontroller.Pin pin_a: Pin to read pulses from.
|
//| import countio
|
||||||
//|
|
//| import time
|
||||||
|
//| from board import *
|
||||||
//|
|
//|
|
||||||
//| For example::
|
//| pin_counter = countio.Counter(board.D1)
|
||||||
//|
|
//| #reset the count after 100 counts
|
||||||
//| import countio
|
//| while True:
|
||||||
//| import time
|
//| if pin_counter.count == 100:
|
||||||
//| from board import *
|
//| pin_counter.reset()
|
||||||
//|
|
//| print(pin_counter.count)"""
|
||||||
//| pin_counter = countio.Counter(board.D1)
|
|
||||||
//| #reset the count after 100 counts
|
|
||||||
//| while True:
|
|
||||||
//| if pin_counter.count == 100:
|
|
||||||
//| pin_counter.reset()
|
|
||||||
//| print(pin_counter.count)
|
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
||||||
enum { ARG_pin_a };
|
enum { ARG_pin_a };
|
||||||
static const mp_arg_t allowed_args[] = {
|
static const mp_arg_t allowed_args[] = {
|
||||||
{ MP_QSTR_pin_a, MP_ARG_REQUIRED | MP_ARG_OBJ }
|
{ MP_QSTR_pin_a, MP_ARG_REQUIRED | MP_ARG_OBJ }
|
||||||
|
|
||||||
};
|
};
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||||
|
|
||||||
const mcu_pin_obj_t* pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj);
|
const mcu_pin_obj_t* pin_a = validate_obj_is_free_pin(args[ARG_pin_a].u_obj);
|
||||||
|
|
||||||
|
|
||||||
countio_counter_obj_t *self = m_new_obj(countio_counter_obj_t);
|
countio_counter_obj_t *self = m_new_obj(countio_counter_obj_t);
|
||||||
self->base.type = &countio_counter_type;
|
self->base.type = &countio_counter_type;
|
||||||
@ -57,9 +53,8 @@ STATIC mp_obj_t countio_counter_make_new(const mp_obj_type_t *type, size_t n_arg
|
|||||||
return MP_OBJ_FROM_PTR(self);
|
return MP_OBJ_FROM_PTR(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
//| .. method:: deinit()
|
//| def deinit(self):
|
||||||
//|
|
//| """Deinitializes the Counter and releases any hardware resources for reuse."""
|
||||||
//| Deinitializes the Counter and releases any hardware resources for reuse.
|
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t countio_counter_deinit(mp_obj_t self_in) {
|
STATIC mp_obj_t countio_counter_deinit(mp_obj_t self_in) {
|
||||||
countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
@ -74,16 +69,14 @@ STATIC void check_for_deinit(countio_counter_obj_t *self) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//| .. method:: __enter__()
|
//| def __enter__(self):
|
||||||
//|
|
//| """No-op used by Context Managers."""
|
||||||
//| No-op used by Context Managers.
|
|
||||||
//|
|
//|
|
||||||
// Provided by context manager helper.
|
// Provided by context manager helper.
|
||||||
|
|
||||||
//| .. method:: __exit__()
|
//| def __exit__(self):
|
||||||
//|
|
//| """Automatically deinitializes the hardware when exiting a context. See
|
||||||
//| Automatically deinitializes the hardware when exiting a context. See
|
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||||
//| :ref:`lifetime-and-contextmanagers` for more info.
|
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t countio_counter_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
STATIC mp_obj_t countio_counter_obj___exit__(size_t n_args, const mp_obj_t *args) {
|
||||||
(void)n_args;
|
(void)n_args;
|
||||||
@ -93,10 +86,8 @@ STATIC mp_obj_t countio_counter_obj___exit__(size_t n_args, const mp_obj_t *args
|
|||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(countio_counter___exit___obj, 4, 4, countio_counter_obj___exit__);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(countio_counter___exit___obj, 4, 4, countio_counter_obj___exit__);
|
||||||
|
|
||||||
|
|
||||||
//| .. attribute:: count
|
//| count: int = ...
|
||||||
//|
|
//| """The current count in terms of pulses."""
|
||||||
//| The current count in terms of pulses.
|
|
||||||
//|
|
|
||||||
//|
|
//|
|
||||||
STATIC mp_obj_t countio_counter_obj_get_count(mp_obj_t self_in) {
|
STATIC mp_obj_t countio_counter_obj_get_count(mp_obj_t self_in) {
|
||||||
countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
@ -122,6 +113,9 @@ const mp_obj_property_t countio_counter_count_obj = {
|
|||||||
(mp_obj_t)&mp_const_none_obj},
|
(mp_obj_t)&mp_const_none_obj},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//| def reset(self):
|
||||||
|
//| """Resets the count back to 0."""
|
||||||
|
//|
|
||||||
STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in){
|
STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in){
|
||||||
countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
countio_counter_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
check_for_deinit(self);
|
check_for_deinit(self);
|
||||||
@ -129,7 +123,7 @@ STATIC mp_obj_t countio_counter_reset(mp_obj_t self_in){
|
|||||||
common_hal_countio_counter_reset(self);
|
common_hal_countio_counter_reset(self);
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_reset_obj, countio_counter_reset);
|
MP_DEFINE_CONST_FUN_OBJ_1(countio_counter_reset_obj, countio_counter_reset);
|
||||||
|
|
||||||
|
@ -8,22 +8,10 @@
|
|||||||
#include "shared-bindings/countio/__init__.h"
|
#include "shared-bindings/countio/__init__.h"
|
||||||
#include "shared-bindings/countio/Counter.h"
|
#include "shared-bindings/countio/Counter.h"
|
||||||
|
|
||||||
//| :mod:`countio` --- Support for edge counting
|
//| """Support for edge counting
|
||||||
//| ========================================================
|
|
||||||
//|
|
|
||||||
//| .. module:: countio
|
|
||||||
//| :synopsis: Support for edge counting
|
|
||||||
//| :platform: SAMD
|
|
||||||
//|
|
//|
|
||||||
//| The `countio` module contains logic to read and count edge transistions
|
//| The `countio` module contains logic to read and count edge transistions
|
||||||
//|
|
//|
|
||||||
//| Libraries
|
|
||||||
//|
|
|
||||||
//| .. toctree::
|
|
||||||
//| :maxdepth: 3
|
|
||||||
//|
|
|
||||||
//| Counter
|
|
||||||
//|
|
|
||||||
|
|
||||||
//| .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the
|
//| .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the
|
||||||
//| :ref:`module-support-matrix` for more info.
|
//| :ref:`module-support-matrix` for more info.
|
||||||
@ -32,7 +20,7 @@
|
|||||||
//| All classes change hardware state and should be deinitialized when they
|
//| All classes change hardware state and should be deinitialized when they
|
||||||
//| are no longer needed if the program continues after use. To do so, either
|
//| are no longer needed if the program continues after use. To do so, either
|
||||||
//| call :py:meth:`!deinit` or use a context manager. See
|
//| call :py:meth:`!deinit` or use a context manager. See
|
||||||
//| :ref:`lifetime-and-contextmanagers` for more info.
|
//| :ref:`lifetime-and-contextmanagers` for more info."""
|
||||||
//|
|
//|
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t countio_module_globals_table[] = {
|
STATIC const mp_rom_map_elem_t countio_module_globals_table[] = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user