Skip to content

Commit 214dfed

Browse files
authored
Add documentation for Palette shared binding
Add documentation for the palette subscript operator and how to use it.
1 parent 36e2faf commit 214dfed

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

shared-bindings/displayio/Palette.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,17 @@ STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_a
6666

6767
return MP_OBJ_FROM_PTR(self);
6868
}
69-
69+
//| .. method:: __setitem__(index, value)
70+
//|
71+
//| Sets the pixel color at the given index. The index should be an integer in the range 0 to color_count-1
72+
//|
73+
//| The color can be from 0x000000 to 0xFFFFFF, and can be an int or bytes (3 bytes (RGB) or 4 bytes (RGB + pad byte))
74+
//|
75+
//| This allows you to::
76+
//|
77+
//| palette[0] = 0xFFFFFF
78+
//| palette[1] = 0xFF0000
79+
//|
7080
STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
7181
if (value == MP_OBJ_NULL) {
7282
// delete item

0 commit comments

Comments
 (0)