Skip to content

Add documentation for Palette shared binding #1874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion shared-bindings/displayio/Palette.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,20 @@ STATIC mp_obj_t displayio_palette_make_new(const mp_obj_type_t *type, size_t n_a

return MP_OBJ_FROM_PTR(self);
}

//| .. method:: __setitem__(index, value)
//|
//| Sets the pixel color at the given index. The index should be an integer in the range 0 to color_count-1.
//|
//| The value argument represents a color, and can be from 0x000000 to 0xFFFFFF (to represent an RGB value).
//| Value can be an int, bytes (3 bytes (RGB) or 4 bytes (RGB + pad byte)), or bytearray.
//|
//| This allows you to::
//|
//| palette[0] = 0xFFFFFF # set using an integer
//| palette[1] = b'\xff\xff\x00' # set using 3 bytes
//| palette[2] = b'\xff\xff\x00\x00' # set using 4 bytes
//| palette[3] = bytearray(b'\x00\x00\xFF') # set using a bytearay of 3 or 4 bytes
//|
STATIC mp_obj_t palette_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
if (value == MP_OBJ_NULL) {
// delete item
Expand Down