aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp20
-rw-r--r--src/ESP32-HUB75-MatrixPanel-I2S-DMA.h11
2 files changed, 16 insertions, 15 deletions
diff --git a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp
index 04ab22f..9539a92 100644
--- a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp
+++ b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp
@@ -62,7 +62,7 @@ bool MatrixPanel_I2S_DMA::allocateDMAmemory()
// TODO: should we release all previous rowBitStructs here???
}
- allocated_fb_memory += ptr->size();
+ allocated_fb_memory += ptr->getColorDepthSize();
frame_buffer[fb].rowBits.emplace_back(ptr); // save new rowBitStruct into rows vector
++frame_buffer[fb].rows;
}
@@ -124,7 +124,7 @@ bool MatrixPanel_I2S_DMA::allocateDMAmemory()
// Refer to 'DMA_LL_PAYLOAD_SPLIT' code in configureDMA() below to understand why this exists.
// numDMAdescriptorsPerRow is also used to calculate descount which is super important in i2s_parallel_config_t SoC DMA setup.
- if (frame_buffer[0].rowBits[0]->size() > DMA_MAX)
+ if (frame_buffer[0].rowBits[0]->getColorDepthSize() > DMA_MAX)
{
ESP_LOGW("I2S-DMA", "rowBits struct is too large to fit in one DMA transfer payload, splitting required. Adding %d DMA descriptors\n", m_cfg.getPixelColorDepthBits() - 1);
@@ -193,7 +193,7 @@ void MatrixPanel_I2S_DMA::configureDMA(const HUB75_I2S_CFG &_cfg)
// HACK: If we need to split the payload in 1/2 so that it doesn't breach DMA_MAX, lets do it by the colour_depth.
int num_dma_payload_colour_depths = m_cfg.getPixelColorDepthBits();
- if (frame_buffer[0].rowBits[0]->size() > DMA_MAX)
+ if (frame_buffer[0].rowBits[0]->getColorDepthSize() > DMA_MAX)
{
num_dma_payload_colour_depths = 1;
}
@@ -224,26 +224,26 @@ void MatrixPanel_I2S_DMA::configureDMA(const HUB75_I2S_CFG &_cfg)
// link_dma_desc(&dmadesc_a[current_dmadescriptor_offset], previous_dmadesc_a, dma_buff.rowBits[row]->getDataPtr(), dma_buff.rowBits[row]->size(num_dma_payload_colour_depths));
// previous_dmadesc_a = &dmadesc_a[current_dmadescriptor_offset];
- dma_bus.create_dma_desc_link(frame_buffer[0].rowBits[row]->getDataPtr(0, 0), frame_buffer[0].rowBits[row]->size(), false);
+ dma_bus.create_dma_desc_link(frame_buffer[0].rowBits[row]->getDataPtr(0, 0), frame_buffer[0].rowBits[row]->getColorDepthSize(), false);
if (m_cfg.double_buff)
{
- dma_bus.create_dma_desc_link(frame_buffer[1].rowBits[row]->getDataPtr(0, 1), frame_buffer[1].rowBits[row]->size(), true);
+ dma_bus.create_dma_desc_link(frame_buffer[1].rowBits[row]->getDataPtr(0, 1), frame_buffer[1].rowBits[row]->getColorDepthSize(), true);
}
current_dmadescriptor_offset++;
// If the number of pixels per row is too great for the size of a DMA payload, so we need to split what we were going to send above.
- if (frame_buffer[0].rowBits[0]->size() > DMA_MAX)
+ if (frame_buffer[0].rowBits[0]->getColorDepthSize() > DMA_MAX)
{
for (int cd = 1; cd < m_cfg.getPixelColorDepthBits(); cd++)
{
- dma_bus.create_dma_desc_link(frame_buffer[0].rowBits[row]->getDataPtr(cd, 0), frame_buffer[0].rowBits[row]->size(1), false);
+ dma_bus.create_dma_desc_link(frame_buffer[0].rowBits[row]->getDataPtr(cd, 0), frame_buffer[0].rowBits[row]->getColorDepthSize(1), false);
if (m_cfg.double_buff)
{
- dma_bus.create_dma_desc_link(frame_buffer[1].rowBits[row]->getDataPtr(cd, 1), frame_buffer[1].rowBits[row]->size(1), true);
+ dma_bus.create_dma_desc_link(frame_buffer[1].rowBits[row]->getDataPtr(cd, 1), frame_buffer[1].rowBits[row]->getColorDepthSize(1), true);
}
current_dmadescriptor_offset++;
@@ -259,11 +259,11 @@ void MatrixPanel_I2S_DMA::configureDMA(const HUB75_I2S_CFG &_cfg)
for (int k = 0; k < (1 << (i - lsbMsbTransitionBit - 1)); k++)
{
- dma_bus.create_dma_desc_link(frame_buffer[0].rowBits[row]->getDataPtr(i, 0), frame_buffer[0].rowBits[row]->size(1), false);
+ dma_bus.create_dma_desc_link(frame_buffer[0].rowBits[row]->getDataPtr(i, 0), frame_buffer[0].rowBits[row]->getColorDepthSize(1), false);
if (m_cfg.double_buff)
{
- dma_bus.create_dma_desc_link(frame_buffer[1].rowBits[row]->getDataPtr(i, 1), frame_buffer[1].rowBits[row]->size(1), true);
+ dma_bus.create_dma_desc_link(frame_buffer[1].rowBits[row]->getDataPtr(i, 1), frame_buffer[1].rowBits[row]->getColorDepthSize(1), true);
}
current_dmadescriptor_offset++;
diff --git a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h
index 781bd80..2e2c3a9 100644
--- a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h
+++ b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h
@@ -139,12 +139,13 @@ struct rowBitStruct
ESP32_I2S_DMA_STORAGE_TYPE *data;
/** @brief
- * Returns size of row of data vectorfor a SINGLE buff for the number of colour depths rquested
+ * Returns size (in bytes) of row of data vectorfor a SINGLE buff for the number of colour depths requested
*
- * default - returns full data vector size for a SINGLE buff
+ * default - Returns full data vector size for a SINGLE buff.
+ * You should only pass either PIXEL_COLOR_DEPTH_BITS or '1' to this
*
*/
- size_t size(uint8_t _dpth = 0)
+ size_t getColorDepthSize(uint8_t _dpth = 0)
{
if (!_dpth)
_dpth = colour_depth;
@@ -171,12 +172,12 @@ struct rowBitStruct
// data = (ESP32_I2S_DMA_STORAGE_TYPE *)heap_caps_aligned_alloc(64, size()+size()*double_buff, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
// No longer have double buffer in the same struct - have a different struct
- data = (ESP32_I2S_DMA_STORAGE_TYPE *)heap_caps_aligned_alloc(64, size(), MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
+ data = (ESP32_I2S_DMA_STORAGE_TYPE *)heap_caps_aligned_alloc(64, getColorDepthSize(), MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
#else
// data = (ESP32_I2S_DMA_STORAGE_TYPE *)heap_caps_malloc( size()+size()*double_buff, MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA);
// No longer have double buffer in the same struct - have a different struct
- data = (ESP32_I2S_DMA_STORAGE_TYPE *)heap_caps_malloc(size(), MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA);
+ data = (ESP32_I2S_DMA_STORAGE_TYPE *)heap_caps_malloc(getColorDepthSize(), MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA);
#endif
}