Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hub75 output #108

Merged
merged 64 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
228c090
Start adding SmartMatrix code
netmindz Oct 23, 2023
4734959
Register SmartMatrix
netmindz Oct 23, 2023
c693ee1
Impliment BusSmartMatrix
netmindz Oct 23, 2023
e27ada3
Fix ordering of Bus Type checking
netmindz Oct 23, 2023
9f55d7d
Trying to get output working
netmindz Oct 23, 2023
744e894
Trying to get output working
netmindz Oct 23, 2023
cf2ff1e
Working SmartMatrix outout
netmindz Oct 23, 2023
7c22bb4
Move define
netmindz Oct 24, 2023
565cfb4
add ifdef for addBus
netmindz Oct 24, 2023
a3f8628
v4 deps
netmindz Oct 24, 2023
68fce57
SmartMatrix wont compile on V4
netmindz Oct 24, 2023
a0b0757
Merge branch 'MoonModules:mdev' into SmartMatrix
netmindz Oct 24, 2023
effeeda
Disable builds that mix V4 and not
netmindz Oct 24, 2023
fa12f0f
Save space
netmindz Oct 24, 2023
4482db8
Merge branch 'MoonModules:mdev' into SmartMatrix
netmindz Oct 24, 2023
6fcb29e
Exclude failing builds
netmindz Oct 24, 2023
ca0eb53
Swap to 64x64
netmindz Oct 24, 2023
b049845
Drop brightness
netmindz Oct 24, 2023
e12e5ad
Swap back to 32x32 for now
netmindz Oct 24, 2023
ee0ec77
Update settings
netmindz Oct 24, 2023
3ba37e0
Swap to ESP32-HUB75-MatrixPanel-DMA
netmindz Oct 24, 2023
aae9b62
Define pins to match SmartMatrix esp32 formum layout
netmindz Oct 25, 2023
3088128
Start testing output on Adafruit Matrix Portal S3
netmindz Jan 12, 2024
83e51b4
Tweaks
netmindz Jan 13, 2024
19029c6
Build only adafruit_matrixportal_esp32s3
netmindz Jan 13, 2024
31edc73
Tweaks
netmindz Jan 13, 2024
df9810e
Enable SMARTMATRIX for V4 builds
netmindz Oct 25, 2023
10e22dc
Tweak build flags
netmindz Oct 25, 2023
41eb48b
Update LED type ID
netmindz Dec 13, 2023
b2972ad
Settings UI update
netmindz Jan 13, 2024
f5ccd6d
Add config for MatrixPortal_S3
netmindz Jan 13, 2024
260159a
Cleanup and rename to generic Hub75 rather than SmartMatrix
netmindz Jan 13, 2024
7fa2fe3
Panel size selection
netmindz Jan 13, 2024
907bc0d
ESP32 build
netmindz Jan 14, 2024
b7b17ee
Update HUB75 driver to 3.0.10
netmindz Feb 10, 2024
b0a63c5
Fix RGB capability issue with HUB75 output
netmindz Feb 10, 2024
bd228e3
Merge branch 'mdev' into ESP32-HUB75-MatrixPanel-DMA
netmindz Feb 10, 2024
c50fda1
Cleanup changes to platformio.ini
netmindz Feb 10, 2024
9c80997
Disable GFX
netmindz Feb 10, 2024
1969f6c
Cleanup changes to platformio.ini
netmindz Feb 10, 2024
0c4d5ab
Update comments
netmindz Feb 10, 2024
609f193
Remove Hub75 led types from list if no support in build
netmindz Feb 10, 2024
afd2b05
Tweaks to adafruit_matrixportal_esp32s3
netmindz Feb 10, 2024
1dc17f9
Impliment getPins
netmindz Feb 10, 2024
977cfb1
Cleanup flags for adafruit_matrixportal_esp32s3
netmindz Feb 10, 2024
2065d9c
Allocate pins using pinManager
netmindz Feb 22, 2024
a92292a
Allocate pins using pinManager
netmindz Feb 22, 2024
99511f2
Merge branch 'mdev' into ESP32-HUB75-MatrixPanel-DMA
netmindz Feb 22, 2024
3b1f408
Check full range of TYPE_HUB75MATRIX types
netmindz Feb 23, 2024
26de408
Add 8S and 16S, 1/8 ad 1/16 support
netmindz Feb 24, 2024
e2aad47
Allow chain of 1-4 panels - subject to memory
netmindz Feb 24, 2024
240c55d
Update generated html
netmindz Feb 25, 2024
e3e9ff7
Force chain length to 1 for 64 panels
netmindz Feb 25, 2024
bf1a91a
Resolve validation error for length
netmindz Feb 25, 2024
565e740
Try LOLIN_WIFI_FIX with matrix portal to see if that helps with poor …
netmindz Feb 25, 2024
b793bb3
Allow more pixels
netmindz Feb 25, 2024
3162579
reset default back
netmindz Feb 25, 2024
c463d51
Set pixel limit by bus type
netmindz Feb 25, 2024
668a757
pixel limit for hub75
netmindz Feb 25, 2024
43320a0
pixel limit for hub75
netmindz Feb 25, 2024
69436a6
Merge branch 'mdev' into ESP32-HUB75-MatrixPanel-DMA
netmindz Feb 25, 2024
68ca14a
Remove TODO
netmindz Feb 25, 2024
2f87b61
Default to mrfaptastic pinout
netmindz Feb 26, 2024
f1a494f
Cleanup comments
netmindz Feb 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ default_envs =
esp01_1MB_S
esp32_16MB_M_eth
athom_music_esp32_4MB_M
adafruit_matrixportal_esp32s3

