@@ -44,31 +44,32 @@ extern const int32_t colorwheel(float pos);
4444
4545static void parse_byteorder (mp_obj_t byteorder_obj , pixelbuf_byteorder_details_t * parsed );
4646
47- //| .. currentmodule:: pixelbuf
47+ //| class PixelBuf:
48+ //| """.. currentmodule:: pixelbuf
4849//|
49- //| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices
50- //| ===========================================================================
50+ //| :class:`PixelBuf` -- A fast RGB[W] pixel buffer for LED and similar devices
51+ //| ===========================================================================
5152//|
52- //| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction.
53+ //| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction."""
5354//|
54- //| .. class:: PixelBuf(size, *, byteorder="BGR", brightness=0, auto_write=False, header=b"", trailer=b"")
55+ //| def __init__(self, size: int, *, byteorder: str = "BGR", brightness: float = 0, auto_write: bool = False, header: bytes = b"", trailer: bytes = b""):
56+ //| """Create a PixelBuf object of the specified size, byteorder, and bits per pixel.
5557//|
56- //| Create a PixelBuf object of the specified size, byteorder, and bits per pixel.
58+ //| When brightness is less than 1.0, a second buffer will be used to store the color values
59+ //| before they are adjusted for brightness.
5760//|
58- //| When brightness is less than 1.0, a second buffer will be used to store the color values
59- //| before they are adjusted for brightness.
61+ //| When ``P`` (pwm duration) is present as the 4th character of the byteorder
62+ //| string, the 4th value in the tuple/list for a pixel is the individual pixel
63+ //| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the
64+ //| output buffer (``buf``).
6065//|
61- //| When ``P`` (pwm duration) is present as the 4th character of the byteorder
62- //| string, the 4th value in the tuple/list for a pixel is the individual pixel
63- //| brightness (0.0-1.0) and will enable a Dotstar compatible 1st byte in the
64- //| output buffer (``buf``).
65- //|
66- //| :param ~int size: Number of pixelsx
67- //| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR")
68- //| :param ~float brightness: Brightness (0 to 1.0, default 1.0)
69- //| :param ~bool auto_write: Whether to automatically write pixels (Default False)
70- //| :param bytes header: Sequence of bytes to always send before pixel values.
71- //| :param bytes trailer: Sequence of bytes to always send after pixel values.
66+ //| :param ~int size: Number of pixelsx
67+ //| :param ~str byteorder: Byte order string (such as "BGR" or "PBGR")
68+ //| :param ~float brightness: Brightness (0 to 1.0, default 1.0)
69+ //| :param ~bool auto_write: Whether to automatically write pixels (Default False)
70+ //| :param bytes header: Sequence of bytes to always send before pixel values.
71+ //| :param bytes trailer: Sequence of bytes to always send after pixel values."""
72+ //| ...
7273//|
7374STATIC 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 ) {
7475 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
156157 }
157158}
158159
159- //| .. attribute:: bpp
160- //|
161- //| The number of bytes per pixel in the buffer (read-only)
160+ //| bpp: Any = ...
161+ //| """The number of bytes per pixel in the buffer (read-only)"""
162162//|
163163STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_bpp (mp_obj_t self_in ) {
164164 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 = {
173173};
174174
175175
176- //| .. attribute:: brightness
177- //|
178- //| Float value between 0 and 1. Output brightness.
176+ //| brightness: Any = ...
177+ //| """Float value between 0 and 1. Output brightness.
179178//|
180179//| When brightness is less than 1.0, a second buffer will be used to store the color values
181- //| before they are adjusted for brightness.
180+ //| before they are adjusted for brightness."""
182181//|
183182STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_brightness (mp_obj_t self_in ) {
184183 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 = {
205204 (mp_obj_t )& mp_const_none_obj },
206205};
207206
208- //| .. attribute:: auto_write
209- //|
210- //| Whether to automatically write the pixels after each update.
207+ //| auto_write: Any = ...
208+ //| """Whether to automatically write the pixels after each update."""
211209//|
212210STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_auto_write (mp_obj_t self_in ) {
213211 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 = {
228226 (mp_obj_t )& mp_const_none_obj },
229227};
230228
231- //| .. attribute:: byteorder
232- //|
233- //| byteorder string for the buffer (read-only)
229+ //| byteorder: Any = ...
230+ //| """byteorder string for the buffer (read-only)"""
234231//|
235232STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder (mp_obj_t self_in ) {
236233 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) {
253250 }
254251}
255252
256- //| .. method:: show()
257- //|
258- //| Transmits the color data to the pixels so that they are shown. This is done automatically
259- //| when `auto_write` is True .
253+ //| def show(self, ) -> Any:
254+ //| """Transmits the color data to the pixels so that they are shown. This is done automatically
255+ //| when `auto_write` is True."""
256+ //| .. .
260257//|
261258
262259STATIC 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) {
265262}
266263STATIC MP_DEFINE_CONST_FUN_OBJ_1 (pixelbuf_pixelbuf_show_obj , pixelbuf_pixelbuf_show );
267264
268- //| .. function:: fill(color)
269- //|
270- //| Fills the given pixelbuf with the given color .
265+ //| def fill(color: Any) -> Any:
266+ //| """Fills the given pixelbuf with the given color."""
267+ //| .. .
271268//|
272269
273270STATIC 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) {
277274}
278275STATIC MP_DEFINE_CONST_FUN_OBJ_2 (pixelbuf_pixelbuf_fill_obj , pixelbuf_pixelbuf_fill );
279276
280-
281- //| .. method:: __getitem__(index)
282- //|
283- //| Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values
284- //| between 0 and 255.
285- //|
286- //| .. method:: __setitem__(index, value)
277+ //| def __getitem__(self, index: Any) -> Any:
278+ //| """Returns the pixel value at the given index as a tuple of (Red, Green, Blue[, White]) values
279+ //| between 0 and 255."""
280+ //| ...
287281//|
288- //| Sets the pixel value at the given index. Value can either be a tuple of (Red, Green, Blue
289- //| [, White]) values between 0 and 255 or an integer where the red, green and blue values are
290- //| packed into the lower three bytes (0xRRGGBB).
282+ //| def __setitem__(self, index: Any, value: Any) -> Any:
283+ //| """Sets the pixel value at the given index. Value can either be a tuple of (Red, Green, Blue
284+ //| [, White]) values between 0 and 255 or an integer where the red, green and blue values are
285+ //| packed into the lower three bytes (0xRRGGBB)."""
286+ //| ...
291287//|
292288STATIC mp_obj_t pixelbuf_pixelbuf_subscr (mp_obj_t self_in , mp_obj_t index_in , mp_obj_t value ) {
293289 if (value == MP_OBJ_NULL ) {
0 commit comments