@@ -44,31 +44,32 @@ extern const int32_t colorwheel(float pos);
44
44
45
45
static void parse_byteorder (mp_obj_t byteorder_obj , pixelbuf_byteorder_details_t * parsed );
46
46
47
- //| .. currentmodule:: pixelbuf
47
+ //| class PixelBuf:
48
+ //| """.. currentmodule:: pixelbuf
48
49
//|
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
+ //| ===========================================================================
51
52
//|
52
- //| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction.
53
+ //| :class:`~_pixelbuf.PixelBuf` implements an RGB[W] bytearray abstraction."""
53
54
//|
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.
55
57
//|
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.
57
60
//|
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``).
60
65
//|
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
+ //| ...
72
73
//|
73
74
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 ) {
74
75
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
156
157
}
157
158
}
158
159
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)"""
162
162
//|
163
163
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_bpp (mp_obj_t self_in ) {
164
164
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 = {
173
173
};
174
174
175
175
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.
179
178
//|
180
179
//| 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."""
182
181
//|
183
182
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_brightness (mp_obj_t self_in ) {
184
183
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 = {
205
204
(mp_obj_t )& mp_const_none_obj },
206
205
};
207
206
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."""
211
209
//|
212
210
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_auto_write (mp_obj_t self_in ) {
213
211
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 = {
228
226
(mp_obj_t )& mp_const_none_obj },
229
227
};
230
228
231
- //| .. attribute:: byteorder
232
- //|
233
- //| byteorder string for the buffer (read-only)
229
+ //| byteorder: Any = ...
230
+ //| """byteorder string for the buffer (read-only)"""
234
231
//|
235
232
STATIC mp_obj_t pixelbuf_pixelbuf_obj_get_byteorder (mp_obj_t self_in ) {
236
233
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) {
253
250
}
254
251
}
255
252
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
+ //| .. .
260
257
//|
261
258
262
259
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) {
265
262
}
266
263
STATIC MP_DEFINE_CONST_FUN_OBJ_1 (pixelbuf_pixelbuf_show_obj , pixelbuf_pixelbuf_show );
267
264
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
+ //| .. .
271
268
//|
272
269
273
270
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) {
277
274
}
278
275
STATIC MP_DEFINE_CONST_FUN_OBJ_2 (pixelbuf_pixelbuf_fill_obj , pixelbuf_pixelbuf_fill );
279
276
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
+ //| ...
287
281
//|
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
+ //| ...
291
287
//|
292
288
STATIC mp_obj_t pixelbuf_pixelbuf_subscr (mp_obj_t self_in , mp_obj_t index_in , mp_obj_t value ) {
293
289
if (value == MP_OBJ_NULL ) {
0 commit comments