diff --git a/epicardium/epicardium.h b/epicardium/epicardium.h index cbc89d3f8349ffd7839546c298f49b24d3d3d108..ff8fb0f6b2e55dc1cfe4b341d2d82dde791b02ae 100644 --- a/epicardium/epicardium.h +++ b/epicardium/epicardium.h @@ -1304,8 +1304,13 @@ API(API_DISP_PIXEL, ); /** + * Draws pixels on the display + * + * :param data: Image data as byte string: int8 x, int8 y, int16 rgb585, ... + * :param data_length: Amount of pixels in data + * :param offset_x: Offset in x direction of the pixels + * :param offset_y: Offset in y direction of the pixels */ - API(API_DISP_PIXELS, int epic_disp_pixels(const uint8_t *data, size_t data_length, uint8_t offset_x, uint8_t offset_y) ); diff --git a/pycardium/modules/py/display.py b/pycardium/modules/py/display.py index 220951e4aa6b9ea98cc761ab731020de96693544..aa1d14a6502cd1d7d7d61687c0ae1f7bf1d0f699 100644 --- a/pycardium/modules/py/display.py +++ b/pycardium/modules/py/display.py @@ -10,6 +10,12 @@ FONT24 = 4 def get_pixels_size(data): + """ + Returns (min_x, min_y, max_x, max_y, width, height) from and pixels data byte string + + :param data: Image data as byte string: int8 x, int8 y, int16 rgb585, ... + """ + min_x = max_x = data[0] min_y = max_y = data[1] @@ -136,7 +142,30 @@ class Display: """ Draws pixels on the display - :param data: Image data as byte string: int8 x, int8 y, int16 rgb585 + :param data: Image data as byte string: int8 x, int8 y, int16 rgb585, ... + :param offset_x: Offset in x direction of the pixels + :param offset_y: Offset in y direction of the pixels + + **Example:** + .. code-block:: python + + data = b'\x00\x00\xF8\x00' + # |--| x-position: 0 + # |--| yposition: 0 + # |------| color (rgb565): red + data += b'\x05\x00\x07\xE0' + # |--| x-position: 1 + # |--| yposition: 0 + # |------| color (rgb565): green + data += b'\x02\x0f\x00\x1F' + # |--| x-position: 2 + # |--| yposition: 15 + # |------| color (rgb565): blue + + with display.open() as d: + d.clear() + d.pixels(data, offset_x=20, offset_y=10) + d.update() """ sys_display.pixels(data, offset_x, offset_y) diff --git a/pycardium/modules/sys_display.c b/pycardium/modules/sys_display.c index d1b6e1686f1b7cac978a9ceec5aca3d23ed48935..1950768533d6795fe8b88f67c7b1bf219f0fa58b 100644 --- a/pycardium/modules/sys_display.c +++ b/pycardium/modules/sys_display.c @@ -94,6 +94,7 @@ static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN( display_pixel_obj, 3, 3, mp_display_pixel ); +/* draw pixels on the display */ static mp_obj_t mp_display_pixels(size_t n_args, const mp_obj_t *args) { uint8_t offset_x = mp_obj_get_int(args[1]);