; Go to MoonModules environments for environments

Expand Down Expand Up @@ -336,11 +337,15 @@ build_flagsV4 = -g
-D CONFIG_ASYNC_TCP_USE_WDT=0
-D CONFIG_ASYNC_TCP_TASK_STACK_SIZE=9472 ;; WLEDMM increase stack by 1.25Kb, as audioreactive needs bigger SETTINGS_STACK_BUF_SIZE
; -DARDUINO_USB_CDC_ON_BOOT=0 ;; mandatory for "classic ESP32" when building with arduino-esp32 >=2.0.3
-D NO_GFX ; Disable the use of Adafruit_GFX by the HUB75 driver

;;; V4.4.x libraries (without LOROL_LITTLEFS; with newer NeoPixelBus)
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 !!
makuna/NeoPixelBus @ 2.7.5
${env.lib_deps}
https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA.git @ 3.0.10


;; WLEDMM end

Expand Down Expand Up @@ -1504,11 +1509,12 @@ build_flags = ${esp32_4MB_V4_S_base.esp32_build_flags}
; -D WLED_DEBUG
; -D SR_DEBUG
; -D MIC_LOGGER
-D WLED_ENABLE_HUB75MATRIX

lib_deps = ${esp32_4MB_V4_S_base.esp32_lib_deps}
lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
; RAM: [=== ] 25.1% (used 82176 bytes from 327680 bytes)
; Flash: [========= ] 93.8% (used 1474893 bytes from 1572864 bytes)

; RAM: [=== ] 27.7% (used 90664 bytes from 327680 bytes)
; Flash: [==========] 95.1% (used 1495497 bytes from 1572864 bytes)
; compiled with ESP-IDF 4.4.1
[env:esp32_4MB_V4_M]
extends = esp32_4MB_V4_M_base
Expand Down Expand Up @@ -2276,3 +2282,26 @@ lib_deps = ${esp32_4MB_V4_S_base.esp32_lib_deps}
; RAM: [=== ] 25.4% (used 83144 bytes from 327680 bytes)
; Flash: [==========] 96.4% (used 1516029 bytes from 1572864 bytes)
;


[env:adafruit_matrixportal_esp32s3]
platform = espressif32 ; latest
board = adafruit_matrixportal_esp32s3
extends = esp32_4MB_V4_S_base
build_unflags = ${env:esp32S3_8MB_M.build_unflags} ;; use the same as "normal" S3 buildenv
build_flags = ${common.build_flags} ${esp32s3.build_flags} -Wno-misleading-indentation -Wno-format-truncation
${common_mm.build_flags_S}
-D WLED_RELEASE_NAME=matrixportal_esp32s3
-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
-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)
${common_mm.animartrix_build_flags}
${common_mm.build_disable_sync_interfaces}
-D LOLIN_WIFI_FIX ;; try this in case Wifi does not work
-D WLED_WATCHDOG_TIMEOUT=0 -D CONFIG_ASYNC_TCP_USE_WDT=0
-D WLED_USE_PSRAM -DBOARD_HAS_PSRAM ; tells WLED that PSRAM shall be used
-D WLED_ENABLE_HUB75MATRIX -D NO_GFX ;-D SPIRAM_FRAMEBUFFER
-D DEFAULT_LED_TYPE=101
lib_deps = ${esp32_4MB_V4_S_base.esp32_lib_deps}
${common_mm.animartrix_lib_deps}
lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation
monitor_filters = esp32_exception_decoder
232 changes: 232 additions & 0 deletions wled00/bus_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,232 @@ void BusNetwork::cleanup() {
_data = nullptr;
}

// ***************************************************************************

#ifdef WLED_ENABLE_HUB75MATRIX

BusHub75Matrix::BusHub75Matrix(BusConfig &bc) : Bus(bc.type, bc.start, bc.autoWhite) {

mxconfig.double_buff = false; // <------------- Turn on double buffer


fourScanPanel = nullptr;

switch(bc.type) {
case 101:
mxconfig.mx_width = 32;
mxconfig.mx_height = 32;
break;
case 102:
mxconfig.mx_width = 64;
mxconfig.mx_height = 32;
break;
case 103:
mxconfig.mx_width = 64;
mxconfig.mx_height = 64;
break;
case 105:
mxconfig.mx_width = 32 * 2;
mxconfig.mx_height = 32 / 2;
break;
case 106:
mxconfig.mx_width = 64 * 2;
mxconfig.mx_height = 64 / 2;
break;
}

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

if(mxconfig.mx_width >= 64 && (bc.pins[0] > 1)) {
USER_PRINT("WARNING, only single panel can be used of 64 pixel boards due to memory")
mxconfig.chain_length = 1;
}

// mxconfig.driver = HUB75_I2S_CFG::SHIFTREG;

#if defined(ARDUINO_ADAFRUIT_MATRIXPORTAL_ESP32S3) // MatrixPortal ESP32-S3

// https://www.adafruit.com/product/5778

USER_PRINTLN("MatrixPanel_I2S_DMA - Matrix Portal S3 config");

mxconfig.gpio.r1 = 42;
mxconfig.gpio.g1 = 41;
mxconfig.gpio.b1 = 40;
mxconfig.gpio.r2 = 38;
mxconfig.gpio.g2 = 39;
mxconfig.gpio.b2 = 37;

mxconfig.gpio.lat = 47;
mxconfig.gpio.oe = 14;
mxconfig.gpio.clk = 2;

mxconfig.gpio.a = 45;
mxconfig.gpio.b = 36;
mxconfig.gpio.c = 48;
mxconfig.gpio.d = 35;
mxconfig.gpio.e = 21;

#elif defined(ESP32_FORUM_PINOUT) // Common format for boards designed for SmartMatrix

USER_PRINTLN("MatrixPanel_I2S_DMA - ESP32_FORUM_PINOUT");

/*
ESP32 with SmartMatrix's default pinout - ESP32_FORUM_PINOUT

https://github.com/pixelmatix/SmartMatrix/blob/teensylc/src/MatrixHardware_ESP32_V0.h

Can use a board like https://github.com/rorosaurus/esp32-hub75-driver
*/

mxconfig.gpio.r1 = 2;
mxconfig.gpio.g1 = 15;
mxconfig.gpio.b1 = 4;
mxconfig.gpio.r2 = 16;
mxconfig.gpio.g2 = 27;
mxconfig.gpio.b2 = 17;

mxconfig.gpio.lat = 26;
mxconfig.gpio.oe = 25;
mxconfig.gpio.clk = 22;

mxconfig.gpio.a = 5;
mxconfig.gpio.b = 18;
mxconfig.gpio.c = 19;
mxconfig.gpio.d = 21;
mxconfig.gpio.e = 12;

#else
USER_PRINTLN("MatrixPanel_I2S_DMA - Default pins");
/*
https://github.com/mrfaptastic/ESP32-HUB75-MatrixPanel-DMA?tab=readme-ov-file

Boards

https://esp32trinity.com/
https://www.electrodragon.com/product/rgb-matrix-panel-drive-interface-board-for-esp32-dma/

*/
mxconfig.gpio.r1 = 25;
mxconfig.gpio.g1 = 26;
mxconfig.gpio.b1 = 27;
mxconfig.gpio.r2 = 14;
mxconfig.gpio.g2 = 12;
mxconfig.gpio.b2 = 13;

mxconfig.gpio.lat = 4;
mxconfig.gpio.oe = 15;
mxconfig.gpio.clk = 16;

mxconfig.gpio.a = 23;
mxconfig.gpio.b = 19;
mxconfig.gpio.c = 5;
mxconfig.gpio.d = 17;
mxconfig.gpio.e = 18;

#endif


USER_PRINTF("MatrixPanel_I2S_DMA config - %ux%u length: %u\n", mxconfig.mx_width, mxconfig.mx_height, mxconfig.chain_length);

// OK, now we can create our matrix object
display = new MatrixPanel_I2S_DMA(mxconfig);

this->_len = (display->width() * display->height());

pinManager.allocatePin(mxconfig.gpio.r1, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.g1, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.b1, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.r2, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.g2, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.b2, true, PinOwner::HUB75);

pinManager.allocatePin(mxconfig.gpio.lat, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.oe, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.clk, true, PinOwner::HUB75);

pinManager.allocatePin(mxconfig.gpio.a, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.b, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.c, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.d, true, PinOwner::HUB75);
pinManager.allocatePin(mxconfig.gpio.e, true, PinOwner::HUB75);

// display->setLatBlanking(4);

USER_PRINTLN("MatrixPanel_I2S_DMA created");
// let's adjust default brightness
display->setBrightness8(25); // range is 0-255, 0 - 0%, 255 - 100%

// Allocate memory and start DMA display
if( not display->begin() ) {
USER_PRINTLN("****** MatrixPanel_I2S_DMA !KABOOM! I2S memory allocation failed ***********");
return;
}
else {
_valid = true;
}

switch(bc.type) {
case 105:
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_32PX_HIGH");
fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 32, 32);
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_32PX_HIGH);
fourScanPanel->setRotation(0);
break;
case 106:
USER_PRINTLN("MatrixPanel_I2S_DMA FOUR_SCAN_64PX_HIGH");
fourScanPanel = new VirtualMatrixPanel((*display), 1, 1, 64, 64);
fourScanPanel->setPhysicalPanelScanRate(FOUR_SCAN_64PX_HIGH);
fourScanPanel->setRotation(0);
break;
}


