diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp | 3 | ||||
| -rw-r--r-- | src/ESP32-HUB75-MatrixPanel-I2S-DMA.h | 74 | ||||
| -rw-r--r-- | src/ESP32-VirtualMatrixPanel-I2S-DMA.h | 12 |
3 files changed, 70 insertions, 19 deletions
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); diff --git a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h index 91e89a6..865b524 100644 --- a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h +++ b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h @@ -431,11 +431,25 @@ class MatrixPanel_I2S_DMA { uint8_t r, g, b; color565to888(color, r, g, b); startWrite(); - vlineDMA(x, y, h, r, g, b); + + 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){ 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){ + 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); + }; /** * @brief - override Adafruit's FastHLine @@ -444,12 +458,26 @@ 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(); - hlineDMA(x, y, w, r, g, b); + 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){ 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){ + 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); + }; /** * @brief - override Adafruit's fillRect @@ -458,14 +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(); - fillRectDMA(x, y, w, h, r, g, b); + 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(); - fillRectDMA(x, y, w, h, r, g, b); + startWrite(); + transform( x, y, w, h); + fillRectDMA( x, y, w, h, r, g, b); endWrite(); } #endif @@ -761,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 /***************************************************************************************/ @@ -786,6 +830,8 @@ 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); + int16_t w = 1, h = 1; + transform( x, y, w, h); updateMatrixDMABuffer( x, y, r, g, b); } @@ -799,6 +845,8 @@ 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) { + int16_t w = 1, h = 1; + transform( x, y, w, h); updateMatrixDMABuffer( x, y, r, g, b); } @@ -811,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); } 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/ |
