Skip to content

Commit af2e0bf

Browse files
authored
Merge branch 'MoonModules:mdev' into Strip_Level_Color_Adjust
2 parents c5d7e42 + d0fe878 commit af2e0bf

File tree

10 files changed

+392
-23
lines changed

10 files changed

+392
-23
lines changed

platformio.ini

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ default_envs =
9090
esp01_1MB_S
9191
esp32_16MB_M_eth
9292
athom_music_esp32_4MB_M
93+
adafruit_matrixportal_esp32s3
9394

9495
; Go to MoonModules environments for environments
9596

@@ -336,11 +337,15 @@ build_flagsV4 = -g
336337
-D CONFIG_ASYNC_TCP_USE_WDT=0
337338
-D CONFIG_ASYNC_TCP_TASK_STACK_SIZE=9472 ;; WLEDMM increase stack by 1.25Kb, as audioreactive needs bigger SETTINGS_STACK_BUF_SIZE
338339
; -DARDUINO_USB_CDC_ON_BOOT=0 ;; mandatory for "classic ESP32" when building with arduino-esp32 >=2.0.3
340+
-D NO_GFX ; Disable the use of Adafruit_GFX by the HUB75 driver
341+
339342
;;; V4.4.x libraries (without LOROL_LITTLEFS; with newer NeoPixelBus)
340343
lib_depsV4 =
341344
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 !!
342345
makuna/NeoPixelBus @ 2.7.5
343346
${env.lib_deps}
347+
https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git @ 3.0.10
348+
344349

345350
;; WLEDMM end
346351

@@ -1504,11 +1509,12 @@ build_flags = ${esp32_4MB_V4_S_base.esp32_build_flags}
15041509
; -D WLED_DEBUG
15051510
; -D SR_DEBUG
15061511
; -D MIC_LOGGER
1512+
-D WLED_ENABLE_HUB75MATRIX
1513+
15071514
lib_deps = ${esp32_4MB_V4_S_base.esp32_lib_deps}
15081515
lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
1509-
; RAM: [=== ] 25.1% (used 82176 bytes from 327680 bytes)
1510-
; Flash: [========= ] 93.8% (used 1474893 bytes from 1572864 bytes)
1511-
1516+
; RAM: [=== ] 27.7% (used 90664 bytes from 327680 bytes)
1517+
; Flash: [==========] 95.1% (used 1495497 bytes from 1572864 bytes)
15121518
; compiled with ESP-IDF 4.4.1
15131519
[env:esp32_4MB_V4_M]
15141520
extends = esp32_4MB_V4_M_base
@@ -1525,6 +1531,7 @@ lib_deps = ${esp32_4MB_V4_M_base.esp32_lib_deps}
15251531
lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
15261532
build_unflags = ${esp32_4MB_V4_M_base.build_unflags}
15271533
-D USERMOD_ANIMARTRIX ;; Tips our memory usage over the limit
1534+
-D WLED_ENABLE_HUB75MATRIX
15281535

15291536
;; RAM: [=== ] 25.9% (used 84708 bytes from 327680 bytes)
15301537
;; Flash: [==========] 98.5% (used 1549033 bytes from 1572864 bytes)
@@ -2276,3 +2283,26 @@ lib_deps = ${esp32_4MB_V4_S_base.esp32_lib_deps}
22762283
; RAM: [=== ] 25.4% (used 83144 bytes from 327680 bytes)
22772284
; Flash: [==========] 96.4% (used 1516029 bytes from 1572864 bytes)
22782285
;
2286+
2287+
2288+
[env:adafruit_matrixportal_esp32s3]
2289+
platform = espressif32 ; latest
2290+
board = adafruit_matrixportal_esp32s3
2291+
extends = esp32_4MB_V4_S_base
2292+
build_unflags = ${env:esp32S3_8MB_M.build_unflags} ;; use the same as "normal" S3 buildenv
2293+
build_flags = ${common.build_flags} ${esp32s3.build_flags} -Wno-misleading-indentation -Wno-format-truncation
2294+
${common_mm.build_flags_S}
2295+
-D WLED_RELEASE_NAME=matrixportal_esp32s3
2296+
-DARDUINO_USB_MODE=1 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=1 ;; for Hardware-CDC USB mode
2297+
-D WLED_DISABLE_ADALIGHT ;; disables serial protocols - recommended for Hardware-CDC USB (Serial RX will receive junk commands when RX pin is unconnected, unless its pulled down by resistor)
2298+
${common_mm.animartrix_build_flags}
2299+
${common_mm.build_disable_sync_interfaces}
2300+
-D LOLIN_WIFI_FIX ;; try this in case Wifi does not work
2301+
-D WLED_WATCHDOG_TIMEOUT=0 -D CONFIG_ASYNC_TCP_USE_WDT=0
2302+
-D WLED_USE_PSRAM -DBOARD_HAS_PSRAM ; tells WLED that PSRAM shall be used
2303+
-D WLED_ENABLE_HUB75MATRIX -D NO_GFX ;-D SPIRAM_FRAMEBUFFER
2304+
-D DEFAULT_LED_TYPE=101
2305+
lib_deps = ${esp32_4MB_V4_S_base.esp32_lib_deps}
2306+
${common_mm.animartrix_lib_deps}
2307+
lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
2308+
monitor_filters = esp32_exception_decoder

