Skip to content

Commit 09530e5

Browse files
committed
Did os, _pixelbuf, _pew
1 parent d750096 commit 09530e5

File tree

5 files changed

+134
-138
lines changed

5 files changed

+134
-138
lines changed

shared-bindings/_pew/PewPew.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,33 +34,33 @@
3434
#include "shared-module/_pew/PewPew.h"
3535
#include "supervisor/shared/translate.h"
3636

37-
38-
//| .. currentmodule:: _pew
37+
//| class PewPew:
38+
//| """.. currentmodule:: _pew
3939
//|
40-
//| :class:`PewPew` -- LED matrix and button driver
41-
//| ===============================================
40+
//| :class:`PewPew` -- LED matrix and button driver
41+
//| ===============================================
4242
//|
43-
//| This is an internal module to be used by the ``pew.py`` library from
44-
//| https://github.com/pewpew-game/pew-pewpew-standalone-10.x to handle the
45-
//| LED matrix display and buttons on the ``pewpew10`` board.
43+
//| This is an internal module to be used by the ``pew.py`` library from
44+
//| https://github.com/pewpew-game/pew-pewpew-standalone-10.x to handle the
45+
//| LED matrix display and buttons on the ``pewpew10`` board.
4646
//|
47-
//| Usage::
47+
//| Usage::
4848
//|
49-
//| This singleton class is instantiated by the ``pew`` library, and
50-
//| used internally by it. All user-visible interactions are done through
51-
//| that library.
49+
//| This singleton class is instantiated by the ``pew`` library, and
50+
//| used internally by it. All user-visible interactions are done through
51+
//| that library."""
5252
//|
5353

54-
//| .. class:: PewPew(buffer, rows, cols, buttons)
55-
//|
56-
//| Initializes matrix scanning routines.
54+
//| def __init__(self, buffer: Any, rows: Any, cols: Any, buttons: Any):
55+
//| """Initializes matrix scanning routines.
5756
//|
58-
//| The ``buffer`` is a 64 byte long ``bytearray`` that stores what should
59-
//| be displayed on the matrix. ``rows`` and ``cols`` are both lists of
60-
//| eight ``DigitalInputOutput`` objects that are connected to the matrix
61-
//| rows and columns. ``buttons`` is a ``DigitalInputOutput`` object that
62-
//| is connected to the common side of all buttons (the other sides of the
63-
//| buttons are connected to rows of the matrix).
57+
//| The ``buffer`` is a 64 byte long ``bytearray`` that stores what should
58+
//| be displayed on the matrix. ``rows`` and ``cols`` are both lists of
59+
//| eight ``DigitalInputOutput`` objects that are connected to the matrix
60+
//| rows and columns. ``buttons`` is a ``DigitalInputOutput`` object that
61+
//| is connected to the common side of all buttons (the other sides of the
62+
//| buttons are connected to rows of the matrix)."""
63+
//| ...
6464
//|
6565
STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args,
6666
const mp_obj_t *pos_args, mp_map_t *kw_args) {

shared-bindings/_pew/__init__.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ STATIC mp_obj_t get_pressed(void) {
4141
STATIC MP_DEFINE_CONST_FUN_OBJ_0(get_pressed_obj, get_pressed);
4242

4343

44-
//| :mod:`_pew` --- LED matrix driver
44+
//| """:mod:`_pew` --- LED matrix driver
4545
//| ==================================
4646
//|
4747
//| .. module:: _pew
@@ -51,7 +51,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(get_pressed_obj, get_pressed);
5151
//| .. toctree::
5252
//| :maxdepth: 3
5353
//|
54-
//| PewPew
54+
//| PewPew"""
5555
//|
5656
STATIC const mp_rom_map_elem_t pew_module_globals_table[] = {
5757
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR__pew) },

shared-bindings/_pixelbuf/PixelBuf.c

Lines changed: 45 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,32 @@ extern const int32_t colorwheel(float pos);
4444

4545
static 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
//|
7374
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) {
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
//|
163163
STATIC 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
//|
183182
STATIC 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
//|
212210
STATIC 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
//|
235232
STATIC 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

262259
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) {
265262
}
266263
STATIC 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

273270
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) {
277274
}
278275
STATIC 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
//|
292288
STATIC 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) {

shared-bindings/_pixelbuf/__init__.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include "shared-bindings/_pixelbuf/PixelBuf.h"
3434

3535

36-
//| :mod:`_pixelbuf` --- Fast RGB(W) pixel buffer and helpers
36+
//| """:mod:`_pixelbuf` --- Fast RGB(W) pixel buffer and helpers
3737
//| ===========================================================
3838

3939
//| .. module:: _pixelbuf
@@ -50,13 +50,13 @@
5050
//| .. toctree::
5151
//| :maxdepth: 3
5252
//|
53-
//| PixelBuf
54-
55-
56-
//| .. function:: wheel(n)
53+
//| PixelBuf"""
5754
//|
58-
//| C implementation of the common wheel() function found in many examples.
59-
//| Returns the colorwheel RGB value as an integer value for n (usable in :py:class:`PixelBuf`, neopixel, and dotstar).
55+
56+
//| def wheel(n: Any) -> Any:
57+
//| """C implementation of the common wheel() function found in many examples.
58+
//| Returns the colorwheel RGB value as an integer value for n (usable in :py:class:`PixelBuf`, neopixel, and dotstar)."""
59+
//| ...
6060
//|
6161

6262
STATIC mp_obj_t pixelbuf_wheel(mp_obj_t n) {

0 commit comments

Comments
 (0)