aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormrfaptastic <12006953+mrfaptastic@users.noreply.github.com>2022-10-23 16:32:29 +0100
committermrfaptastic <12006953+mrfaptastic@users.noreply.github.com>2022-10-23 16:32:29 +0100
commit99c2c569ef9c520d5741b64e5d3f804891fceff6 (patch)
tree3d90340b06c98c101bebb6c05ddcb58f61bf1232 /src
parent4a9160904a13858ab3a0789cd3b2f3e9ebfc805a (diff)
PSRAM exploring
Diffstat (limited to 'src')
-rw-r--r--src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp11
-rw-r--r--src/ESP32-HUB75-MatrixPanel-I2S-DMA.h12
2 files changed, 18 insertions, 5 deletions
diff --git a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp
index 40388fd..dde328d 100644
--- a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp
+++ b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.cpp
@@ -12,12 +12,17 @@ static const char* TAG = "MatrixPanel";
bool MatrixPanel_I2S_DMA::allocateDMAmemory()
{
-
+
+ ESP_LOGI(TAG, "Free heap: %d", ESP.getFreeHeap());
+ ESP_LOGI(TAG, "Free SPIRAM: %d", ESP.getFreePsram());
+
+
// Alright, theoretically we should be OK, so let us do this, so
// lets allocate a chunk of memory for each row (a row could span multiple panels if chaining is in place)
dma_buff.rowBits.reserve(ROWS_PER_FRAME);
- // iterate through number of rows
+ // iterate through number of rows, allocate memory for each
+ size_t allocated_fb_memory = 0;
for (int malloc_num =0; malloc_num < ROWS_PER_FRAME; ++malloc_num)
{
auto ptr = std::make_shared<rowBitStruct>(PIXELS_PER_ROW, PIXEL_COLOUR_DEPTH_BITS, m_cfg.double_buff);
@@ -29,9 +34,11 @@ bool MatrixPanel_I2S_DMA::allocateDMAmemory()
// TODO: should we release all previous rowBitStructs here???
}
+ allocated_fb_memory += ptr->size();
dma_buff.rowBits.emplace_back(ptr); // save new rowBitStruct into rows vector
++dma_buff.rows;
}
+ ESP_LOGI(TAG, "Allocating %d bytes memory for DMA BCM framebuffer(s).", allocated_fb_memory);
// calculate the lowest LSBMSB_TRANSITION_BIT value that will fit in memory that will meet or exceed the configured refresh rate
#if !defined(FORCE_COLOUR_DEPTH)
diff --git a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h
index 8fb90c7..d5f72d0 100644
--- a/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h
+++ b/src/ESP32-HUB75-MatrixPanel-I2S-DMA.h
@@ -167,11 +167,17 @@ struct rowBitStruct {
// constructor - allocates DMA-capable memory to hold the struct data
rowBitStruct(const size_t _width, const uint8_t _depth, const bool _dbuff) : width(_width), colour_depth(_depth), double_buff(_dbuff) {
-#if defined(SPIRAM_FRAMEBUFFER)
+#if defined(SPIRAM_FRAMEBUFFER) && defined (CONFIG_IDF_TARGET_ESP32S3)
#pragma message "Enabling PSRAM / SPIRAM for frame buffer."
- data = (ESP32_I2S_DMA_STORAGE_TYPE *)heap_caps_malloc( size()+size()*double_buff, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
+ data = (ESP32_I2S_DMA_STORAGE_TYPE *)heap_caps_malloc( size()+size()*double_buff, MALLOC_CAP_SPIRAM);
+/*
+ if (!psramFound())
+ {
+ ESP_LOGE("rowBitStruct", "Requested to use PSRAM / SPIRAM for framebuffer, but it was not detected.");
+ }
+*/
#else
- data = (ESP32_I2S_DMA_STORAGE_TYPE *)heap_caps_malloc( size()+size()*double_buff, MALLOC_CAP_DMA);
+ data = (ESP32_I2S_DMA_STORAGE_TYPE *)heap_caps_malloc( size()+size()*double_buff, MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA);
#endif
}