usermods/usermod_v2_animartrix/usermod_v2_animartrix.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ class ANIMartRIXMod:public ANIMartRIX {
9696
}
9797
float speedFactor = 1.0;
9898
if (SEGMENT.speed < 128) {
99-
speedFactor = (float) map(SEGMENT.speed, 0, 127, 1, 10) / 10.0f;
99+
speedFactor = (float) map(SEGMENT.speed, 0, 127, 1, 100) / 100.0f;
100100
}
101101
else{
102-
speedFactor = map(SEGMENT.speed, 128, 255, 10, 100) / 10;
102+
speedFactor = (float) map(SEGMENT.speed, 128, 255, 10, 100) / 10.0f;
103103
}
104104
setSpeedFactor(speedFactor);
105105
}

wled00/bus_manager.cpp

Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,232 @@ void BusNetwork::cleanup() {
462462
_data = nullptr;
463463
}
464464

465+
// ***************************************************************************
466+
467+
#ifdef WLED_ENABLE_HUB75MATRIX
468+
469+
BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) {
470+
471+
mxconfig.double_buff = false; // <------------- Turn on double buffer
472+
473+
474+
fourScanPanel = nullptr;
475+
476+
switch(bc.type) {
477+
case 101:
478+
mxconfig.mx_width = 32;
479+
mxconfig.mx_height = 32;
480+
break;
481+
case 102:
482+
mxconfig.mx_width = 64;
483+
mxconfig.mx_height = 32;
484+
break;
485+
case 103:
486+
mxconfig.mx_width = 64;
487+
mxconfig.mx_height = 64;
488+
break;
489+
case 105:
490+
mxconfig.mx_width = 32 * 2;
491+
mxconfig.mx_height = 32 / 2;
492+
break;
493+
case 106:
494+
mxconfig.mx_width = 64 * 2;
495+
mxconfig.mx_height = 64 / 2;
496+
break;
497+
}
498+
499+
mxconfig.chain_length = max((u_int8_t) 1, min(bc.pins[0], (u_int8_t) 4)); // prevent bad data preventing boot due to low memory
500+
501+
if(mxconfig.mx_width >= 64 && (bc.pins[0] > 1)) {
502+
USER_PRINT("WARNING, only single panel can be used of 64 pixel boards due to memory")
503+
mxconfig.chain_length = 1;
504+
}
505+
506+
// mxconfig.driver = HUB75_I2S_CFG::SHIFTREG;
507+
508+
#if defined(ARDUINO_ADAFRUIT_MATRIXPORTAL_ESP32S3) // MatrixPortal ESP32-S3
509+
510+
// https://www.adafruit.com/product/5778
511+
512+
USER_PRINTLN("MatrixPanel_I2S_DMA - Matrix Portal S3 config");
513+
514+
mxconfig.gpio.r1 = 42;
515+
mxconfig.gpio.g1 = 41;
516+
mxconfig.gpio.b1 = 40;
517+
mxconfig.gpio.r2 = 38;
518+
mxconfig.gpio.g2 = 39;
519+
mxconfig.gpio.b2 = 37;
520+
521+
mxconfig.gpio.lat = 47;
522+
mxconfig.gpio.oe = 14;
523+
mxconfig.gpio.clk = 2;
524+
525+
mxconfig.gpio.a = 45;
526+
mxconfig.gpio.b = 36;
527+
mxconfig.gpio.c = 48;
528+
mxconfig.gpio.d = 35;
529+
mxconfig.gpio.e = 21;
530+
531+
#elif defined(ESP32_FORUM_PINOUT) // Common format for boards designed for SmartMatrix
532+
533+
USER_PRINTLN("MatrixPanel_I2S_DMA - ESP32_FORUM_PINOUT");
534+
535+
/*
536+
ESP32 with SmartMatrix's default pinout - ESP32_FORUM_PINOUT
537+
538+
https://github.com/pixelmatix/SmartMatrix/blob/teensylc/src/MatrixHardware_ESP32_V0.h
539+
540+
Can use a board like https://github.com/rorosaurus/esp32-hub75-driver
541+
*/
542+
543+
mxconfig.gpio.r1 = 2;
544+
mxconfig.gpio.g1 = 15;
545+
mxconfig.gpio.b1 = 4;
546+
mxconfig.gpio.r2 = 16;
547+
mxconfig.gpio.g2 = 27;
548+
mxconfig.gpio.b2 = 17;
549+
550+
mxconfig.gpio.lat = 26;
551+
mxconfig.gpio.oe = 25;
552+
mxconfig.gpio.clk = 22;
553+
554+
mxconfig.gpio.a = 5;
555+
mxconfig.gpio.b = 18;
556+
mxconfig.gpio.c = 19;
557+
mxconfig.gpio.d = 21;
558+
mxconfig.gpio.e = 12;
559+
560+
#else
561+
USER_PRINTLN("MatrixPanel_I2S_DMA - Default pins");
562+
/*
563+
https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA?tab=readme-ov-file
564+
565+
Boards
566+
567+
https://esp32trinity.com/
568+
https://www.electrodragon.com/product/rgb-matrix-panel-drive-interface-board-for-esp32-dma/
569+
570+
*/
571+
mxconfig.gpio.r1 = 25;
572+
mxconfig.gpio.g1 = 26;
573+
mxconfig.gpio.b1 = 27;
574+
mxconfig.gpio.r2 = 14;
575+
mxconfig.gpio.g2 = 12;
576+
mxconfig.gpio.b2 = 13;
577+
578+
mxconfig.gpio.lat = 4;
579+
mxconfig.gpio.oe = 15;
580+
mxconfig.gpio.clk = 16;
581+
582+
mxconfig.gpio.a = 23;
583+
mxconfig.gpio.b = 19;
584+
mxconfig.gpio.c = 5;
585+
mxconfig.gpio.d = 17;
586+
mxconfig.gpio.e = 18;
587+
588+
#endif
589+
590+
591+
USER_PRINTF("MatrixPanel_I2S_DMA config - %ux%u length: %u\n", mxconfig.mx_width, mxconfig.mx_height, mxconfig.chain_length);
592+
593+
// OK, now we can create our matrix object
594+
display = new MatrixPanel_I2S_DMA(mxconfig);
595+
596+
this->_len = (display->width() * display->height());
597+
598+
pinManager.allocatePin(mxconfig.gpio.r1, true, PinOwner::HUB75);
599+
pinManager.allocatePin(mxconfig.gpio.g1, true, PinOwner::HUB75);
600+
pinManager.allocatePin(mxconfig.gpio.b1, true, PinOwner::HUB75);
601+
pinManager.allocatePin(mxconfig.gpio.r2, true, PinOwner::HUB75);
602+
pinManager.allocatePin(mxconfig.gpio.g2, true, PinOwner::HUB75);
603+
pinManager.allocatePin(mxconfig.gpio.b2, true, PinOwner::HUB75);
604+
605+
pinManager.allocatePin(mxconfig.gpio.lat, true, PinOwner::HUB75);
606+
pinManager.allocatePin(mxconfig.gpio.oe, true, PinOwner::HUB75);
607+
pinManager.allocatePin(mxconfig.gpio.clk, true, PinOwner::HUB75);
608+
609+
pinManager.allocatePin(mxconfig.gpio.a, true, PinOwner::HUB75);
610+
pinManager.allocatePin(mxconfig.gpio.b, true, PinOwner::HUB75);
611+
pinManager.allocatePin(mxconfig.gpio.c, true, PinOwner::HUB75);
612+
pinManager.allocatePin(mxconfig.gpio.d, true, PinOwner::HUB75);
613+
pinManager.allocatePin(mxconfig.gpio.e, true, PinOwner::HUB75);
614+
615+
// display->setLatBlanking(4);
616+
617+
USER_PRINTLN("MatrixPanel_I2S_DMA created");
618+
// let's adjust default brightness
619+
display->setBrightness8(25); // range is 0-255, 0 - 0%, 255 - 100%
620+
621+
// Allocate memory and start DMA display
622+
if( not display->begin() ) {
623+
USER_PRINTLN("****** MatrixPanel_I2S_DMA !KABOOM! I2S memory allocation failed ***********");
624+
return;
625+
}
626+
else {
627+
_valid = true;
628+
}
629+
630+
switch(bc.type) {
631+
case 105:
632+
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_32PX_HIGH");
633+
fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 32, 32);
634+
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_32PX_HIGH);
635+
fourScanPanel->setRotation(0);
636+
break;
637+
case 106:
638+
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_64PX_HIGH");
639+
fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 64, 64);
640+
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_64PX_HIGH);
641+
fourScanPanel->setRotation(0);
642+
break;
643+
}
644+
645+
646+
USER_PRINTLN("MatrixPanel_I2S_DMA started");
647+
}
648+
649+
void BusHub75Matrix::setPixelColor(uint16_t pix, uint32_t c) {
650+
r = R(c);
651+
g = G(c);
652+
b = B(c);
653+
if(fourScanPanel != nullptr) {
654+
x = pix % fourScanPanel->width();
655+
y = floor(pix / fourScanPanel->width());
656+
fourScanPanel->drawPixelRGB888(x, y, r, g, b);
657+
}
658+
else {
659+
x = pix % display->width();
660+
y = floor(pix / display->width());
661+
display->drawPixelRGB888(x, y, r, g, b);
662+
}
663+
}
664+
665+
void BusHub75Matrix::setBrightness(uint8_t b, bool immediate) {
666+
this->display->setBrightness(b);
667+
}
668+
669+
void BusHub75Matrix::deallocatePins() {
670+
671+
pinManager.deallocatePin(mxconfig.gpio.r1, PinOwner::HUB75);
672+
pinManager.deallocatePin(mxconfig.gpio.g1, PinOwner::HUB75);
673+
pinManager.deallocatePin(mxconfig.gpio.b1, PinOwner::HUB75);
674+
pinManager.deallocatePin(mxconfig.gpio.r2, PinOwner::HUB75);
675+
pinManager.deallocatePin(mxconfig.gpio.g2, PinOwner::HUB75);
676+
pinManager.deallocatePin(mxconfig.gpio.b2, PinOwner::HUB75);
677+
678+
pinManager.deallocatePin(mxconfig.gpio.lat, PinOwner::HUB75);
679+
pinManager.deallocatePin(mxconfig.gpio.oe, PinOwner::HUB75);
680+
pinManager.deallocatePin(mxconfig.gpio.clk, PinOwner::HUB75);
681+
682+
pinManager.deallocatePin(mxconfig.gpio.a, PinOwner::HUB75);
683+
pinManager.deallocatePin(mxconfig.gpio.b, PinOwner::HUB75);
684+
pinManager.deallocatePin(mxconfig.gpio.c, PinOwner::HUB75);
685+
pinManager.deallocatePin(mxconfig.gpio.d, PinOwner::HUB75);
686+
pinManager.deallocatePin(mxconfig.gpio.e, PinOwner::HUB75);
687+
688+
}
689+
#endif
690+
// ***************************************************************************
465691

