diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a3f1a8d27..7fa2953b37 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -475,7 +475,7 @@ jobs: id: idf-cache with: path: ${{ github.workspace }}/.idf_tools - key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210303 + key: ${{ runner.os }}-idf-tools-${{ hashFiles('.git/modules/ports/esp32s2/esp-idf/HEAD') }}-20210304 - name: Clone IDF submodules run: | (cd $IDF_PATH && git submodule update --init) diff --git a/lib/tinyusb b/lib/tinyusb index 5285548c75..280297bdb7 160000 --- a/lib/tinyusb +++ b/lib/tinyusb @@ -1 +1 @@ -Subproject commit 5285548c7543354ac8e13da37499019e204b1c49 +Subproject commit 280297bdb7aec67adf347ec046943a48a71647df diff --git a/shared-module/displayio/TileGrid.c b/shared-module/displayio/TileGrid.c index 2cd3a49488..96473d4a86 100644 --- a/shared-module/displayio/TileGrid.c +++ b/shared-module/displayio/TileGrid.c @@ -74,6 +74,7 @@ void common_hal_displayio_tilegrid_construct(displayio_tilegrid_t *self, mp_obj_ self->flip_x = false; self->flip_y = false; self->transpose_xy = false; + self->absolute_transform = NULL; } @@ -110,17 +111,24 @@ void _update_current_x(displayio_tilegrid_t *self) { } else { width = self->pixel_width; } - if (self->absolute_transform->transpose_xy) { - self->current_area.y1 = self->absolute_transform->y + self->absolute_transform->dy * self->x; - self->current_area.y2 = self->absolute_transform->y + self->absolute_transform->dy * (self->x + width); + + // If there's no transform, substitute an identity transform so the calculations will work. + const displayio_buffer_transform_t* absolute_transform = + self->absolute_transform == NULL + ? &null_transform + : self->absolute_transform; + + if (absolute_transform->transpose_xy) { + self->current_area.y1 = absolute_transform->y + absolute_transform->dy * self->x; + self->current_area.y2 = absolute_transform->y + absolute_transform->dy * (self->x + width); if (self->current_area.y2 < self->current_area.y1) { int16_t temp = self->current_area.y2; self->current_area.y2 = self->current_area.y1; self->current_area.y1 = temp; } } else { - self->current_area.x1 = self->absolute_transform->x + self->absolute_transform->dx * self->x; - self->current_area.x2 = self->absolute_transform->x + self->absolute_transform->dx * (self->x + width); + self->current_area.x1 = absolute_transform->x + absolute_transform->dx * self->x; + self->current_area.x2 = absolute_transform->x + absolute_transform->dx * (self->x + width); if (self->current_area.x2 < self->current_area.x1) { int16_t temp = self->current_area.x2; self->current_area.x2 = self->current_area.x1; @@ -136,17 +144,24 @@ void _update_current_y(displayio_tilegrid_t *self) { } else { height = self->pixel_height; } - if (self->absolute_transform->transpose_xy) { - self->current_area.x1 = self->absolute_transform->x + self->absolute_transform->dx * self->y; - self->current_area.x2 = self->absolute_transform->x + self->absolute_transform->dx * (self->y + height); + + // If there's no transform, substitute an identity transform so the calculations will work. + const displayio_buffer_transform_t* absolute_transform = + self->absolute_transform == NULL + ? &null_transform + : self->absolute_transform; + + if (absolute_transform->transpose_xy) { + self->current_area.x1 = absolute_transform->x + absolute_transform->dx * self->y; + self->current_area.x2 = absolute_transform->x + absolute_transform->dx * (self->y + height); if (self->current_area.x2 < self->current_area.x1) { int16_t temp = self->current_area.x2; self->current_area.x2 = self->current_area.x1; self->current_area.x1 = temp; } } else { - self->current_area.y1 = self->absolute_transform->y + self->absolute_transform->dy * self->y; - self->current_area.y2 = self->absolute_transform->y + self->absolute_transform->dy * (self->y + height); + self->current_area.y1 = absolute_transform->y + absolute_transform->dy * self->y; + self->current_area.y2 = absolute_transform->y + absolute_transform->dy * (self->y + height); if (self->current_area.y2 < self->current_area.y1) { int16_t temp = self->current_area.y2; self->current_area.y2 = self->current_area.y1; diff --git a/shared-module/displayio/__init__.c b/shared-module/displayio/__init__.c index a9bb3b21b6..740af0570c 100644 --- a/shared-module/displayio/__init__.c +++ b/shared-module/displayio/__init__.c @@ -26,6 +26,20 @@ primary_display_t displays[CIRCUITPY_DISPLAY_LIMIT]; +displayio_buffer_transform_t null_transform = { + .x = 0, + .y = 0, + .dx = 1, + .dy = 1, + .scale = 1, + .width = 0, + .height = 0, + .mirror_x = false, + .mirror_y = false, + .transpose_xy = false +}; + + #if CIRCUITPY_RGBMATRIX STATIC bool any_display_uses_this_framebuffer(mp_obj_base_t *obj) { for (uint8_t i = 0; i < CIRCUITPY_DISPLAY_LIMIT; i++) { diff --git a/shared-module/displayio/area.h b/shared-module/displayio/area.h index ec7c389b4b..7ad36883ce 100644 --- a/shared-module/displayio/area.h +++ b/shared-module/displayio/area.h @@ -51,6 +51,8 @@ typedef struct { bool transpose_xy; } displayio_buffer_transform_t; +extern displayio_buffer_transform_t null_transform; + void displayio_area_union(const displayio_area_t* a, const displayio_area_t* b, displayio_area_t* u); diff --git a/shared-module/vectorio/VectorShape.c b/shared-module/vectorio/VectorShape.c index 81f46b3fa0..b5d36339ed 100644 --- a/shared-module/vectorio/VectorShape.c +++ b/shared-module/vectorio/VectorShape.c @@ -93,20 +93,6 @@ void common_hal_vectorio_vector_shape_set_dirty(void *vector_shape) { } -static displayio_buffer_transform_t null_transform = { - .x = 0, - .y = 0, - .dx = 1, - .dy = 1, - .scale = 1, - .width = 0, - .height = 0, - .mirror_x = false, - .mirror_y = false, - .transpose_xy = false -}; - - void common_hal_vectorio_vector_shape_construct(vectorio_vector_shape_t *self, vectorio_ishape_t ishape, mp_obj_t pixel_shader, uint16_t x, uint16_t y) {