From b101ae69971d11fe23f52791d5ab29897218a587 Mon Sep 17 00:00:00 2001 From: mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> Date: Sat, 1 Apr 2023 19:31:24 +0100 Subject: [PATCH] Update ESP32-VirtualMatrixPanel-I2S-DMA.h --- src/ESP32-VirtualMatrixPanel-I2S-DMA.h | 30 ++++++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h index b84b968..37af9be 100644 --- a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h +++ b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h @@ -181,6 +181,14 @@ inline VirtualCoords VirtualMatrixPanel::getCoords(int16_t virt_x, int16_t virt_ coords.x = coords.y = -1; // By defalt use an invalid co-ordinates that will be rejected by updateMatrixDMABuffer return coords; } +#else + + if (virt_x < 0 || virt_x >= _virtualResX || virt_y < 0 || virt_y >= _virtualResY) // _width and _height are defined in the adafruit constructor + { // Co-ordinates go from 0 to X-1 remember! otherwise they are out of range! + coords.x = coords.y = -1; // By defalt use an invalid co-ordinates that will be rejected by updateMatrixDMABuffer + return coords; + } + #endif // Do we want to rotate? @@ -458,24 +466,32 @@ inline void VirtualMatrixPanel::setRotation(int rotate) if(rotate < 4 && rotate >= 0) _rotate = rotate; -#if !defined NO_GFX - // Change the _width and _height variables used by the underlying adafruit gfx library. // Actual pixel rotation / mapping is done in the getCoords function. rotation = (rotate & 3); switch (rotation) { case 0: // nothing case 2: // 180 - _width = virtualResX; - _height = virtualResY; + _virtualResX = virtualResX; + _virtualResY = virtualResY; + +#if !defined NO_GFX + _width = virtualResX; // adafruit base class + _height = virtualResY; // adafruit base class +#endif break; case 1: case 3: - _width = virtualResY; - _height = virtualResX; + _virtualResX = virtualResY; + _virtualResY = virtualResX; + +#if !defined NO_GFX + _width = virtualResY; // adafruit base class + _height = virtualResX; // adafruit base class +#endif break; } -#endif + }