summaryrefslogtreecommitdiff
path: root/shared-bindings
diff options
context:
space:
mode:
Diffstat (limited to 'shared-bindings')
-rw-r--r--shared-bindings/time/__init__.c103
-rw-r--r--shared-bindings/touchio/TouchIn.c68
-rw-r--r--shared-bindings/touchio/__init__.c4
-rw-r--r--shared-bindings/uheap/__init__.c12
4 files changed, 93 insertions, 94 deletions
diff --git a/shared-bindings/time/__init__.c b/shared-bindings/time/__init__.c
index 8d7f2f3fd..36eaa27f6 100644
--- a/shared-bindings/time/__init__.c
+++ b/shared-bindings/time/__init__.c
@@ -36,7 +36,7 @@
#include "shared-bindings/time/__init__.h"
#include "supervisor/shared/translate.h"
-//| :mod:`time` --- time and timing related functions
+//| """:mod:`time` --- time and timing related functions
//| ========================================================
//|
//| .. module:: time
@@ -45,15 +45,15 @@
//|
//| The `time` module is a strict subset of the CPython `cpython:time` module. So, code
//| written in MicroPython will work in CPython but not necessarily the other
-//| way around.
+//| way around."""
//|
-//| .. function:: monotonic()
+//| def monotonic() -> Any:
+//| """Returns an always increasing value of time with an unknown reference
+//| point. Only use it to compare against other values from `monotonic`.
//|
-//| Returns an always increasing value of time with an unknown reference
-//| point. Only use it to compare against other values from `monotonic`.
-//|
-//| :return: the current monotonic time
-//| :rtype: float
+//| :return: the current monotonic time
+//| :rtype: float"""
+//| ...
//|
STATIC mp_obj_t time_monotonic(void) {
uint64_t time64 = common_hal_time_monotonic();
@@ -62,11 +62,11 @@ STATIC mp_obj_t time_monotonic(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_obj, time_monotonic);
-//| .. function:: sleep(seconds)
-//|
-//| Sleep for a given number of seconds.
+//| def sleep(seconds: float) -> Any:
+//| """Sleep for a given number of seconds.
//|
-//| :param float seconds: the time to sleep in fractional seconds
+//| :param float seconds: the time to sleep in fractional seconds"""
+//| ...
//|
STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
#if MICROPY_PY_BUILTINS_FLOAT
@@ -97,21 +97,22 @@ mp_obj_t struct_time_make_new(const mp_obj_type_t *type, size_t n_args, const mp
return namedtuple_make_new(type, 9, tuple->items, NULL);
}
-//| .. class:: struct_time(time_tuple)
+//| class struct_time:
+//| def __init__(self, time_tuple: Any):
+//| """Structure used to capture a date and time. Note that it takes a tuple!
//|
-//| Structure used to capture a date and time. Note that it takes a tuple!
+//| :param tuple time_tuple: Tuple of time info: ``(tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst)``
//|
-//| :param tuple time_tuple: Tuple of time info: ``(tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, tm_isdst)``
-//|
-//| * ``tm_year``: the year, 2017 for example
-//| * ``tm_month``: the month, range [1, 12]
-//| * ``tm_mday``: the day of the month, range [1, 31]
-//| * ``tm_hour``: the hour, range [0, 23]
-//| * ``tm_minute``: the minute, range [0, 59]
-//| * ``tm_sec``: the second, range [0, 61]
-//| * ``tm_wday``: the day of the week, range [0, 6], Monday is 0
-//| * ``tm_yday``: the day of the year, range [1, 366], -1 indicates not known
-//| * ``tm_isdst``: 1 when in daylight savings, 0 when not, -1 if unknown.
+//| * ``tm_year``: the year, 2017 for example
+//| * ``tm_month``: the month, range [1, 12]
+//| * ``tm_mday``: the day of the month, range [1, 31]
+//| * ``tm_hour``: the hour, range [0, 23]
+//| * ``tm_minute``: the minute, range [0, 59]
+//| * ``tm_sec``: the second, range [0, 61]
+//| * ``tm_wday``: the day of the week, range [0, 6], Monday is 0
+//| * ``tm_yday``: the day of the year, range [1, 366], -1 indicates not known
+//| * ``tm_isdst``: 1 when in daylight savings, 0 when not, -1 if unknown."""
+//| ...
//|
const mp_obj_namedtuple_type_t struct_time_type_obj = {
.base = {
@@ -194,12 +195,12 @@ mp_obj_t MP_WEAK rtc_get_time_source_time(void) {
mp_raise_RuntimeError(translate("RTC is not supported on this board"));
}
-//| .. function:: time()
-//|
-//| Return the current time in seconds since since Jan 1, 1970.
+//| def time() -> Any:
+//| """Return the current time in seconds since since Jan 1, 1970.
//|
-//| :return: the current time
-//| :rtype: int
+//| :return: the current time
+//| :rtype: int"""
+//| ...
//|
STATIC mp_obj_t time_time(void) {
timeutils_struct_time_t tm;
@@ -210,12 +211,12 @@ STATIC mp_obj_t time_time(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time);
-//| .. function:: monotonic_ns()
+//| def monotonic_ns() -> Any:
+//| """Return the time of the specified clock clk_id in nanoseconds.
//|
-//| Return the time of the specified clock clk_id in nanoseconds.
-//|
-//| :return: the current time
-//| :rtype: int
+//| :return: the current time
+//| :rtype: int"""
+//| ...
//|
STATIC mp_obj_t time_monotonic_ns(void) {
uint64_t time64 = common_hal_time_monotonic_ns();
@@ -223,15 +224,15 @@ STATIC mp_obj_t time_monotonic_ns(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(time_monotonic_ns_obj, time_monotonic_ns);
-//| .. function:: localtime([secs])
-//|
-//| Convert a time expressed in seconds since Jan 1, 1970 to a struct_time in
-//| local time. If secs is not provided or None, the current time as returned
-//| by time() is used.
-//| The earliest date for which it can generate a time is Jan 1, 2000.
+//| def localtime(secs: Any) -> Any:
+//| """Convert a time expressed in seconds since Jan 1, 1970 to a struct_time in
+//| local time. If secs is not provided or None, the current time as returned
+//| by time() is used.
+//| The earliest date for which it can generate a time is Jan 1, 2000.
//|
-//| :return: the current time
-//| :rtype: time.struct_time
+//| :return: the current time
+//| :rtype: time.struct_time"""
+//| ...
//|
STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
if (n_args == 0 || args[0] == mp_const_none) {
@@ -256,15 +257,15 @@ STATIC mp_obj_t time_localtime(size_t n_args, const mp_obj_t *args) {
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(time_localtime_obj, 0, 1, time_localtime);
-//| .. function:: mktime(t)
-//|
-//| This is the inverse function of localtime(). Its argument is the
-//| struct_time or full 9-tuple (since the dst flag is needed; use -1 as the
-//| dst flag if it is unknown) which expresses the time in local time, not UTC.
-//| The earliest date for which it can generate a time is Jan 1, 2000.
+//| def mktime(t: Any) -> Any:
+//| """This is the inverse function of localtime(). Its argument is the
+//| struct_time or full 9-tuple (since the dst flag is needed; use -1 as the
+//| dst flag if it is unknown) which expresses the time in local time, not UTC.
+//| The earliest date for which it can generate a time is Jan 1, 2000.
//|
-//| :return: seconds
-//| :rtype: int
+//| :return: seconds
+//| :rtype: int"""
+//| ...
//|
STATIC mp_obj_t time_mktime(mp_obj_t t) {
mp_obj_t *elem;
diff --git a/shared-bindings/touchio/TouchIn.c b/shared-bindings/touchio/TouchIn.c
index db53ec1bc..6d59a1744 100644
--- a/shared-bindings/touchio/TouchIn.c
+++ b/shared-bindings/touchio/TouchIn.c
@@ -38,27 +38,28 @@
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
-//| .. currentmodule:: touchio
+//| class TouchIn:
+//| """.. currentmodule:: touchio
//|
-//| :class:`TouchIn` -- Read the state of a capacitive touch sensor
-//| ===================================================================
+//| :class:`TouchIn` -- Read the state of a capacitive touch sensor
+//| ===================================================================
//|
-//| Usage::
+//| Usage::
//|
-//| import touchio
-//| from board import *
+//| import touchio
+//| from board import *
//|
-//| touch = touchio.TouchIn(A1)
-//| while True:
-//| if touch.value:
-//| print("touched!")
+//| touch = touchio.TouchIn(A1)
+//| while True:
+//| if touch.value:
+//| print("touched!")"""
//|
-//| .. class:: TouchIn(pin)
+//| def __init__(self, pin: microcontroller.Pin):
+//| """Use the TouchIn on the given pin.
//|
-//| Use the TouchIn on the given pin.
-//|
-//| :param ~microcontroller.Pin pin: the pin to read from
+//| :param ~microcontroller.Pin pin: the pin to read from"""
+//| ...
//|
STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type,
mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
@@ -75,9 +76,9 @@ STATIC mp_obj_t touchio_touchin_make_new(const mp_obj_type_t *type,
return (mp_obj_t) self;
}
-//| .. method:: deinit()
-//|
-//| Deinitialises the TouchIn and releases any hardware resources for reuse.
+//| def deinit(self, ) -> Any:
+//| """Deinitialises the TouchIn and releases any hardware resources for reuse."""
+//| ...
//|
STATIC mp_obj_t touchio_touchin_deinit(mp_obj_t self_in) {
touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -92,16 +93,16 @@ STATIC void check_for_deinit(touchio_touchin_obj_t *self) {
}
}
-//| .. method:: __enter__()
-//|
-//| No-op used by Context Managers.
+//| def __enter__(self, ) -> Any:
+//| """No-op used by Context Managers."""
+//| ...
//|
// Provided by context manager helper.
-//| .. method:: __exit__()
-//|
-//| Automatically deinitializes the hardware when exiting a context. See
-//| :ref:`lifetime-and-contextmanagers` for more info.
+//| def __exit__(self, ) -> Any:
+//| """Automatically deinitializes the hardware when exiting a context. See
+//| :ref:`lifetime-and-contextmanagers` for more info."""
+//| ...
//|
STATIC mp_obj_t touchio_touchin_obj___exit__(size_t n_args, const mp_obj_t *args) {
(void)n_args;
@@ -110,11 +111,10 @@ STATIC mp_obj_t touchio_touchin_obj___exit__(size_t n_args, const mp_obj_t *args
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(touchio_touchin___exit___obj, 4, 4, touchio_touchin_obj___exit__);
-//| .. attribute:: value
+//| value: Any = ...
+//| """Whether the touch pad is being touched or not. (read-only)
//|
-//| Whether the touch pad is being touched or not. (read-only)
-//|
-//| True when `raw_value` > `threshold`.
+//| True when `raw_value` > `threshold`."""
//|
STATIC mp_obj_t touchio_touchin_obj_get_value(mp_obj_t self_in) {
touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -131,9 +131,8 @@ const mp_obj_property_t touchio_touchin_value_obj = {
};
-//| .. attribute:: raw_value
-//|
-//| The raw touch measurement as an `int`. (read-only)
+//| raw_value: Any = ...
+//| """The raw touch measurement as an `int`. (read-only)"""
//|
STATIC mp_obj_t touchio_touchin_obj_get_raw_value(mp_obj_t self_in) {
touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -151,14 +150,13 @@ const mp_obj_property_t touchio_touchin_raw_value_obj = {
};
-//| .. attribute:: threshold
-//|
-//| Minimum `raw_value` needed to detect a touch (and for `value` to be `True`).
+//| threshold: Any = ...
+//| """Minimum `raw_value` needed to detect a touch (and for `value` to be `True`).
//|
//| When the **TouchIn** object is created, an initial `raw_value` is read from the pin,
//| and then `threshold` is set to be 100 + that value.
//|
-//| You can adjust `threshold` to make the pin more or less sensitive.
+//| You can adjust `threshold` to make the pin more or less sensitive."""
//|
STATIC mp_obj_t touchio_touchin_obj_get_threshold(mp_obj_t self_in) {
touchio_touchin_obj_t *self = MP_OBJ_TO_PTR(self_in);
diff --git a/shared-bindings/touchio/__init__.c b/shared-bindings/touchio/__init__.c
index 6adbe09cf..96367f082 100644
--- a/shared-bindings/touchio/__init__.c
+++ b/shared-bindings/touchio/__init__.c
@@ -35,7 +35,7 @@
#include "py/runtime.h"
-//| :mod:`touchio` --- Touch related IO
+//| """:mod:`touchio` --- Touch related IO
//| =================================================
//|
//| .. module:: touchio
@@ -66,7 +66,7 @@
//| print(touch_pin.value)
//|
//| This example will initialize the the device, and print the
-//| :py:data:`~touchio.TouchIn.value`.
+//| :py:data:`~touchio.TouchIn.value`."""
//|
STATIC const mp_rom_map_elem_t touchio_module_globals_table[] = {
diff --git a/shared-bindings/uheap/__init__.c b/shared-bindings/uheap/__init__.c
index 0d699cd28..f1be30424 100644
--- a/shared-bindings/uheap/__init__.c
+++ b/shared-bindings/uheap/__init__.c
@@ -31,17 +31,17 @@
#include "shared-bindings/uheap/__init__.h"
-//| :mod:`uheap` --- Heap size analysis
+//| """:mod:`uheap` --- Heap size analysis
//| ================================================================
//|
//| .. module:: uheap
-//| :synopsis: Heap size analysis
+//| :synopsis: Heap size analysis"""
//|
-//| .. function:: info(object)
-//|
-//| Prints memory debugging info for the given object and returns the
-//| estimated size.
+//| def info(object: Any) -> Any:
+//| """Prints memory debugging info for the given object and returns the
+//| estimated size."""
+//| ...
//|
STATIC mp_obj_t uheap_info(mp_obj_t obj) {
uint32_t size = shared_module_uheap_info(obj);