466692
//utility to get the approx. memory usage of a given BusConfig
467693
uint32_t BusManager::memUsage(BusConfig &bc) {
@@ -487,8 +713,14 @@ uint32_t BusManager::memUsage(BusConfig &bc) {
487713

488714
int BusManager::add(BusConfig &bc) {
489715
if (getNumBusses() - getNumVirtualBusses() >= WLED_MAX_BUSSES) return -1;
716+
USER_PRINTF("BusManager::add(bc.type=%u)\n", bc.type);
490717
if (bc.type >= TYPE_NET_DDP_RGB && bc.type < 96) {
491718
busses[numBusses] = new BusNetwork(bc);
719+
#ifdef WLED_ENABLE_HUB75MATRIX
720+
} else if (bc.type >= TYPE_HUB75MATRIX && bc.type <= (TYPE_HUB75MATRIX + 10)) {
721+
USER_PRINTLN("BusManager::add - Adding BusHub75Matrix");
722+
busses[numBusses] = new BusHub75Matrix(bc);
723+
#endif
492724
} else if (IS_DIGITAL(bc.type)) {
493725
busses[numBusses] = new BusDigital(bc, numBusses, colorOrderMap);
494726
} else if (bc.type == TYPE_ONOFF) {

0 commit comments

Comments
 (0)