Merge pull request #2027 from dastels/displayio_fill_area

To displayio.Display: expose fill_area and add a property for rotation
This commit is contained in:
Scott Shawcroft 2019-08-21 23:48:21 -07:00 committed by GitHub
commit 6aa311aabd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 248 additions and 12 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -330,6 +330,14 @@ msgstr ""
msgid "Buffer incorrect size. Should be %d bytes."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -520,6 +528,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr ""

View File

@ -8,6 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
@ -326,6 +327,14 @@ msgstr ""
msgid "Buffer incorrect size. Should be %d bytes."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -509,6 +518,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@ -330,6 +330,14 @@ msgstr "Die Helligkeit ist nicht einstellbar"
msgid "Buffer incorrect size. Should be %d bytes."
msgstr "Der Puffergröße ist inkorrekt. Sie sollte %d bytes haben."
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -513,6 +521,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr "Die Zielkapazität ist kleiner als destination_length."
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr "Die Rotation der Anzeige muss in 90-Grad-Schritten erfolgen"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -326,6 +326,14 @@ msgstr ""
msgid "Buffer incorrect size. Should be %d bytes."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -509,6 +517,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: @sommersoft, @MrCertainly\n"
@ -330,6 +330,14 @@ msgstr ""
msgid "Buffer incorrect size. Should be %d bytes."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -513,6 +521,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -339,6 +339,14 @@ msgstr "Tamaño de buffer incorrecto. Debe ser de %d bytes."
msgid "Buffer length %d too big. It must be less than %d"
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c
msgid "Buffer must be at least length 1"
msgstr "Buffer debe ser de longitud 1 como minimo"
@ -517,6 +525,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr "Capacidad de destino es mas pequeña que destination_length."
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr "Rotación de display debe ser en incrementos de 90 grados"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@ -332,6 +332,14 @@ msgstr ""
msgid "Buffer incorrect size. Should be %d bytes."
msgstr "Mali ang size ng buffer. Dapat %d bytes."
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -521,6 +529,10 @@ msgid "Destination capacity is smaller than destination_length."
msgstr ""
"Ang kapasidad ng destinasyon ay mas maliit kaysa sa destination_length."
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: 2019-04-14 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@ -337,6 +337,14 @@ msgstr "Luminosité non-ajustable"
msgid "Buffer incorrect size. Should be %d bytes."
msgstr "Tampon de taille incorrect. Devrait être de %d octets."
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -525,6 +533,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr "La capacité de destination est plus petite que 'destination_length'."
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr "La rotation d'affichage doit se faire par incréments de 90 degrés"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@ -332,6 +332,14 @@ msgstr "Illiminazione non è regolabile"
msgid "Buffer incorrect size. Should be %d bytes."
msgstr "Buffer di lunghezza non valida. Dovrebbe essere di %d bytes."
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -521,6 +529,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr "La capacità di destinazione è più piccola di destination_length."
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
"Language-Team: pl\n"
@ -329,6 +329,14 @@ msgstr "Jasność nie jest regulowana"
msgid "Buffer incorrect size. Should be %d bytes."
msgstr "Zła wielkość bufora. Powinno być %d bajtów."
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -512,6 +520,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr "Pojemność celu mniejsza od destination_length."
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr "Wyświetlacz można obracać co 90 stopni"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -329,6 +329,14 @@ msgstr ""
msgid "Buffer incorrect size. Should be %d bytes."
msgstr "Buffer de tamanho incorreto. Deve ser %d bytes."
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -516,6 +524,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-19 10:22-0400\n"
"POT-Creation-Date: 2019-08-21 14:18-0400\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@ -330,6 +330,14 @@ msgstr "Liàngdù wúfǎ tiáozhěng"
msgid "Buffer incorrect size. Should be %d bytes."
msgstr "Huǎnchōng qū dàxiǎo bù zhèngquè. Yīnggāi shì %d zì jié."
#: shared-bindings/displayio/Display.c
msgid "Buffer is not a bytearray."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Buffer is too small"
msgstr ""
#: ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
#, c-format
msgid "Buffer length %d too big. It must be less than %d"
@ -513,6 +521,10 @@ msgstr ""
msgid "Destination capacity is smaller than destination_length."
msgstr "Mùbiāo róngliàng xiǎoyú mùdì de_chángdù."
#: shared-bindings/displayio/Display.c
msgid "Display must have a 16 bit colorspace."
msgstr ""
#: shared-bindings/displayio/Display.c
msgid "Display rotation must be in 90 degree increments"
msgstr "Xiǎnshì xuánzhuǎn bìxū 90 dù jiā xīn"

View File

@ -14,3 +14,6 @@ LONGINT_IMPL = MPZ
CFLAGS_INLINE_LIMIT = 60
SUPEROPT_GC = 0
CIRCUITPY_I2CSLAVE = 0
CIRCUITPY_RTC = 0

View File

