From c25557990e6eeb1393d8e68b5a8825adbbefb25d Mon Sep 17 00:00:00 2001 From: mrfaptastic <12006953+mrfaptastic@users.noreply.github.com> Date: Thu, 10 Jun 2021 15:59:31 +0100 Subject: [PATCH] Update ESP32-HUB75-MatrixPanel-I2S-DMA.cpp --- ESP32-HUB75-MatrixPanel-I2S-DMA.cpp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp b/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp index 9aeecc7..1a202e3 100644 --- a/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp +++ b/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp @@ -76,6 +76,7 @@ #define COLOR_DEPTH_LESS_THAN_8BIT_ADJUST // Nothing to adjust. #endif + bool MatrixPanel_I2S_DMA::allocateDMAmemory() { @@ -511,7 +512,12 @@ void IRAM_ATTR MatrixPanel_I2S_DMA::updateMatrixDMABuffer(int16_t x_coord, int16 uint8_t color_depth_idx = PIXEL_COLOR_DEPTH_BITS; do { --color_depth_idx; - uint8_t mask = (1 << (color_depth_idx COLOR_DEPTH_LESS_THAN_8BIT_ADJUST)); // expect 24 bit color (8 bits per RGB subpixel) +// uint8_t mask = (1 << (color_depth_idx COLOR_DEPTH_LESS_THAN_8BIT_ADJUST)); // expect 24 bit color (8 bits per RGB subpixel) + #if PIXEL_COLOR_DEPTH_BITS < 8 + uint8_t mask = (1 << (color_depth_idx+(8-PIXEL_COLOR_DEPTH_BITS))); // expect 24 bit color (8 bits per RGB subpixel) + #else + uint8_t mask = (1 << (color_depth_idx)); // expect 24 bit color (8 bits per RGB subpixel) + #endif uint16_t RGB_output_bits = 0; /* Per the .h file, the order of the output RGB bits is: @@ -553,7 +559,12 @@ void MatrixPanel_I2S_DMA::updateMatrixDMABuffer(uint8_t red, uint8_t green, uint { // let's precalculate RGB1 and RGB2 bits than flood it over the entire DMA buffer uint16_t RGB_output_bits = 0; - uint8_t mask = (1 << color_depth_idx COLOR_DEPTH_LESS_THAN_8BIT_ADJUST); // 24 bit color +// uint8_t mask = (1 << color_depth_idx COLOR_DEPTH_LESS_THAN_8BIT_ADJUST); // 24 bit color + #if PIXEL_COLOR_DEPTH_BITS < 8 + uint8_t mask = (1 << (color_depth_idx+(8-PIXEL_COLOR_DEPTH_BITS))); // expect 24 bit color (8 bits per RGB subpixel) + #else + uint8_t mask = (1 << (color_depth_idx)); // expect 24 bit color (8 bits per RGB subpixel) + #endif /* Per the .h file, the order of the output RGB bits is: * BIT_B2, BIT_G2, BIT_R2, BIT_B1, BIT_G1, BIT_R1 */ @@ -797,7 +808,12 @@ void MatrixPanel_I2S_DMA::hlineDMA(int16_t x_coord, int16_t y_coord, int16_t l, // let's precalculate RGB1 and RGB2 bits than flood it over the entire DMA buffer uint16_t RGB_output_bits = 0; - uint8_t mask = (1 << color_depth_idx COLOR_DEPTH_LESS_THAN_8BIT_ADJUST); +// uint8_t mask = (1 << color_depth_idx COLOR_DEPTH_LESS_THAN_8BIT_ADJUST); + #if PIXEL_COLOR_DEPTH_BITS < 8 + uint8_t mask = (1 << (color_depth_idx+(8-PIXEL_COLOR_DEPTH_BITS))); // expect 24 bit color (8 bits per RGB subpixel) + #else + uint8_t mask = (1 << (color_depth_idx)); // expect 24 bit color (8 bits per RGB subpixel) + #endif /* Per the .h file, the order of the output RGB bits is: * BIT_B2, BIT_G2, BIT_R2, BIT_B1, BIT_G1, BIT_R1 */ @@ -859,7 +875,12 @@ void MatrixPanel_I2S_DMA::vlineDMA(int16_t x_coord, int16_t y_coord, int16_t l, --color_depth_idx; // let's precalculate RGB1 and RGB2 bits than flood it over the entire DMA buffer - uint8_t mask = (1 << color_depth_idx COLOR_DEPTH_LESS_THAN_8BIT_ADJUST); +// uint8_t mask = (1 << color_depth_idx COLOR_DEPTH_LESS_THAN_8BIT_ADJUST); + #if PIXEL_COLOR_DEPTH_BITS < 8 + uint8_t mask = (1 << (color_depth_idx+(8-PIXEL_COLOR_DEPTH_BITS))); // expect 24 bit color (8 bits per RGB subpixel) + #else + uint8_t mask = (1 << (color_depth_idx)); // expect 24 bit color (8 bits per RGB subpixel) + #endif uint16_t RGB_output_bits = 0; /* Per the .h file, the order of the output RGB bits is: