summaryrefslogtreecommitdiff
path: root/shared-bindings/_pixelbuf
diff options
context:
space:
mode:
authordherrada <dylan.herrada@gmail.com>2020-05-08 16:03:39 -0400
committerdherrada <dylan.herrada@gmail.com>2020-05-08 16:03:39 -0400
commit09530e5dc34d6fbcbf5fa85a1f7df9d47d8c8329 (patch)
tree25b48c888f72ad9a66a05abc864ee66490e9fd8d /shared-bindings/_pixelbuf
parentd750096befe2e6d23b1d0d4796306382cfbbb198 (diff)
Did os, _pixelbuf, _pew
Diffstat (limited to 'shared-bindings/_pixelbuf')
-rw-r--r--shared-bindings/_pixelbuf/PixelBuf.c94
-rw-r--r--shared-bindings/_pixelbuf/__init__.c14
2 files changed, 52 insertions, 56 deletions
diff --git a/shared-bindings/_pixelbuf/PixelBuf.c b/shared-bindings/_pixelbuf/PixelBuf.c
index 61b4c9ae0..1c0888802 100644
--- a/shared-bindings/_pixelbuf/PixelBuf.c
+++ b/shared-bindings/_pixelbuf/PixelBuf.c
@@ -44,31 +44,32 @@ extern const int32_t colorwheel(float pos);
static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t* parsed);
-//| .. currentmodule:: pixelbuf
+//| class PixelBuf:
+//| """.. currentmodule:: pixelbuf
//|
-//| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices
-//| ===========================================================================
+//| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices
+//| ===========================================================================
//|
-//| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction.
+//| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction."""
//|
-//| .. class:: PixelBuf(size, *, byteorder="BGR", brightness=0, auto_write=False, header=b"", trailer=b"")
+//| def __init__(self, size: int, *, byteorder: str = "BGR", brightness: float = 0, auto_write: bool = False, header: bytes = b"", trailer: bytes = b""):
+//| """Create a PixelBuf object of the specified size, byteorder, and bits per pixel.
//|
-//| Create a PixelBuf object of the specified size, byteorder, and bits per pixel.
+//| When brightness is less than 1.0, a second buffer will be used to store the color values
+//| before they are adjusted for brightness.
//|
-//| When brightness is less than 1.0, a second buffer will be used to store the color values
-//| before they are adjusted for brightness.
+//| When ``P`` (pwm duration) is present as the 4th character of the byteorder
+//| string, the 4th value in the tuple/list for a pixel is the individual pixel
+//| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the
+//| output buffer (``buf``).
//|
-//| When ``P`` (pwm duration) is present as the 4th character of the byteorder
-//| string, the 4th value in the tuple/list for a pixel is the individual pixel
-//| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the
-//| output buffer (``buf``).
-//|
-//| :param ~int size: Number of pixelsx
-//| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR")
-//| :param ~float brightness: Brightness (0 to 1.0, default 1.0)
-//| :param ~bool auto_write: Whether to automatically write pixels (Default False)
-//| :param bytes header: Sequence of bytes to always send before pixel values.
-//| :param bytes trailer: Sequence of bytes to always send after pixel values.
+//| :param ~int size: Number of pixelsx
+//| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR")
+//| :param ~float brightness: Brightness (0 to 1.0, default 1.0)
+//| :param ~bool auto_write: Whether to automatically write pixels (Default False)
+//| :param bytes header: Sequence of bytes to always send before pixel values.
+//| :param bytes trailer: Sequence of bytes to always send after pixel values."""
+//| ...
//|
STATIC mp_obj_t pixelbuf_pixelbuf_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, kw_args, 1, MP_OBJ_FUN_ARGS_MAX, true);
@@ -156,9 +157,8 @@ static void parse_byteorder(mp_obj_t byteorder_obj, pixelbuf_byteorder_details_t
}
}
-//| .. attribute:: bpp
-//|
-//| The number of bytes per pixel in the buffer (read-only)
+//| bpp: Any = ...
+//| """The number of bytes per pixel in the buffer (read-only)"""
//|
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_bpp(mp_obj_t self_in) {
return MP_OBJ_NEW_SMALL_INT(common_hal__pixelbuf_pixelbuf_get_bpp(self_in));
@@ -173,12 +173,11 @@ const mp_obj_property_t pixelbuf_pixelbuf_bpp_obj = {
};
-//| .. attribute:: brightness
-//|
-//| Float value between 0 and 1. Output brightness.
+//| brightness: Any = ...
+//| """Float value between 0 and 1. Output brightness.
//|
//| When brightness is less than 1.0, a second buffer will be used to store the color values
-//| before they are adjusted for brightness.
+//| before they are adjusted for brightness."""
//|
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_brightness(mp_obj_t self_in) {
return mp_obj_new_float(common_hal__pixelbuf_pixelbuf_get_brightness(self_in));
@@ -205,9 +204,8 @@ const mp_obj_property_t pixelbuf_pixelbuf_brightness_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| .. attribute:: auto_write
-//|
-//| Whether to automatically write the pixels after each update.
+//| auto_write: Any = ...
+//| """Whether to automatically write the pixels after each update."""
//|
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_auto_write(mp_obj_t self_in) {
return mp_obj_new_bool(common_hal__pixelbuf_pixelbuf_get_auto_write(self_in));
@@ -228,9 +226,8 @@ const mp_obj_property_t pixelbuf_pixelbuf_auto_write_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| .. attribute:: byteorder
-//|
-//| byteorder string for the buffer (read-only)
+//| byteorder: Any = ...
+//| """byteorder string for the buffer (read-only)"""
//|
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder(mp_obj_t self_in) {
return common_hal__pixelbuf_pixelbuf_get_byteorder_string(self_in);
@@ -253,10 +250,10 @@ STATIC mp_obj_t pixelbuf_pixelbuf_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
}
}
-//| .. method:: show()
-//|
-//| Transmits the color data to the pixels so that they are shown. This is done automatically
-//| when `auto_write` is True.
+//| def show(self, ) -> Any:
+//| """Transmits the color data to the pixels so that they are shown. This is done automatically
+//| when `auto_write` is True."""
+//| ...
//|
STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) {
@@ -265,9 +262,9 @@ STATIC mp_obj_t pixelbuf_pixelbuf_show(mp_obj_t self_in) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pixelbuf_pixelbuf_show_obj, pixelbuf_pixelbuf_show);
-//| .. function:: fill(color)
-//|
-//| Fills the given pixelbuf with the given color.
+//| def fill(color: Any) -> Any:
+//| """Fills the given pixelbuf with the given color."""
+//| ...
//|
STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) {
@@ -277,17 +274,16 @@ STATIC mp_obj_t pixelbuf_pixelbuf_fill(mp_obj_t self_in, mp_obj_t value) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(pixelbuf_pixelbuf_fill_obj, pixelbuf_pixelbuf_fill);
-
-//| .. method:: __getitem__(index)
-//|
-//| Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values
-//| between 0 and 255.
-//|
-//| .. method:: __setitem__(index, value)
+//| def __getitem__(self, index: Any) -> Any:
+//| """Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values
+//| between 0 and 255."""
+//| ...
//|
-//| Sets the pixel value at the given index. Value can either be a tuple of (Red, Green, Blue
-//| [, White]) values between 0 and 255 or an integer where the red, green and blue values are
-//| packed into the lower three bytes (0xRRGGBB).
+//| def __setitem__(self, index: Any, value: Any) -> Any:
+//| """Sets the pixel value at the given index. Value can either be a tuple of (Red, Green, Blue
+//| [, White]) values between 0 and 255 or an integer where the red, green and blue values are
+//| packed into the lower three bytes (0xRRGGBB)."""
+//| ...
//|
STATIC mp_obj_t pixelbuf_pixelbuf_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
if (value == MP_OBJ_NULL) {
diff --git a/shared-bindings/_pixelbuf/__init__.c b/shared-bindings/_pixelbuf/__init__.c
index 424ed23e4..3c04d436a 100644
--- a/shared-bindings/_pixelbuf/__init__.c
+++ b/shared-bindings/_pixelbuf/__init__.c
@@ -33,7 +33,7 @@
#include "shared-bindings/_pixelbuf/PixelBuf.h"
-//| :mod:`_pixelbuf` --- Fast RGB(W) pixel buffer and helpers
+//| """:mod:`_pixelbuf` --- Fast RGB(W) pixel buffer and helpers
//| ===========================================================
//| .. module:: _pixelbuf
@@ -50,13 +50,13 @@
//| .. toctree::
//| :maxdepth: 3
//|
-//| PixelBuf
-
-
-//| .. function:: wheel(n)
+//| PixelBuf"""
//|
-//| C implementation of the common wheel() function found in many examples.
-//| Returns the colorwheel RGB value as an integer value for n (usable in :py:class:`PixelBuf`, neopixel, and dotstar).
+
+//| def wheel(n: Any) -> Any:
+//| """C implementation of the common wheel() function found in many examples.
+//| Returns the colorwheel RGB value as an integer value for n (usable in :py:class:`PixelBuf`, neopixel, and dotstar)."""
+//| ...
//|
STATIC mp_obj_t pixelbuf_wheel(mp_obj_t n) {