@ -337,6 +337,23 @@ const mp_obj_property_t displayio_display_height_obj = {
(mp_obj_t)&mp_const_none_obj},
};
//| .. attribute:: rotation
//|
//| The rotation of the display as an int in degrees.
//|
STATIC mp_obj_t displayio_display_obj_get_rotation(mp_obj_t self_in) {
displayio_display_obj_t *self = native_display(self_in);
return MP_OBJ_NEW_SMALL_INT(common_hal_displayio_display_get_rotation(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(displayio_display_get_rotation_obj, displayio_display_obj_get_rotation);
const mp_obj_property_t displayio_display_rotation_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&displayio_display_get_rotation_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj},
};
//| .. attribute:: bus
//|
//| The bus being used by the display
@ -356,16 +373,81 @@ const mp_obj_property_t displayio_display_bus_obj = {
};
//| .. method:: fill_row(y, buffer)
//|
//| Extract the pixels from a single row
//|
//| :param int y: The top edge of the area
//| :param bytearray buffer: The buffer in which to place the pixel data
STATIC mp_obj_t displayio_display_obj_fill_row(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_y, ARG_buffer };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_y, MP_ARG_INT | MP_ARG_REQUIRED, {.u_int = -1} },
{ MP_QSTR_buffer, MP_ARG_OBJ | MP_ARG_REQUIRED, {} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
displayio_display_obj_t *self = native_display(pos_args[0]);
mp_int_t y = args[ARG_y].u_int;
mp_obj_t *result = args[ARG_buffer].u_obj;
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(result, &bufinfo, MP_BUFFER_WRITE);
if (bufinfo.typecode != BYTEARRAY_TYPECODE) {
mp_raise_ValueError(translate("Buffer is not a bytearray."));
}
if (self->colorspace.depth != 16) {
mp_raise_ValueError(translate("Display must have a 16 bit colorspace."));
}
displayio_area_t area = {
.x1 = 0,
.y1 = y,
.x2 = self->width,
.y2 = y + 1
};
uint8_t pixels_per_word = (sizeof(uint32_t) * 8) / self->colorspace.depth;
uint16_t buffer_size = self->width / pixels_per_word;
uint16_t pixels_per_buffer = displayio_area_size(&area);
if (pixels_per_buffer % pixels_per_word) {
buffer_size += 1;
}
uint32_t *result_buffer = bufinfo.buf;
size_t result_buffer_size = bufinfo.len;
if (result_buffer_size >= (buffer_size * 4)) {
volatile uint32_t mask_length = (pixels_per_buffer / 32) + 1;
uint32_t mask[mask_length];
for (uint16_t k = 0; k < mask_length; k++) {
mask[k] = 0x00000000;
}
displayio_display_fill_area(self, &area, mask, result_buffer);
return result;
} else {
mp_raise_ValueError(translate("Buffer is too small"));
}
}
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_display_fill_row_obj, 1, displayio_display_obj_fill_row);
STATIC const mp_rom_map_elem_t displayio_display_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_show), MP_ROM_PTR(&displayio_display_show_obj) },
{ MP_ROM_QSTR(MP_QSTR_refresh_soon), MP_ROM_PTR(&displayio_display_refresh_soon_obj) },
{ MP_ROM_QSTR(MP_QSTR_wait_for_frame), MP_ROM_PTR(&displayio_display_wait_for_frame_obj) },
{ MP_ROM_QSTR(MP_QSTR_fill_row), MP_ROM_PTR(&displayio_display_fill_row_obj) },
{ MP_ROM_QSTR(MP_QSTR_brightness), MP_ROM_PTR(&displayio_display_brightness_obj) },
{ MP_ROM_QSTR(MP_QSTR_auto_brightness), MP_ROM_PTR(&displayio_display_auto_brightness_obj) },
{ MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&displayio_display_width_obj) },
{ MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&displayio_display_height_obj) },
{ MP_ROM_QSTR(MP_QSTR_rotation), MP_ROM_PTR(&displayio_display_rotation_obj) },
{ MP_ROM_QSTR(MP_QSTR_bus), MP_ROM_PTR(&displayio_display_bus_obj) },
};
STATIC MP_DEFINE_CONST_DICT(displayio_display_locals_dict, displayio_display_locals_dict_table);

View File

@ -69,6 +69,7 @@ void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* s
uint16_t common_hal_displayio_display_get_width(displayio_display_obj_t* self);
uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t* self);
uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self);
mp_float_t common_hal_displayio_display_get_brightness(displayio_display_obj_t* self);
bool common_hal_displayio_display_set_brightness(displayio_display_obj_t* self, mp_float_t brightness);

View File

@ -119,7 +119,7 @@ void common_hal_displayio_display_construct(displayio_display_obj_t* self,
self->width = width;
self->height = height;
rotation = rotation % 360;
self->rotation = rotation % 360;
self->transform.x = 0;
self->transform.y = 0;
self->transform.scale = 1;
@ -257,6 +257,10 @@ uint16_t common_hal_displayio_display_get_height(displayio_display_obj_t* self){
return self->height;
}
uint16_t common_hal_displayio_display_get_rotation(displayio_display_obj_t* self){
return self->rotation;
}
void common_hal_displayio_display_set_auto_brightness(displayio_display_obj_t* self, bool auto_brightness) {
self->auto_brightness = auto_brightness;
}

View File

@ -55,6 +55,7 @@ typedef struct {
mp_float_t current_brightness;
uint16_t width;
uint16_t height;
uint16_t rotation;
_displayio_colorspace_t colorspace;
int16_t colstart;
int16_t rowstart;