This commit is contained in:
mrfaptastic 2023-02-19 17:50:22 +10:00
commit b262ddeaa1
3 changed files with 70 additions and 19 deletions

View file

@ -715,7 +715,8 @@ void MatrixPanel_I2S_DMA::brtCtrlOEv2(uint8_t brt, const int _buff_id) {
char rightshift = std::max( bitplane - bitshift - 2, 0 ); char rightshift = std::max( bitplane - bitshift - 2, 0 );
// calculate the OE disable period by brightness, and also blanking // 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 // 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); ESP32_I2S_DMA_STORAGE_TYPE* row = dma_buff.rowBits[row_idx]->getDataPtr(colouridx, _buff_id);

View file

@ -431,11 +431,25 @@ class MatrixPanel_I2S_DMA {
uint8_t r, g, b; uint8_t r, g, b;
color565to888(color, r, g, b); color565to888(color, r, g, b);
startWrite(); 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(); endWrite();
} }
// rgb888 overload // 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 * @brief - override Adafruit's FastHLine
@ -445,11 +459,25 @@ class MatrixPanel_I2S_DMA {
uint8_t r, g, b; uint8_t r, g, b;
color565to888(color, r, g, b); color565to888(color, r, g, b);
startWrite(); startWrite();
hlineDMA(x, y, w, r, g, 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);
endWrite(); endWrite();
} }
// rgb888 overload // 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 * @brief - override Adafruit's fillRect
@ -459,13 +487,15 @@ class MatrixPanel_I2S_DMA {
uint8_t r, g, b; uint8_t r, g, b;
color565to888(color, r, g, b); color565to888(color, r, g, b);
startWrite(); startWrite();
fillRectDMA(x, y, w, h, r, g, b); transform( x, y, w, h);
fillRectDMA( x, y, w, h, r, g, b);
endWrite(); endWrite();
} }
// rgb888 overload // 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){ 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(); startWrite();
fillRectDMA(x, y, w, h, r, g, b); transform( x, y, w, h);
fillRectDMA( x, y, w, h, r, g, b);
endWrite(); endWrite();
} }
#endif #endif
@ -761,9 +791,23 @@ class MatrixPanel_I2S_DMA {
*/ */
void brtCtrlOEv2(uint8_t brt, const int _buff_id=0); 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 }; // 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; uint8_t r,g,b;
color565to888(color,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); 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) 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); 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 // Support for CRGB values provided via FastLED
inline void MatrixPanel_I2S_DMA::drawPixel(int16_t x, int16_t y, CRGB color) 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); updateMatrixDMABuffer( x, y, color.red, color.green, color.blue);
} }

View file

@ -11,14 +11,14 @@
However, the function of this class has expanded now to also manage However, the function of this class has expanded now to also manage
the output for the output for
1) HALF scan panels = Two rows updated in parallel. 1) TWO scan panels = Two rows updated in parallel.
* 64px high panel = (incorrectly) referred to as 1/32 scan * 64px high panel = sometimes referred to as 1/32 scan
* 32px high panel = (incorrectly) referred to as 1/16 scan * 32px high panel = sometimes referred to as 1/16 scan
* 16px high panel = (incorrectly) referred to as 1/8 scan * 16px high panel = sometimes referred to as 1/8 scan
2) FOUR scan panels = Four rows updated in parallel 2) FOUR scan panels = Four rows updated in parallel
* 32px high panel = (incorrectly) referred to as 1/8 scan * 32px high panel = sometimes referred to as 1/8 scan
* 16px high panel = (incorrectly) referred to as 1/4 scan * 16px high panel = sometimes referred to as 1/4 scan
YouTube: https://www.youtube.com/brianlough YouTube: https://www.youtube.com/brianlough
Tindie: https://www.tindie.com/stores/brianlough/ Tindie: https://www.tindie.com/stores/brianlough/