USER_PRINTLN("MatrixPanel_I2S_DMA started");
}

void BusHub75Matrix::setPixelColor(uint16_t pix, uint32_t c) {
r = R(c);
g = G(c);
b = B(c);
if(fourScanPanel != nullptr) {
x = pix % fourScanPanel->width();
y = floor(pix / fourScanPanel->width());
fourScanPanel->drawPixelRGB888(x, y, r, g, b);
}
else {
x = pix % display->width();
y = floor(pix / display->width());
display->drawPixelRGB888(x, y, r, g, b);
}
}

void BusHub75Matrix::setBrightness(uint8_t b, bool immediate) {
this->display->setBrightness(b);
}

void BusHub75Matrix::deallocatePins() {

pinManager.deallocatePin(mxconfig.gpio.r1, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.g1, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.b1, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.r2, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.g2, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.b2, PinOwner::HUB75);

pinManager.deallocatePin(mxconfig.gpio.lat, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.oe, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.clk, PinOwner::HUB75);

pinManager.deallocatePin(mxconfig.gpio.a, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.b, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.c, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.d, PinOwner::HUB75);
pinManager.deallocatePin(mxconfig.gpio.e, PinOwner::HUB75);

}
#endif
// ***************************************************************************

//utility to get the approx. memory usage of a given BusConfig
uint32_t BusManager::memUsage(BusConfig &bc) {
Expand All @@ -483,8 +709,14 @@ uint32_t BusManager::memUsage(BusConfig &bc) {

int BusManager::add(BusConfig &bc) {
if (getNumBusses() - getNumVirtualBusses() >= WLED_MAX_BUSSES) return -1;
USER_PRINTF("BusManager::add(bc.type=%u)\n", bc.type);
if (bc.type >= TYPE_NET_DDP_RGB && bc.type < 96) {
busses[numBusses] = new BusNetwork(bc);
#ifdef WLED_ENABLE_HUB75MATRIX
} else if (bc.type >= TYPE_HUB75MATRIX && bc.type <= (TYPE_HUB75MATRIX + 10)) {
USER_PRINTLN("BusManager::add - Adding BusHub75Matrix");
busses[numBusses] = new BusHub75Matrix(bc);
#endif
} else if (IS_DIGITAL(bc.type)) {
busses[numBusses] = new BusDigital(bc, numBusses, colorOrderMap);
} else if (bc.type == TYPE_ONOFF) {
Expand Down
Loading
Loading