move min_refresh_rate to core config

Can only be setup on initisation of the library. Moving to a start-up configuration variable like the others.
This commit is contained in:
mrfaptastic 2021-02-22 12:13:31 +00:00
parent a3068c8934
commit f279d49103
3 changed files with 41 additions and 42 deletions

View file

@ -205,7 +205,7 @@ bool MatrixPanel_I2S_DMA::allocateDMAmemory()
Serial.printf_P(PSTR("lsbMsbTransitionBit of %d gives %d Hz refresh: \r\n"), lsbMsbTransitionBit, actualRefreshRate); Serial.printf_P(PSTR("lsbMsbTransitionBit of %d gives %d Hz refresh: \r\n"), lsbMsbTransitionBit, actualRefreshRate);
#endif #endif
if (actualRefreshRate > min_refresh_rate) // HACK Hard Coded: 100 if (actualRefreshRate > m_cfg.min_refresh_rate)
break; break;
if(lsbMsbTransitionBit < PIXEL_COLOR_DEPTH_BITS - 1) if(lsbMsbTransitionBit < PIXEL_COLOR_DEPTH_BITS - 1)
@ -433,9 +433,7 @@ void MatrixPanel_I2S_DMA::configureDMA(const HUB75_I2S_CFG& _cfg)
i2s_parallel_send_dma(I2S_NUM_1, &dmadesc_a[0]); i2s_parallel_send_dma(I2S_NUM_1, &dmadesc_a[0]);
#if SERIAL_DEBUG #if SERIAL_DEBUG
Serial.println(F("configureDMA(): DMA configuration completed on I2S1.")); Serial.println(F("configureDMA(): DMA setup completed on I2S1."));
Serial.println(F("DMA Memory Map after DMA LL allocations:"));
heap_caps_print_heap_info(MALLOC_CAP_DMA);
#endif #endif
} // end initMatrixDMABuff } // end initMatrixDMABuff

View file

@ -242,6 +242,7 @@ struct HUB75_I2S_CFG {
uint16_t mx_height; uint16_t mx_height;
// number of chained panels regardless of the topology, default 1 - a single matrix module // number of chained panels regardless of the topology, default 1 - a single matrix module
uint16_t chain_length; uint16_t chain_length;
/** /**
* GPIO pins mapping * GPIO pins mapping
*/ */
@ -258,6 +259,9 @@ struct HUB75_I2S_CFG {
// How many clock cycles to blank OE before/after LAT signal change, default is 1 clock // How many clock cycles to blank OE before/after LAT signal change, default is 1 clock
uint8_t latch_blanking; uint8_t latch_blanking;
// Minimum refresh / scan rate needs to be configured on start due to LSBMSB_TRANSITION_BIT calculation in allocateDMAmemory()
uint8_t min_refresh_rate;
/** /**
* I2S clock phase * I2S clock phase
* 0 (default) - data lines are clocked with negative edge * 0 (default) - data lines are clocked with negative edge
@ -285,8 +289,9 @@ struct HUB75_I2S_CFG {
shift_driver _drv = SHIFTREG, shift_driver _drv = SHIFTREG,
bool _dbuff = false, bool _dbuff = false,
clk_speed _i2sspeed = HZ_10M, clk_speed _i2sspeed = HZ_10M,
uint16_t _latblk = 1, uint8_t _latblk = 1,
bool _clockphase = false bool _clockphase = false,
uint8_t _min_refresh_rate = 85
) : mx_width(_w), ) : mx_width(_w),
mx_height(_h), mx_height(_h),
chain_length(_chain), chain_length(_chain),
@ -294,7 +299,8 @@ struct HUB75_I2S_CFG {
driver(_drv), i2sspeed(_i2sspeed), driver(_drv), i2sspeed(_i2sspeed),
double_buff(_dbuff), double_buff(_dbuff),
latch_blanking(_latblk), latch_blanking(_latblk),
clkphase(_clockphase) {} clkphase(_clockphase),
min_refresh_rate (_min_refresh_rate) {}
}; // end of structure HUB75_I2S_CFG }; // end of structure HUB75_I2S_CFG
@ -360,10 +366,11 @@ class MatrixPanel_I2S_DMA {
Serial.printf_P(PSTR("Using pin %d for the CLK_PIN\n"), m_cfg.gpio.clk); Serial.printf_P(PSTR("Using pin %d for the CLK_PIN\n"), m_cfg.gpio.clk);
#endif #endif
// initialize some sppecific panel drivers // initialize some specific panel drivers
if (m_cfg.driver) if (m_cfg.driver)
shiftDriver(m_cfg); shiftDriver(m_cfg);
/* As DMA buffers are dynamically allocated, we must allocated in begin() /* As DMA buffers are dynamically allocated, we must allocated in begin()
* Ref: https://github.com/espressif/arduino-esp32/issues/831 * Ref: https://github.com/espressif/arduino-esp32/issues/831
*/ */
@ -517,11 +524,10 @@ class MatrixPanel_I2S_DMA {
setPanelBrightness(b * PIXELS_PER_ROW / 256); setPanelBrightness(b * PIXELS_PER_ROW / 256);
} }
inline void setMinRefreshRate(int rr) /**
{ * Contains the resulting refresh rate (scan rate) that will be achieved
min_refresh_rate = rr; * based on the i2sspeed, colour depth and min_refresh_rate requested.
} */
int calculated_refresh_rate = 0; int calculated_refresh_rate = 0;
/** /**
@ -618,8 +624,8 @@ class MatrixPanel_I2S_DMA {
bool initialized = false; bool initialized = false;
int back_buffer_id = 0; // If using double buffer, which one is NOT active (ie. being displayed) to write too? int back_buffer_id = 0; // If using double buffer, which one is NOT active (ie. being displayed) to write too?
int brightness = 32; // If you get ghosting... reduce brightness level. 60 seems to be the limit before ghosting on a 64 pixel wide physical panel for some panels. int brightness = 32; // If you get ghosting... reduce brightness level. 60 seems to be the limit before ghosting on a 64 pixel wide physical panel for some panels.
int min_refresh_rate = 99; // Probably best to leave as is unless you want to experiment. Framerate has an impact on brightness and also power draw - voltage ripple. int lsbMsbTransitionBit = 0; // For colour depth calculations
int lsbMsbTransitionBit = 0; // For possible color depth calculations
// *** DMA FRAMEBUFFER structures // *** DMA FRAMEBUFFER structures

View file

@ -212,11 +212,6 @@ void setup() {
Serial.println("SPIFFS Mount Failed"); Serial.println("SPIFFS Mount Failed");
} }
/* setPanelBrightness should be called before .begin() */
/* setMinRefreshRate must be called before .begin() */
dma_display.setPanelBrightness(32);
dma_display.setMinRefreshRate(200);
dma_display.begin(); dma_display.begin();
/* all other pixel drawing functions can only be called after .begin() */ /* all other pixel drawing functions can only be called after .begin() */