diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index 0fc96f8b6e..e421eef8ea 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -147,11 +147,6 @@ msgstr "" msgid "%q must of type %q" msgstr "" -#: shared-bindings/keypad/KeyMatrix.c shared-bindings/keypad/Keys.c -#: shared-bindings/keypad/ShiftRegisterKeys.c -msgid "%q must store bytes" -msgstr "" - #: ports/raspberrypi/common-hal/rp2pio/StateMachine.c #: shared-bindings/canio/Match.c msgid "%q out of range" diff --git a/shared-bindings/displayio/__init__.c b/shared-bindings/displayio/__init__.c index b39e72b946..dc4971de2a 100644 --- a/shared-bindings/displayio/__init__.c +++ b/shared-bindings/displayio/__init__.c @@ -70,6 +70,10 @@ MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565, DISPLAY MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB565_SWAPPED, DISPLAYIO_COLORSPACE_RGB565_SWAPPED); MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555, DISPLAYIO_COLORSPACE_RGB555); MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, RGB555_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565, DISPLAYIO_COLORSPACE_BGR565); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR565_SWAPPED, DISPLAYIO_COLORSPACE_BGR565_SWAPPED); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555, DISPLAYIO_COLORSPACE_BGR555); +MAKE_ENUM_VALUE(displayio_colorspace_type, displayio_colorspace, BGR555_SWAPPED, DISPLAYIO_COLORSPACE_BGR555_SWAPPED); //| class Colorspace: //| """The colorspace for a `ColorConverter` to operate in""" @@ -95,6 +99,10 @@ MAKE_ENUM_MAP(displayio_colorspace) { MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB565_SWAPPED), MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555), MAKE_ENUM_MAP_ENTRY(displayio_colorspace, RGB555_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR565_SWAPPED), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555), + MAKE_ENUM_MAP_ENTRY(displayio_colorspace, BGR555_SWAPPED), }; STATIC MP_DEFINE_CONST_DICT(displayio_colorspace_locals_dict, displayio_colorspace_locals_table); diff --git a/shared-bindings/displayio/__init__.h b/shared-bindings/displayio/__init__.h index 31af2ff2ba..938fcf3d98 100644 --- a/shared-bindings/displayio/__init__.h +++ b/shared-bindings/displayio/__init__.h @@ -46,6 +46,10 @@ typedef enum { DISPLAYIO_COLORSPACE_RGB555, DISPLAYIO_COLORSPACE_RGB565_SWAPPED, DISPLAYIO_COLORSPACE_RGB555_SWAPPED, + DISPLAYIO_COLORSPACE_BGR565, + DISPLAYIO_COLORSPACE_BGR555, + DISPLAYIO_COLORSPACE_BGR565_SWAPPED, + DISPLAYIO_COLORSPACE_BGR555_SWAPPED, } displayio_colorspace_t; typedef bool (*display_bus_bus_reset)(mp_obj_t bus); diff --git a/shared-module/displayio/ColorConverter.c b/shared-module/displayio/ColorConverter.c index 6de7fe7883..4871ce81a0 100644 --- a/shared-module/displayio/ColorConverter.c +++ b/shared-module/displayio/ColorConverter.c @@ -176,6 +176,28 @@ void displayio_colorconverter_convert(displayio_colorconverter_t *self, const _d } break; + case DISPLAYIO_COLORSPACE_BGR565_SWAPPED: + pixel = __builtin_bswap16(pixel); + MP_FALLTHROUGH; + case DISPLAYIO_COLORSPACE_BGR565: { + uint32_t b8 = (pixel >> 11) << 3; + uint32_t g8 = ((pixel >> 5) << 2) & 0xff; + uint32_t r8 = (pixel << 3) & 0xff; + pixel = (r8 << 16) | (g8 << 8) | b8; + } + break; + + case DISPLAYIO_COLORSPACE_BGR555_SWAPPED: + pixel = __builtin_bswap16(pixel); + MP_FALLTHROUGH; + case DISPLAYIO_COLORSPACE_BGR555: { + uint32_t b8 = (pixel >> 10) << 3; + uint32_t g8 = ((pixel >> 5) << 3) & 0xff; + uint32_t r8 = (pixel << 3) & 0xff; + pixel = (r8 << 16) | (g8 << 8) | b8; + } + break; + case DISPLAYIO_COLORSPACE_RGB888: break; }