diff options
| author | mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> | 2022-01-13 15:32:24 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-13 15:32:24 +0000 |
| commit | c682a7e5e313d7db66eec589273cb64dc6310748 (patch) | |
| tree | 61a527fa6562eb90712f6299b8043458ad7eeac4 | |
| parent | fa2ae183136796d9c7c8f661e6d31c620301d9c4 (diff) | |
| parent | e5d7940879899e1f0a334ede8f364793cabbdc25 (diff) | |
Merge pull request #240 from solhuebner/patch-3
Fix boundary check of VirtualMatrixPanel getCoords
| -rw-r--r-- | ESP32-VirtualMatrixPanel-I2S-DMA.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/ESP32-VirtualMatrixPanel-I2S-DMA.h b/ESP32-VirtualMatrixPanel-I2S-DMA.h index 47ac960..b2c36d0 100644 --- a/ESP32-VirtualMatrixPanel-I2S-DMA.h +++ b/ESP32-VirtualMatrixPanel-I2S-DMA.h @@ -134,19 +134,19 @@ inline VirtualCoords VirtualMatrixPanel::getCoords(int16_t &x, int16_t &y) { //Serial.println("Called Base."); coords.x = coords.y = -1; // By defalt use an invalid co-ordinates that will be rejected by updateMatrixDMABuffer - if ( x < 0 || x >= virtualResX || y < 0 || y >= virtualResY ) { // Co-ordinates go from 0 to X-1 remember! otherwise they are out of range! - //Serial.printf("VirtualMatrixPanel::getCoords(): Invalid virtual display coordinate. x,y: %d, %d\r\n", x, y); - return coords; - } - // We want to rotate? if (_rotate){ - uint16_t temp_x=x; + int16_t temp_x=x; x=y; y=virtualResY-1-temp_x; - } + } + + if ( x < 0 || x >= virtualResX || y < 0 || y >= virtualResY ) { // Co-ordinates go from 0 to X-1 remember! otherwise they are out of range! + //Serial.printf("VirtualMatrixPanel::getCoords(): Invalid virtual display coordinate. x,y: %d, %d\r\n", x, y); + return coords; + } - // Stupidity check + // Stupidity check if ( (vmodule_rows == 1) && (vmodule_cols == 1)) // single panel... { coords.x = x; |
