minor fixes and comments
Signed-off-by: Emil Muratov <gpm@hotplug.ru>
This commit is contained in:
parent
33b95f534f
commit
05d196d188
2 changed files with 20 additions and 17 deletions
|
@ -200,14 +200,17 @@ bool MatrixPanel_I2S_DMA::allocateDMAmemory()
|
||||||
for(int i=lsbMsbTransitionBit + 1; i<PIXEL_COLOR_DEPTH_BITS; i++) {
|
for(int i=lsbMsbTransitionBit + 1; i<PIXEL_COLOR_DEPTH_BITS; i++) {
|
||||||
numDMAdescriptorsPerRow += (1<<(i - lsbMsbTransitionBit - 1));
|
numDMAdescriptorsPerRow += (1<<(i - lsbMsbTransitionBit - 1));
|
||||||
}
|
}
|
||||||
|
#if SERIAL_DEBUG
|
||||||
|
Serial.printf("Recalculated number of DMA descriptors per row: %d\n", numDMAdescriptorsPerRow);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Refer to 'DMA_LL_PAYLOAD_SPLIT' code in configureDMA() below to understand why this exists.
|
// Refer to 'DMA_LL_PAYLOAD_SPLIT' code in configureDMA() below to understand why this exists.
|
||||||
// numDMAdescriptorsPerRow is also used to calcaulte descount which is super important in i2s_parallel_config_t SoC DMA setup.
|
// numDMAdescriptorsPerRow is also used to calcaulte descount which is super important in i2s_parallel_config_t SoC DMA setup.
|
||||||
if ( sizeof(rowColorDepthStruct) > DMA_MAX ) {
|
if ( sizeof(rowColorDepthStruct) > DMA_MAX ) {
|
||||||
|
|
||||||
#if SERIAL_DEBUG
|
#if SERIAL_DEBUG
|
||||||
Serial.println("Split DMA payload required.");
|
Serial.printf("rowColorDepthStruct struct is too large, split DMA payload required. Adding %d DMA descriptors\n", PIXEL_COLOR_DEPTH_BITS-1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
numDMAdescriptorsPerRow += PIXEL_COLOR_DEPTH_BITS-1;
|
numDMAdescriptorsPerRow += PIXEL_COLOR_DEPTH_BITS-1;
|
||||||
// Not if numDMAdescriptorsPerRow is even just one descriptor too large, DMA linked list will not correctly loop.
|
// Not if numDMAdescriptorsPerRow is even just one descriptor too large, DMA linked list will not correctly loop.
|
||||||
|
@ -273,7 +276,7 @@ bool MatrixPanel_I2S_DMA::allocateDMAmemory()
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} // end initMatrixDMABuffer()
|
} // end allocateDMAmemory()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -301,7 +304,7 @@ void MatrixPanel_I2S_DMA::configureDMA(int r1_pin, int g1_pin, int b1_pin, int
|
||||||
rowColorDepthStruct *fb_malloc_ptr = matrix_row_framebuffer_malloc[row];
|
rowColorDepthStruct *fb_malloc_ptr = matrix_row_framebuffer_malloc[row];
|
||||||
|
|
||||||
#if SERIAL_DEBUG
|
#if SERIAL_DEBUG
|
||||||
Serial.printf("DMA payload of %d bytes. DMA_MAX is %d.\r\n", sizeof(rowBitStruct) * PIXEL_COLOR_DEPTH_BITS, DMA_MAX);
|
Serial.printf("Row %d DMA payload of %d bytes. DMA_MAX is %d.\r\n", row, sizeof(rowBitStruct) * PIXEL_COLOR_DEPTH_BITS, DMA_MAX);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -389,13 +392,6 @@ void MatrixPanel_I2S_DMA::configureDMA(int r1_pin, int g1_pin, int b1_pin, int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
//End markers
|
|
||||||
dmadesc_a[desccount-1].eof = 1;
|
|
||||||
dmadesc_b[desccount-1].eof = 1;
|
|
||||||
dmadesc_a[desccount-1].qe.stqe_next=(lldesc_t*)&dmadesc_a[0];
|
|
||||||
dmadesc_b[desccount-1].qe.stqe_next=(lldesc_t*)&dmadesc_b[0];
|
|
||||||
*/
|
|
||||||
//Serial.printf("Performing I2S setup.\n");
|
//Serial.printf("Performing I2S setup.\n");
|
||||||
|
|
||||||
i2s_parallel_config_t cfg={
|
i2s_parallel_config_t cfg={
|
||||||
|
@ -655,6 +651,7 @@ void MatrixPanel_I2S_DMA::updateMatrixDMABuffer(uint8_t red, uint8_t green, uint
|
||||||
*/
|
*/
|
||||||
void MatrixPanel_I2S_DMA::shiftDriver(const shift_driver _drv, const int dma_r1_pin, const int dma_g1_pin, const int dma_b1_pin, const int dma_r2_pin, const int dma_g2_pin, const int dma_b2_pin, const int dma_a_pin, const int dma_b_pin, const int dma_c_pin, const int dma_d_pin, const int dma_e_pin, const int dma_lat_pin, const int dma_oe_pin, const int dma_clk_pin){
|
void MatrixPanel_I2S_DMA::shiftDriver(const shift_driver _drv, const int dma_r1_pin, const int dma_g1_pin, const int dma_b1_pin, const int dma_r2_pin, const int dma_g2_pin, const int dma_b2_pin, const int dma_a_pin, const int dma_b_pin, const int dma_c_pin, const int dma_d_pin, const int dma_e_pin, const int dma_lat_pin, const int dma_oe_pin, const int dma_clk_pin){
|
||||||
switch (_drv){
|
switch (_drv){
|
||||||
|
case ICN2038S:
|
||||||
case FM6124:
|
case FM6124:
|
||||||
case FM6126A:
|
case FM6126A:
|
||||||
{
|
{
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
|
|
||||||
// RGB Panel Constants / Calculated Values
|
// RGB Panel Constants / Calculated Values
|
||||||
#define COLOR_CHANNELS_PER_PIXEL 3
|
#define COLOR_CHANNELS_PER_PIXEL 3
|
||||||
#define PIXELS_PER_ROW ((MATRIX_WIDTH * MATRIX_HEIGHT) / MATRIX_HEIGHT) // = 64
|
#define PIXELS_PER_ROW MATRIX_WIDTH // number of all pixels in a row of chained modules
|
||||||
//#define PIXEL_COLOR_DEPTH_BITS (MATRIX_COLOR_DEPTH/COLOR_CHANNELS_PER_PIXEL) // = 8
|
//#define PIXEL_COLOR_DEPTH_BITS (MATRIX_COLOR_DEPTH/COLOR_CHANNELS_PER_PIXEL) // = 8
|
||||||
#define ROWS_PER_FRAME (MATRIX_HEIGHT/MATRIX_ROWS_IN_PARALLEL) // = 16
|
#define ROWS_PER_FRAME (MATRIX_HEIGHT/MATRIX_ROWS_IN_PARALLEL) // = 16
|
||||||
|
|
||||||
|
@ -169,13 +169,17 @@ typedef struct RGB24 {
|
||||||
uint8_t blue;
|
uint8_t blue;
|
||||||
} RGB24;
|
} RGB24;
|
||||||
|
|
||||||
enum shift_driver {SHIFT=0, FM6124, FM6126A};
|
/**
|
||||||
|
* Enumeration of hardware-specific chips
|
||||||
|
* used to drive matrix modules
|
||||||
|
*/
|
||||||
|
enum shift_driver {SHIFT=0, FM6124, FM6126A, ICN2038S};
|
||||||
|
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
// Used by val2PWM
|
// Used by val2PWM
|
||||||
//C/p'ed from https://ledshield.wordpress.com/2012/11/13/led-brightness-to-your-eye-gamma-correction-no/
|
//C/p'ed from https://ledshield.wordpress.com/2012/11/13/led-brightness-to-your-eye-gamma-correction-no/
|
||||||
// Example calculator: https://gist.github.com/mathiasvr/19ce1d7b6caeab230934080ae1f1380e
|
// Example calculator: https://gist.github.com/mathiasvr/19ce1d7b6caeab230934080ae1f1380e
|
||||||
const uint16_t lumConvTab[]={
|
const uint8_t lumConvTab[]={
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 30, 30, 31, 31, 32, 33, 33, 34, 35, 35, 36, 37, 38, 38, 39, 40, 41, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 51, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 86, 87, 88, 90, 91, 92, 93, 95, 96, 98, 99, 100, 102, 103, 105, 106, 107, 109, 110, 112, 113, 115, 116, 118, 120, 121, 123, 124, 126, 128, 129, 131, 133, 134, 136, 138, 139, 141, 143, 145, 146, 148, 150, 152, 154, 156, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 192, 194, 196, 198, 200, 203, 205, 207, 209, 212, 214, 216, 218, 221, 223, 226, 228, 230, 233, 235, 238, 240, 243, 245, 248, 250, 253, 255, 255};
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 27, 27, 28, 28, 29, 30, 30, 31, 31, 32, 33, 33, 34, 35, 35, 36, 37, 38, 38, 39, 40, 41, 41, 42, 43, 44, 45, 45, 46, 47, 48, 49, 50, 51, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 86, 87, 88, 90, 91, 92, 93, 95, 96, 98, 99, 100, 102, 103, 105, 106, 107, 109, 110, 112, 113, 115, 116, 118, 120, 121, 123, 124, 126, 128, 129, 131, 133, 134, 136, 138, 139, 141, 143, 145, 146, 148, 150, 152, 154, 156, 157, 159, 161, 163, 165, 167, 169, 171, 173, 175, 177, 179, 181, 183, 185, 187, 189, 192, 194, 196, 198, 200, 203, 205, 207, 209, 212, 214, 216, 218, 221, 223, 226, 228, 230, 233, 235, 238, 240, 243, 245, 248, 250, 253, 255, 255};
|
||||||
|
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
|
@ -237,9 +241,11 @@ class MatrixPanel_I2S_DMA : public Adafruit_GFX {
|
||||||
|
|
||||||
// Flush the DMA buffers prior to configuring DMA - Avoid visual artefacts on boot.
|
// Flush the DMA buffers prior to configuring DMA - Avoid visual artefacts on boot.
|
||||||
clearScreen(); // Must fill the DMA buffer with the initial output bit sequence or the panel will display garbage
|
clearScreen(); // Must fill the DMA buffer with the initial output bit sequence or the panel will display garbage
|
||||||
flipDMABuffer(); // flip to backbuffer 1
|
if (double_buffering_enabled){
|
||||||
clearScreen(); // Must fill the DMA buffer with the initial output bit sequence or the panel will display garbage
|
flipDMABuffer(); // flip to backbuffer 1
|
||||||
flipDMABuffer(); // backbuffer 0
|
clearScreen(); // Must fill the DMA buffer with the initial output bit sequence or the panel will display garbage
|
||||||
|
flipDMABuffer(); // backbuffer 0
|
||||||
|
}
|
||||||
|
|
||||||
// Setup the ESP32 DMA Engine. Sprite_TM built this stuff.
|
// Setup the ESP32 DMA Engine. Sprite_TM built this stuff.
|
||||||
configureDMA(dma_r1_pin, dma_g1_pin, dma_b1_pin, dma_r2_pin, dma_g2_pin, dma_b2_pin, dma_a_pin, dma_b_pin, dma_c_pin, dma_d_pin, dma_e_pin, dma_lat_pin, dma_oe_pin, dma_clk_pin ); //DMA and I2S configuration and setup
|
configureDMA(dma_r1_pin, dma_g1_pin, dma_b1_pin, dma_r2_pin, dma_g2_pin, dma_b2_pin, dma_a_pin, dma_b_pin, dma_c_pin, dma_d_pin, dma_e_pin, dma_lat_pin, dma_oe_pin, dma_clk_pin ); //DMA and I2S configuration and setup
|
||||||
|
|
Loading…
Reference in a new issue