Addition of faster fillScreen function
Addition of a function to wipe the entire DMA buffer / screen with a single color in a quicker manner.
This commit is contained in:
parent
61b3276894
commit
45652d0d52
2 changed files with 125 additions and 6 deletions
|
@ -169,6 +169,7 @@ void RGB64x32MatrixPanel_I2S_DMA::configureDMA()
|
|||
|
||||
} // end initMatrixDMABuff
|
||||
|
||||
/* Update a specific co-ordinate in the DMA buffer */
|
||||
void RGB64x32MatrixPanel_I2S_DMA::updateMatrixDMABuffer(int16_t x_coord, int16_t y_coord, uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
|
||||
|
@ -312,9 +313,112 @@ void RGB64x32MatrixPanel_I2S_DMA::updateMatrixDMABuffer(int16_t x_coord, int16_t
|
|||
i2s_parallel_flip_to_buffer(&I2S1, backbuf_id);
|
||||
//swapBuffer();
|
||||
|
||||
} // updateDMABuffer
|
||||
|
||||
|
||||
/* Update the entire buffer with a single specific colour - quicker */
|
||||
void RGB64x32MatrixPanel_I2S_DMA::updateMatrixDMABuffer(uint8_t red, uint8_t green, uint8_t blue)
|
||||
{
|
||||
|
||||
for (unsigned int y_coord = 0; y_coord < ROWS_PER_FRAME; y_coord++) // half height - 16 iterations
|
||||
{
|
||||
for(int color_depth_idx=0; color_depth_idx<COLOR_DEPTH_BITS; color_depth_idx++) // color depth - 8 iterations
|
||||
{
|
||||
uint16_t mask = (1 << color_depth_idx); // 24 bit color
|
||||
|
||||
// The destination for the pixel bitstream
|
||||
rowBitStruct *p = &matrixUpdateFrames[backbuf_id].rowdata[y_coord].rowbits[color_depth_idx]; //matrixUpdateFrames location to write to uint16_t's
|
||||
|
||||
for(int x_coord=0; x_coord < MATRIX_WIDTH; x_coord++) // row pixel width 64 iterations
|
||||
{
|
||||
|
||||
int v=0; // the output bitstream
|
||||
|
||||
// if there is no latch to hold address, output ADDX lines directly to GPIO and latch data at end of cycle
|
||||
int gpioRowAddress = y_coord;
|
||||
|
||||
// normally output current rows ADDX, special case for LSB, output previous row's ADDX (as previous row is being displayed for one latch cycle)
|
||||
if(color_depth_idx == 0)
|
||||
gpioRowAddress = y_coord-1;
|
||||
|
||||
if (gpioRowAddress & 0x01) v|=BIT_A; // 1
|
||||
if (gpioRowAddress & 0x02) v|=BIT_B; // 2
|
||||
if (gpioRowAddress & 0x04) v|=BIT_C; // 4
|
||||
if (gpioRowAddress & 0x08) v|=BIT_D; // 8
|
||||
if (gpioRowAddress & 0x10) v|=BIT_E; // 16
|
||||
|
||||
// need to disable OE after latch to hide row transition
|
||||
if((x_coord) == 0) v|=BIT_OE;
|
||||
|
||||
// drive latch while shifting out last bit of RGB data
|
||||
if((x_coord) == PIXELS_PER_LATCH-1) v|=BIT_LAT;
|
||||
|
||||
// turn off OE after brightness value is reached when displaying MSBs
|
||||
// MSBs always output normal brightness
|
||||
// LSB (!color_depth_idx) outputs normal brightness as MSB from previous row is being displayed
|
||||
if((color_depth_idx > lsbMsbTransitionBit || !color_depth_idx) && ((x_coord) >= brightness)) v|=BIT_OE; // For Brightness
|
||||
|
||||
// special case for the bits *after* LSB through (lsbMsbTransitionBit) - OE is output after data is shifted, so need to set OE to fractional brightness
|
||||
if(color_depth_idx && color_depth_idx <= lsbMsbTransitionBit) {
|
||||
// divide brightness in half for each bit below lsbMsbTransitionBit
|
||||
int lsbBrightness = brightness >> (lsbMsbTransitionBit - color_depth_idx + 1);
|
||||
if((x_coord) >= lsbBrightness) v|=BIT_OE; // For Brightness
|
||||
}
|
||||
|
||||
// need to turn off OE one clock before latch, otherwise can get ghosting
|
||||
if((x_coord)==PIXELS_PER_LATCH-1) v|=BIT_OE;
|
||||
|
||||
|
||||
// Top half colours
|
||||
if (green & mask)
|
||||
v|=BIT_G1;
|
||||
if (blue & mask)
|
||||
v|=BIT_B1;
|
||||
if (red & mask)
|
||||
v|=BIT_R1;
|
||||
|
||||
// Bottom half colours
|
||||
if (red & mask)
|
||||
v|=BIT_R2;
|
||||
if (green & mask)
|
||||
v|=BIT_G2;
|
||||
if (blue & mask)
|
||||
v|=BIT_B2;
|
||||
|
||||
|
||||
// 16 bit parallel mode
|
||||
//Save the calculated value to the bitplane memory in reverse order to account for I2S Tx FIFO mode1 ordering
|
||||
if(x_coord%2)
|
||||
{
|
||||
p->data[(x_coord)-1] = v;
|
||||
} else {
|
||||
p->data[(x_coord)+1] = v;
|
||||
} // end reordering
|
||||
|
||||
} // end x_coord iteration
|
||||
} // colour depth loop (8)
|
||||
} // end row iteration
|
||||
|
||||
//Show our work!
|
||||
i2s_parallel_flip_to_buffer(&I2S1, backbuf_id);
|
||||
swapBuffer();
|
||||
|
||||
} // updateDMABuffer
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// WORK IN PROGRESS
|
||||
void RGB64x32MatrixPanel_I2S_DMA::writeRGB24Frame2DMABuffer(rgb_24 *framedata, int16_t frame_width = MATRIX_WIDTH, int16_t frame_height = MATRIX_HEIGHT)
|
||||
|
|
|
@ -171,7 +171,7 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
|
|||
allocateDMAbuffers();
|
||||
|
||||
backbuf_id = 0;
|
||||
brightness = 64; // default to max brightness, wear sunglasses when looking directly at panel.
|
||||
brightness = 32; // default to max brightness, wear sunglasses when looking directly at panel.
|
||||
|
||||
}
|
||||
|
||||
|
@ -185,9 +185,13 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
|
|||
swapBuffer();
|
||||
}
|
||||
|
||||
// TODO: Disable/Enable auto buffer flipping (useful for lots of drawPixel usage)...
|
||||
|
||||
|
||||
// Draw pixels
|
||||
virtual void drawPixel(int16_t x, int16_t y, uint16_t color); // adafruit implementation
|
||||
virtual void drawPixel(int16_t x, int16_t y, uint16_t color); // overwrite adafruit implementation
|
||||
virtual void fillScreen(uint16_t color); // overwrite adafruit implementation
|
||||
void clearScreen() { fillScreen(0); }
|
||||
inline void drawPixelRGB565(int16_t x, int16_t y, uint16_t color);
|
||||
inline void drawPixelRGB888(int16_t x, int16_t y, uint8_t r, uint8_t g, uint8_t b);
|
||||
inline void drawPixelRGB24(int16_t x, int16_t y, rgb_24 color);
|
||||
|
@ -236,9 +240,11 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
|
|||
void configureDMA(); // Get everything setup. Refer to the .c file
|
||||
|
||||
|
||||
// Paint a pixel to the DMA buffer directly
|
||||
// Update a specific pixel in the DMA buffer a colour
|
||||
void updateMatrixDMABuffer(int16_t x, int16_t y, uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
// Update the entire DMA buffer a certain colour (wipe the screen basically)
|
||||
void updateMatrixDMABuffer(uint8_t red, uint8_t green, uint8_t blue);
|
||||
|
||||
// Internal variables
|
||||
bool dma_configuration_success;
|
||||
|
@ -257,11 +263,20 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
|
|||
|
||||
/***************************************************************************************/
|
||||
|
||||
inline void RGB64x32MatrixPanel_I2S_DMA::drawPixel(int16_t x, int16_t y, uint16_t color)
|
||||
inline void RGB64x32MatrixPanel_I2S_DMA::drawPixel(int16_t x, int16_t y, uint16_t color) // adafruit virtual void override
|
||||
{
|
||||
drawPixelRGB565( x, y, color);
|
||||
}
|
||||
|
||||
inline void RGB64x32MatrixPanel_I2S_DMA::fillScreen(uint16_t color) // adafruit virtual void override
|
||||
{
|
||||
uint8_t r = ((((color >> 11) & 0x1F) * 527) + 23) >> 6;
|
||||
uint8_t g = ((((color >> 5) & 0x3F) * 259) + 33) >> 6;
|
||||
uint8_t b = (((color & 0x1F) * 527) + 23) >> 6;
|
||||
|
||||
updateMatrixDMABuffer(r, g, b); // the RGB only (no pixel coordinate) version of 'updateMatrixDMABuffer'
|
||||
}
|
||||
|
||||
// For adafruit
|
||||
inline void RGB64x32MatrixPanel_I2S_DMA::drawPixelRGB565(int16_t x, int16_t y, uint16_t color)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue