Swap to ESP32-HUB75-MatrixPanel-DMA

This commit is contained in:
Will Tatam
2023-10-25 00:54:45 +01:00
parent ee0ec77464
commit 3ba37e08bd
3 changed files with 26 additions and 40 deletions

View File

@@ -340,6 +340,8 @@ lib_depsV4 =
https://github.com/pbolduc/AsyncTCP.git @ 1.2.0 ;; WLEDMM this must be first in the list, otherwise Aircoookie/ESPAsyncWebServer pulls in an older version of AsyncTCP !! https://github.com/pbolduc/AsyncTCP.git @ 1.2.0 ;; WLEDMM this must be first in the list, otherwise Aircoookie/ESPAsyncWebServer pulls in an older version of AsyncTCP !!
makuna/NeoPixelBus @ 2.7.5 makuna/NeoPixelBus @ 2.7.5
${env.lib_deps} ${env.lib_deps}
https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git @ 3.0.9
;; WLEDMM end ;; WLEDMM end
@@ -944,17 +946,16 @@ build_flags_M =
-D USERMOD_ROTARY_ENCODER_UI -D USERMOD_ROTARY_ENCODER_UI
-D USERMOD_AUTO_SAVE -D USERMOD_AUTO_SAVE
${common_mm.animartrix_build_flags} ${common_mm.animartrix_build_flags}
-D WLED_ENABLE_SMARTMATRIX
;WLEDMM: only setting WLED_DEBUG_HOST is enough, ip and port can be defined in sync settings as well ;WLEDMM: only setting WLED_DEBUG_HOST is enough, ip and port can be defined in sync settings as well
-D WLED_DEBUG_HOST='"192.168.x.x"' ;; to send debug messages over network to host 192.168.x.y - FQDN is also possible -D WLED_DEBUG_HOST='"192.168.x.x"' ;; to send debug messages over network to host 192.168.x.y - FQDN is also possible
-D WLED_DEBUG_PORT=1768 ;; port for network debugging. default = 7868 -D WLED_DEBUG_PORT=1768 ;; port for network debugging. default = 7868
-D WLED_DEBUG
lib_deps_M = lib_deps_M =
;https://github.com/blazoncek/OneWire.git ; includes bugfixes for inconsistent readings ;https://github.com/blazoncek/OneWire.git ; includes bugfixes for inconsistent readings
OneWire@~2.3.5 ; used for USERMOD_FOUR_LINE_DISPLAY and USERMOD_DALLASTEMPERATURE OneWire@~2.3.5 ; used for USERMOD_FOUR_LINE_DISPLAY and USERMOD_DALLASTEMPERATURE
olikraus/U8g2 @ ^2.28.8 ; used for USERMOD_FOUR_LINE_DISPLAY olikraus/U8g2 @ ^2.28.8 ; used for USERMOD_FOUR_LINE_DISPLAY
${common_mm.animartrix_lib_deps} ${common_mm.animartrix_lib_deps}
https://github.com/pixelmatix/SmartMatrix.git @ 4.0.3
lib_deps_V4_M = lib_deps_V4_M =
;https://github.com/blazoncek/OneWire.git ; includes bugfixes for inconsistent readings ;https://github.com/blazoncek/OneWire.git ; includes bugfixes for inconsistent readings
@@ -1036,7 +1037,7 @@ platform = ${esp32.platformV4}
platform_packages = platform_packages =
${esp32.platformV4_packages} ${esp32.platformV4_packages}
toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5 ; align main tools with riscV tools toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5 ; align main tools with riscV tools
build_unflags = ${common.build_unflags} -D WLED_ENABLE_SMARTMATRIX build_unflags = ${common.build_unflags}
build_flags = ${common.build_flags} ${esp32.build_flagsV4} ${common_mm.build_flags_S} build_flags = ${common.build_flags} ${esp32.build_flagsV4} ${common_mm.build_flags_S}
-Wno-misleading-indentation -Wno-format-truncation -Wno-misleading-indentation -Wno-format-truncation
-Wshadow=compatible-local ;; emit warning in case a local variable "shadows" another local one -Wshadow=compatible-local ;; emit warning in case a local variable "shadows" another local one
@@ -1460,6 +1461,8 @@ build_flags = ${esp32_4MB_V4_S_base.build_flags}
; -D WLED_DEBUG ; -D WLED_DEBUG
; -D SR_DEBUG ; -D SR_DEBUG
; -D MIC_LOGGER ; -D MIC_LOGGER
-D WLED_ENABLE_SMARTMATRIX -D NO_GFX
lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
; RAM: [=== ] 25.1% (used 82176 bytes from 327680 bytes) ; RAM: [=== ] 25.1% (used 82176 bytes from 327680 bytes)
; Flash: [========= ] 93.8% (used 1474893 bytes from 1572864 bytes) ; Flash: [========= ] 93.8% (used 1474893 bytes from 1572864 bytes)

View File

@@ -464,45 +464,28 @@ void BusNetwork::cleanup() {
BusSmartMatrix::BusSmartMatrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) { BusSmartMatrix::BusSmartMatrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) {
#define num_x 32 // how many LEDs are in one row? HUB75_I2S_CFG mxconfig;
#define num_y 32 // how many rows? mxconfig.double_buff = true; // <------------- Turn on double buffer
mxconfig.mx_width = 64;
mxconfig.mx_height = 64;
mxconfig.gpio.e = 18;
// OK, now we can create our matrix object
display = new MatrixPanel_I2S_DMA(mxconfig);
#define radial_filter_radius 23.0; // on 32x32, use 11 for 16x16 // let's adjust default brightness
display->setBrightness8(125); // range is 0-255, 0 - 0%, 255 - 100%
#define COLOR_DEPTH 24 // Choose the color depth used for storing pixels in the layers: 24 or 48 (24 is good for most sketches - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24) // Allocate memory and start DMA display
const uint16_t kMatrixWidth = num_x; // Set to the width of your display, must be a multiple of 8 if( not display->begin() )
const uint16_t kMatrixHeight = num_y; // Set to the height of your display Serial.println("****** !KABOOM! I2S memory allocation failed ***********");
const uint8_t kRefreshDepth = 24; // Tradeoff of color quality vs refresh rate, max brightness, and RAM usage. 36 is typically good, drop down to 24 if you need to. On Teensy, multiples of 3, up to 48: 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48. On ESP32: 24, 36, 48
const uint8_t kDmaBufferRows = 4; // known working: 2-4, use 2 to save RAM, more to keep from dropping frames and automatically lowering refresh rate. (This isn't used on ESP32, leave as default)
const uint8_t kPanelType = SM_PANELTYPE_HUB75_32ROW_MOD16SCAN; // Choose the configuration that matches your panels. See more details in MatrixCommonHub75.h and the docs: https://github.com/pixelmatix/SmartMatrix/wiki
const uint32_t kMatrixOptions = (SM_HUB75_OPTIONS_NONE); // see docs for options: https://github.com/pixelmatix/SmartMatrix/wiki
const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
USER_PRINTF("BusSmartMatrix: kMatrixWidth=%u, kMatrixHeight=%u", kMatrixWidth, kMatrixHeight);
SMARTMATRIX_ALLOCATE_BUFFERS(smartMatrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
this->_len = (kMatrixWidth * kMatrixHeight);
smartMatrix.addLayer(&backgroundLayer);
smartMatrix.begin();
smartMatrix.setBrightness(50); // TODO - hard code for now
this->buffer = backgroundLayer.backBuffer();
backgroundLayer.swapBuffers(true);
this->backgroundLayer = &backgroundLayer;
// this->smartMatrix = &smartMatrix;
} }
void BusSmartMatrix::setPixelColor(uint16_t pix, uint32_t c) { void BusSmartMatrix::setPixelColor(uint16_t pix, uint32_t c) {
uint8_t r = R(c); uint8_t r = R(c);
uint8_t g = G(c); uint8_t g = G(c);
uint8_t b = B(c); uint8_t b = B(c);
this->buffer[pix] = rgb24(r, g, b); display->drawPixelRGB888(1, 1, r, g, b);
} }
// void BusSmartMatrix::setBrightness(uint8_t b, bool immediate) { // void BusSmartMatrix::setBrightness(uint8_t b, bool immediate) {

View File

@@ -1,9 +1,10 @@
#ifndef BusManager_h #ifndef BusManager_h
#define BusManager_h #define BusManager_h
#define WLED_ENABLE_SMARTMATRIX
#ifdef WLED_ENABLE_SMARTMATRIX #ifdef WLED_ENABLE_SMARTMATRIX
#include <MatrixHardware_ESP32_V0.h> #include <ESP32-HUB75-MatrixPanel-I2S-DMA.h>
#include <SmartMatrix.h>
#endif #endif
/* /*
* Class for addressing various light types * Class for addressing various light types
@@ -343,12 +344,13 @@ class BusSmartMatrix : public Bus {
void show() { void show() {
// Serial.println("SmartMatrix: show()"); // Serial.println("SmartMatrix: show()");
backgroundLayer->swapBuffers(true); display->flipDMABuffer(); // Show the back buffer, set currently output buffer to the back (i.e. no longer being sent to LED panels)
display->clearScreen(); // Now clear the back-buffer
} }
bool canShow() { bool canShow() {
// busy swapping still // busy swapping still
return !backgroundLayer->isSwapPending(); return true; // return !backgroundLayer->isSwapPending();
} }
// void setBrightness(uint8_t b, bool immediate); // void setBrightness(uint8_t b, bool immediate);
@@ -366,9 +368,7 @@ class BusSmartMatrix : public Bus {
} }
private: private:
rgb24* buffer; MatrixPanel_I2S_DMA *display = nullptr;
SMLayerBackground<rgb24, 0u>* backgroundLayer;
// SmartMatrixHub75Calc<36, 32, 32, 0u, 0u>* smartMatrix;
}; };
#endif #endif