Update countio to python stub docs

This commit is contained in:
Scott Shawcroft 2020-05-13 08:36:16 -07:00
parent 7546d47f77
commit 3ffa5604fc
No known key found for this signature in database
GPG Key ID: 9349BC7E64B1921E
3 changed files with 38 additions and 58 deletions

View File

@ -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;

View File

@ -9,16 +9,12 @@
#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
//|
//| Counter will keep track of the number of falling edge transistions (pulses) on a given pin
//|
//| .. class:: Counter(pin_a)
//|
//| Create a Counter object associated with the given pin. It tracks the number of
//| falling pulses relative when the object is constructed. //| falling pulses relative when the object is constructed.
//| //|
//| :param ~microcontroller.Pin pin_a: Pin to read pulses from. //| :param ~microcontroller.Pin pin_a: Pin to read pulses from.
@ -35,7 +31,7 @@
//| while True: //| while True:
//| if pin_counter.count == 100: //| if pin_counter.count == 100:
//| pin_counter.reset() //| pin_counter.reset()
//| print(pin_counter.count) //| 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 };
@ -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);

View File

@ -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[] = {