From 70c2ad6c06414969884e89a80de71f613a758bb4 Mon Sep 17 00:00:00 2001 From: Kouzerumatsu / Bananafox <46141631+Kouzeru@users.noreply.github.com> Date: Thu, 9 Feb 2023 22:52:31 +0800 Subject: [PATCH 1/4] Update ESP32-HUB75-MatrixPanel-I2S-DMA.cpp --- src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp index dea7ce6..e3ddbad 100644 --- a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp +++ b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp @@ -715,7 +715,8 @@ void MatrixPanel_I2S_DMA::brtCtrlOEv2(uint8_t brt, const int _buff_id) { char rightshift = std::max( bitplane - bitshift - 2, 0 ); // calculate the OE disable period by brightness, and also blanking - int brightness_in_x_pixels = ( ( _width - _blank ) * brt) >> (8 + rightshift); + int brightness_in_x_pixels = ( ( _width - _blank ) * brt ) >> ( 7 + rightshift ); + brightness_in_x_pixels = ( brightness_in_x_pixels >> 1 ) | ( brightness_in_x_pixels & 1 ); // switch pointer to a row for a specific color index ESP32_I2S_DMA_STORAGE_TYPE* row = dma_buff.rowBits[row_idx]->getDataPtr(colouridx, _buff_id); From a5db9e0665e9e21e092a4f7d5e83c62cfa6fc6a7 Mon Sep 17 00:00:00 2001 From: Kouzerumatsu / Bananafox <46141631+Kouzeru@users.noreply.github.com> Date: Sat, 11 Feb 2023 00:43:07 +0800 Subject: [PATCH 2/4] Update ESP32-HUB75-MatrixPanel-I2S-DMA.h --- src/ESP32-HUB75-MatrixPanel-I2S-DMA.h | 62 +++++++++++++++++++++++---- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h index 91e89a6..19696b7 100644 --- a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h +++ b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h @@ -431,11 +431,23 @@ class MatrixPanel_I2S_DMA { uint8_t r, g, b; color565to888(color, r, g, b); startWrite(); - vlineDMA(x, y, h, r, g, b); + switch (rotation) { + case 0: vlineDMA( x, y, h, r, g, b); break; + case 1: hlineDMA( _height - 1 - y - ( h - 1 ), x, h, r, g, b); break; + case 2: vlineDMA( _width - 1 - x, _height - 1 - y - ( h - 1 ), h, r, g, b); break; + case 3: hlineDMA( y, _width - 1 - x, h, r, g, b); break; + } endWrite(); } // rgb888 overload - virtual inline void drawFastVLine(int16_t x, int16_t y, int16_t h, uint8_t r, uint8_t g, uint8_t b){ vlineDMA(x, y, h, r, g, b); }; + virtual inline void drawFastVLine(int16_t x, int16_t y, int16_t h, uint8_t r, uint8_t g, uint8_t b){ + switch (rotation) { + case 0: vlineDMA( x, y, h, r, g, b); break; + case 1: hlineDMA( _height - 1 - y - ( h - 1 ), x, h, r, g, b); break; + case 2: vlineDMA( _width - 1 - x, _height - 1 - y - ( h - 1 ), h, r, g, b); break; + case 3: hlineDMA( y, _width - 1 - x, h, r, g, b); break; + } + }; /** * @brief - override Adafruit's FastHLine @@ -445,11 +457,23 @@ class MatrixPanel_I2S_DMA { uint8_t r, g, b; color565to888(color, r, g, b); startWrite(); - hlineDMA(x, y, w, r, g, b); + switch (rotation) { + case 0: hlineDMA( x, y, w, r, g, b); break; + case 1: vlineDMA( _height - 1 - y, x, w, r, g, b); break; + case 2: hlineDMA( _width - 1 - x - ( w - 1 ), _height - 1 - y, w, r, g, b); break; + case 3: vlineDMA( y, _width - 1 - x - ( w - 1 ), w, r, g, b); break; + } endWrite(); } // rgb888 overload - virtual inline void drawFastHLine(int16_t x, int16_t y, int16_t w, uint8_t r, uint8_t g, uint8_t b){ hlineDMA(x, y, w, r, g, b); }; + virtual inline void drawFastHLine(int16_t x, int16_t y, int16_t w, uint8_t r, uint8_t g, uint8_t b){ + switch (rotation) { + case 0: hlineDMA( x, y, w, r, g, b); break; + case 1: vlineDMA( _height - 1 - y, x, w, r, g, b); break; + case 2: hlineDMA( _width - 1 - x - ( w - 1 ), _height - 1 - y, w, r, g, b); break; + case 3: vlineDMA( y, _width - 1 - x - ( w - 1 ), w, r, g, b); break; + } + }; /** * @brief - override Adafruit's fillRect @@ -459,13 +483,23 @@ class MatrixPanel_I2S_DMA { uint8_t r, g, b; color565to888(color, r, g, b); startWrite(); - fillRectDMA(x, y, w, h, r, g, b); + switch (rotation) { + case 0: fillRectDMA( x, y, w, h, r, g, b); break; + case 1: fillRectDMA( _height - 1 - y - ( h - 1 ), x, h, w, r, g, b); break; + case 2: fillRectDMA( _width - 1 - x - ( w - 1 ), _height - 1 - y - ( h - 1 ), w, h, r, g, b); break; + case 3: fillRectDMA( y, _width - 1 - x - ( w - 1 ), h, w, r, g, b); break; + } endWrite(); } // rgb888 overload virtual inline void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint8_t r, uint8_t g, uint8_t b){ startWrite(); - fillRectDMA(x, y, w, h, r, g, b); + switch (rotation) { + case 0: fillRectDMA( x, y, w, h, r, g, b); break; + case 1: fillRectDMA( _height - 1 - y - ( h - 1 ), x, h, w, r, g, b); break; + case 2: fillRectDMA( _width - 1 - x - ( w - 1 ), _height - 1 - y - ( h - 1 ), w, h, r, g, b); break; + case 3: fillRectDMA( y, _width - 1 - x - ( w - 1 ), h, w, r, g, b); break; + } endWrite(); } #endif @@ -785,8 +819,12 @@ inline void MatrixPanel_I2S_DMA::drawPixel(int16_t x, int16_t y, uint16_t color) { uint8_t r,g,b; color565to888(color,r,g,b); - - updateMatrixDMABuffer( x, y, r, g, b); + switch (rotation) { + case 0: updateMatrixDMABuffer( x, y, r, g, b); break; + case 1: updateMatrixDMABuffer( _height - 1 - y, x, r, g, b); break; + case 2: updateMatrixDMABuffer( _width - 1 - x, _height - 1 - y, r, g, b); break; + case 3: updateMatrixDMABuffer( y, _width - 1 - x, r, g, b); break; + } } inline void MatrixPanel_I2S_DMA::fillScreen(uint16_t color) // adafruit virtual void override @@ -799,7 +837,13 @@ inline void MatrixPanel_I2S_DMA::fillScreen(uint16_t color) // adafruit virtual inline void MatrixPanel_I2S_DMA::drawPixelRGB888(int16_t x, int16_t y, uint8_t r, uint8_t g,uint8_t b) { - updateMatrixDMABuffer( x, y, r, g, b); + switch (rotation) { + case 0: updateMatrixDMABuffer( x, y, r, g, b); break; + case 1: updateMatrixDMABuffer( _height - 1 - y, x, r, g, b); break; + case 2: updateMatrixDMABuffer( _width - 1 - x, _height - 1 - y, r, g, b); break; + case 3: updateMatrixDMABuffer( y, _width - 1 - x, r, g, b); break; + } + } inline void MatrixPanel_I2S_DMA::fillScreenRGB888(uint8_t r, uint8_t g,uint8_t b) From 7bd6c7028f26009d2da7a8f1299a82ecaae1840e Mon Sep 17 00:00:00 2001 From: Kouzerumatsu / Bananafox <46141631+Kouzeru@users.noreply.github.com> Date: Sat, 11 Feb 2023 13:46:34 +0800 Subject: [PATCH 3/4] Update ESP32-HUB75-MatrixPanel-I2S-DMA.h --- src/ESP32-HUB75-MatrixPanel-I2S-DMA.h | 118 ++++++++++++++------------ 1 file changed, 62 insertions(+), 56 deletions(-) diff --git a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h index 19696b7..865b524 100644 --- a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h +++ b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h @@ -431,22 +431,24 @@ class MatrixPanel_I2S_DMA { uint8_t r, g, b; color565to888(color, r, g, b); startWrite(); - switch (rotation) { - case 0: vlineDMA( x, y, h, r, g, b); break; - case 1: hlineDMA( _height - 1 - y - ( h - 1 ), x, h, r, g, b); break; - case 2: vlineDMA( _width - 1 - x, _height - 1 - y - ( h - 1 ), h, r, g, b); break; - case 3: hlineDMA( y, _width - 1 - x, h, r, g, b); break; - } + + int16_t w = 1; + transform( x, y, w, h); + if( h > w ) + vlineDMA( x, y, h, r, g, b); + else + hlineDMA( x, y, w, r, g, b); + endWrite(); } // rgb888 overload virtual inline void drawFastVLine(int16_t x, int16_t y, int16_t h, uint8_t r, uint8_t g, uint8_t b){ - switch (rotation) { - case 0: vlineDMA( x, y, h, r, g, b); break; - case 1: hlineDMA( _height - 1 - y - ( h - 1 ), x, h, r, g, b); break; - case 2: vlineDMA( _width - 1 - x, _height - 1 - y - ( h - 1 ), h, r, g, b); break; - case 3: hlineDMA( y, _width - 1 - x, h, r, g, b); break; - } + int16_t w = 1; + transform( x, y, w, h); + if( h > w ) + vlineDMA( x, y, h, r, g, b); + else + hlineDMA( x, y, w, r, g, b); }; /** @@ -456,23 +458,25 @@ class MatrixPanel_I2S_DMA { virtual void drawFastHLine(int16_t x, int16_t y, int16_t w, uint16_t color){ uint8_t r, g, b; color565to888(color, r, g, b); - startWrite(); - switch (rotation) { - case 0: hlineDMA( x, y, w, r, g, b); break; - case 1: vlineDMA( _height - 1 - y, x, w, r, g, b); break; - case 2: hlineDMA( _width - 1 - x - ( w - 1 ), _height - 1 - y, w, r, g, b); break; - case 3: vlineDMA( y, _width - 1 - x - ( w - 1 ), w, r, g, b); break; - } + startWrite(); + + int16_t h = 1; + transform( x, y, w, h); + if( h > w ) + vlineDMA( x, y, h, r, g, b); + else + hlineDMA( x, y, w, r, g, b); + endWrite(); } // rgb888 overload - virtual inline void drawFastHLine(int16_t x, int16_t y, int16_t w, uint8_t r, uint8_t g, uint8_t b){ - switch (rotation) { - case 0: hlineDMA( x, y, w, r, g, b); break; - case 1: vlineDMA( _height - 1 - y, x, w, r, g, b); break; - case 2: hlineDMA( _width - 1 - x - ( w - 1 ), _height - 1 - y, w, r, g, b); break; - case 3: vlineDMA( y, _width - 1 - x - ( w - 1 ), w, r, g, b); break; - } + virtual inline void drawFastHLine(int16_t x, int16_t y, int16_t w, uint8_t r, uint8_t g, uint8_t b){ + int16_t h = 1; + transform( x, y, w, h); + if( h > w ) + vlineDMA( x, y, h, r, g, b); + else + hlineDMA( x, y, w, r, g, b); }; /** @@ -482,24 +486,16 @@ class MatrixPanel_I2S_DMA { virtual void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color){ uint8_t r, g, b; color565to888(color, r, g, b); - startWrite(); - switch (rotation) { - case 0: fillRectDMA( x, y, w, h, r, g, b); break; - case 1: fillRectDMA( _height - 1 - y - ( h - 1 ), x, h, w, r, g, b); break; - case 2: fillRectDMA( _width - 1 - x - ( w - 1 ), _height - 1 - y - ( h - 1 ), w, h, r, g, b); break; - case 3: fillRectDMA( y, _width - 1 - x - ( w - 1 ), h, w, r, g, b); break; - } + startWrite(); + transform( x, y, w, h); + fillRectDMA( x, y, w, h, r, g, b); endWrite(); } // rgb888 overload virtual inline void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint8_t r, uint8_t g, uint8_t b){ - startWrite(); - switch (rotation) { - case 0: fillRectDMA( x, y, w, h, r, g, b); break; - case 1: fillRectDMA( _height - 1 - y - ( h - 1 ), x, h, w, r, g, b); break; - case 2: fillRectDMA( _width - 1 - x - ( w - 1 ), _height - 1 - y - ( h - 1 ), w, h, r, g, b); break; - case 3: fillRectDMA( y, _width - 1 - x - ( w - 1 ), h, w, r, g, b); break; - } + startWrite(); + transform( x, y, w, h); + fillRectDMA( x, y, w, h, r, g, b); endWrite(); } #endif @@ -795,9 +791,23 @@ class MatrixPanel_I2S_DMA { */ void brtCtrlOEv2(uint8_t brt, const int _buff_id=0); - - - + /** + * @brief - transforms coordinates according to orientation + * @param x - x position origin + * @param y - y position origin + * @param w - rectangular width + * @param h - rectangular height + */ + void transform(int16_t &x, int16_t &y, int16_t &w, int16_t &h){ + #ifndef NO_GFX + int16_t t; + switch (rotation) { + case 1: t = _height - 1 - y - ( h - 1 ); y = x; x = t; t = h; h = w; w = t; return; + case 2: x = _width - 1 - x - ( w - 1 ); y = _height - 1 - y - ( h - 1 ); return; + case 3: t = y; y = _width - 1 - x - ( w - 1 ); x = t; t = h; h = w; w = t; return; + } + #endif + }; }; // end Class header /***************************************************************************************/ @@ -819,12 +829,10 @@ inline void MatrixPanel_I2S_DMA::drawPixel(int16_t x, int16_t y, uint16_t color) { uint8_t r,g,b; color565to888(color,r,g,b); - switch (rotation) { - case 0: updateMatrixDMABuffer( x, y, r, g, b); break; - case 1: updateMatrixDMABuffer( _height - 1 - y, x, r, g, b); break; - case 2: updateMatrixDMABuffer( _width - 1 - x, _height - 1 - y, r, g, b); break; - case 3: updateMatrixDMABuffer( y, _width - 1 - x, r, g, b); break; - } + + int16_t w = 1, h = 1; + transform( x, y, w, h); + updateMatrixDMABuffer( x, y, r, g, b); } inline void MatrixPanel_I2S_DMA::fillScreen(uint16_t color) // adafruit virtual void override @@ -837,13 +845,9 @@ inline void MatrixPanel_I2S_DMA::fillScreen(uint16_t color) // adafruit virtual inline void MatrixPanel_I2S_DMA::drawPixelRGB888(int16_t x, int16_t y, uint8_t r, uint8_t g,uint8_t b) { - switch (rotation) { - case 0: updateMatrixDMABuffer( x, y, r, g, b); break; - case 1: updateMatrixDMABuffer( _height - 1 - y, x, r, g, b); break; - case 2: updateMatrixDMABuffer( _width - 1 - x, _height - 1 - y, r, g, b); break; - case 3: updateMatrixDMABuffer( y, _width - 1 - x, r, g, b); break; - } - + int16_t w = 1, h = 1; + transform( x, y, w, h); + updateMatrixDMABuffer( x, y, r, g, b); } inline void MatrixPanel_I2S_DMA::fillScreenRGB888(uint8_t r, uint8_t g,uint8_t b) @@ -855,6 +859,8 @@ inline void MatrixPanel_I2S_DMA::fillScreenRGB888(uint8_t r, uint8_t g,uint8_t b // Support for CRGB values provided via FastLED inline void MatrixPanel_I2S_DMA::drawPixel(int16_t x, int16_t y, CRGB color) { + int16_t w = 1, h = 1; + transform( x, y, w, h); updateMatrixDMABuffer( x, y, color.red, color.green, color.blue); } From 6cd5c72a239c4622a15c6724d92a37219538304e Mon Sep 17 00:00:00 2001 From: mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> Date: Sun, 19 Feb 2023 16:47:52 +1000 Subject: [PATCH 4/4] Update ESP32-VirtualMatrixPanel-I2S-DMA.h --- src/ESP32-VirtualMatrixPanel-I2S-DMA.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h index ea49388..cf5324a 100644 --- a/src/ESP32-VirtualMatrixPanel-I2S-DMA.h +++ b/src/ESP32-VirtualMatrixPanel-I2S-DMA.h @@ -11,14 +11,14 @@ However, the function of this class has expanded now to also manage the output for - 1) HALF scan panels = Two rows updated in parallel. - * 64px high panel = (incorrectly) referred to as 1/32 scan - * 32px high panel = (incorrectly) referred to as 1/16 scan - * 16px high panel = (incorrectly) referred to as 1/8 scan + 1) TWO scan panels = Two rows updated in parallel. + * 64px high panel = sometimes referred to as 1/32 scan + * 32px high panel = sometimes referred to as 1/16 scan + * 16px high panel = sometimes referred to as 1/8 scan 2) FOUR scan panels = Four rows updated in parallel - * 32px high panel = (incorrectly) referred to as 1/8 scan - * 16px high panel = (incorrectly) referred to as 1/4 scan + * 32px high panel = sometimes referred to as 1/8 scan + * 16px high panel = sometimes referred to as 1/4 scan YouTube: https://www.youtube.com/brianlough Tindie: https://www.tindie.com/stores/brianlough/