Added ability to define custom pin mappings
Closes issue #4 Use something like: ' display.begin(R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, LAT_PIN, OE_PIN, CLK_PIN ); // setup the LED matrix' with R1_PIN etc. referring to your own define or constant variables
This commit is contained in:
parent
45652d0d52
commit
21f8bbba45
2 changed files with 59 additions and 21 deletions
|
@ -3,7 +3,7 @@
|
||||||
// Credits: Louis Beaudoin <https://github.com/pixelmatix/SmartMatrix/tree/teensylc>
|
// Credits: Louis Beaudoin <https://github.com/pixelmatix/SmartMatrix/tree/teensylc>
|
||||||
// and Sprite_TM: https://www.esp32.com/viewtopic.php?f=17&t=3188 and https://www.esp32.com/viewtopic.php?f=13&t=3256
|
// and Sprite_TM: https://www.esp32.com/viewtopic.php?f=17&t=3188 and https://www.esp32.com/viewtopic.php?f=13&t=3256
|
||||||
|
|
||||||
void RGB64x32MatrixPanel_I2S_DMA::configureDMA()
|
void RGB64x32MatrixPanel_I2S_DMA::configureDMA(int r1_pin, int g1_pin, int b1_pin, int r2_pin, int g2_pin, int b2_pin, int a_pin, int b_pin, int c_pin, int d_pin, int e_pin, int lat_pin, int oe_pin, int clk_pin)
|
||||||
{
|
{
|
||||||
// calculate the lowest LSBMSB_TRANSITION_BIT value that will fit in memory
|
// calculate the lowest LSBMSB_TRANSITION_BIT value that will fit in memory
|
||||||
int numDescriptorsPerRow;
|
int numDescriptorsPerRow;
|
||||||
|
@ -146,9 +146,26 @@ void RGB64x32MatrixPanel_I2S_DMA::configureDMA()
|
||||||
|
|
||||||
Serial.printf("Performing I2S setup.\n");
|
Serial.printf("Performing I2S setup.\n");
|
||||||
|
|
||||||
|
/*
|
||||||
i2s_parallel_config_t cfg={
|
i2s_parallel_config_t cfg={
|
||||||
.gpio_bus={R1_PIN, G1_PIN, B1_PIN, R2_PIN, G2_PIN, B2_PIN, LAT_PIN, OE_PIN, A_PIN, B_PIN, C_PIN, D_PIN, E_PIN, -1, -1, -1},
|
.gpio_bus={R1_PIN_DEFAULT, G1_PIN_DEFAULT, B1_PIN_DEFAULT, R2_PIN_DEFAULT, G2_PIN_DEFAULT, B2_PIN_DEFAULT, LAT_PIN_DEFAULT, OE_PIN_DEFAULT, A_PIN_DEFAULT, B_PIN_DEFAULT, C_PIN_DEFAULT, D_PIN_DEFAULT, E_PIN_DEFAULT, -1, -1, -1},
|
||||||
.gpio_clk=CLK_PIN,
|
.gpio_clk=CLK_PIN_DEFAULT,
|
||||||
|
.clkspeed_hz=ESP32_I2S_CLOCK_SPEED, //ESP32_I2S_CLOCK_SPEED, // formula used is 80000000L/(cfg->clkspeed_hz + 1), must result in >=2. Acceptable values 26.67MHz, 20MHz, 16MHz, 13.34MHz...
|
||||||
|
.bits=MATRIX_I2S_MODE, //MATRIX_I2S_MODE,
|
||||||
|
.bufa=0,
|
||||||
|
.bufb=0,
|
||||||
|
desccount,
|
||||||
|
desccount,
|
||||||
|
dmadesc_a,
|
||||||
|
dmadesc_b
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
i2s_parallel_config_t cfg={
|
||||||
|
.gpio_bus={r1_pin, g1_pin, b1_pin, r2_pin, g2_pin, b2_pin, lat_pin, oe_pin, a_pin, b_pin, c_pin, d_pin, e_pin, -1, -1, -1},
|
||||||
|
.gpio_clk=clk_pin,
|
||||||
.clkspeed_hz=ESP32_I2S_CLOCK_SPEED, //ESP32_I2S_CLOCK_SPEED, // formula used is 80000000L/(cfg->clkspeed_hz + 1), must result in >=2. Acceptable values 26.67MHz, 20MHz, 16MHz, 13.34MHz...
|
.clkspeed_hz=ESP32_I2S_CLOCK_SPEED, //ESP32_I2S_CLOCK_SPEED, // formula used is 80000000L/(cfg->clkspeed_hz + 1), must result in >=2. Acceptable values 26.67MHz, 20MHz, 16MHz, 13.34MHz...
|
||||||
.bits=MATRIX_I2S_MODE, //MATRIX_I2S_MODE,
|
.bits=MATRIX_I2S_MODE, //MATRIX_I2S_MODE,
|
||||||
.bufa=0,
|
.bufa=0,
|
||||||
|
|
|
@ -69,23 +69,23 @@
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
/* ESP32 Pin Definition. You can change this, but best if you keep it as is... */
|
/* ESP32 Pin Definition. You can change this, but best if you keep it as is... */
|
||||||
|
|
||||||
#define R1_PIN 25
|
#define R1_PIN_DEFAULT 25
|
||||||
#define G1_PIN 26
|
#define G1_PIN_DEFAULT 26
|
||||||
#define B1_PIN 27
|
#define B1_PIN_DEFAULT 27
|
||||||
#define R2_PIN 14
|
#define R2_PIN_DEFAULT 14
|
||||||
#define G2_PIN 12
|
#define G2_PIN_DEFAULT 12
|
||||||
#define B2_PIN 13
|
#define B2_PIN_DEFAULT 13
|
||||||
|
|
||||||
#define A_PIN 23
|
#define A_PIN_DEFAULT 23
|
||||||
#define B_PIN 22
|
#define B_PIN_DEFAULT 22
|
||||||
#define C_PIN 5
|
#define C_PIN_DEFAULT 5
|
||||||
#define D_PIN 17
|
#define D_PIN_DEFAULT 17
|
||||||
#define E_PIN -1
|
#define E_PIN_DEFAULT -1
|
||||||
|
|
||||||
#define LAT_PIN 4
|
#define LAT_PIN_DEFAULT 4
|
||||||
#define OE_PIN 15
|
#define OE_PIN_DEFAULT 15
|
||||||
|
|
||||||
#define CLK_PIN 16
|
#define CLK_PIN_DEFAULT 16
|
||||||
|
|
||||||
/***************************************************************************************/
|
/***************************************************************************************/
|
||||||
/* HUB75 RGB Panel definitions and DMA Config. It's best you don't change any of this. */
|
/* HUB75 RGB Panel definitions and DMA Config. It's best you don't change any of this. */
|
||||||
|
@ -175,9 +175,30 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void begin(void)
|
// Painfully propagate the DMA pin configuration, or use compiler defaults
|
||||||
|
void begin(int dma_r1_pin = R1_PIN_DEFAULT , int dma_g1_pin = G1_PIN_DEFAULT, int dma_b1_pin = B1_PIN_DEFAULT , int dma_r2_pin = R2_PIN_DEFAULT , int dma_g2_pin = G2_PIN_DEFAULT , int dma_b2_pin = B2_PIN_DEFAULT , int dma_a_pin = A_PIN_DEFAULT , int dma_b_pin = B_PIN_DEFAULT , int dma_c_pin = C_PIN_DEFAULT , int dma_d_pin = D_PIN_DEFAULT , int dma_e_pin = E_PIN_DEFAULT , int dma_lat_pin = LAT_PIN_DEFAULT, int dma_oe_pin = OE_PIN_DEFAULT , int dma_clk_pin = CLK_PIN_DEFAULT)
|
||||||
{
|
{
|
||||||
configureDMA(); //DMA and I2S configuration and setup
|
|
||||||
|
// Change 'if' to '1' to enable, 0 to not include this Serial output in compiled program
|
||||||
|
#if 1
|
||||||
|
Serial.printf("Using pin %d for the R1_PIN\n", dma_r1_pin);
|
||||||
|
Serial.printf("Using pin %d for the G1_PIN\n", dma_g1_pin);
|
||||||
|
Serial.printf("Using pin %d for the B1_PIN\n", dma_b1_pin);
|
||||||
|
Serial.printf("Using pin %d for the R2_PIN\n", dma_r2_pin);
|
||||||
|
Serial.printf("Using pin %d for the G2_PIN\n", dma_g2_pin);
|
||||||
|
Serial.printf("Using pin %d for the B2_PIN\n", dma_b2_pin);
|
||||||
|
Serial.printf("Using pin %d for the A_PIN\n", dma_a_pin);
|
||||||
|
Serial.printf("Using pin %d for the B_PIN\n", dma_b_pin);
|
||||||
|
Serial.printf("Using pin %d for the C_PIN\n", dma_c_pin);
|
||||||
|
Serial.printf("Using pin %d for the D_PIN\n", dma_d_pin);
|
||||||
|
Serial.printf("Using pin %d for the E_PIN\n", dma_e_pin);
|
||||||
|
|
||||||
|
Serial.printf("Using pin %d for the LAT_PIN\n", dma_lat_pin);
|
||||||
|
Serial.printf("Using pin %d for the OE_PIN\n", dma_oe_pin);
|
||||||
|
Serial.printf("Using pin %d for the CLK_PIN\n", dma_clk_pin);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
flushDMAbuffer();
|
flushDMAbuffer();
|
||||||
swapBuffer();
|
swapBuffer();
|
||||||
|
@ -237,7 +258,7 @@ class RGB64x32MatrixPanel_I2S_DMA : public Adafruit_GFX {
|
||||||
updateMatrixDMABuffer( x, y, 0, 0, 0);
|
updateMatrixDMABuffer( x, y, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void configureDMA(); // Get everything setup. Refer to the .c file
|
void configureDMA(int r1_pin, int g1_pin, int b1_pin, int r2_pin, int g2_pin, int b2_pin, int a_pin, int b_pin, int c_pin, int d_pin, int e_pin, int lat_pin, int oe_pin, int clk_pin); // Get everything setup. Refer to the .c file
|
||||||
|
|
||||||
|
|
||||||
// Update a specific pixel in the DMA buffer a colour
|
// Update a specific pixel in the DMA buffer a colour
|
||||||
|
|
Loading…
Reference in a new issue