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

Add HUB75 support #3777

Open
wants to merge 9 commits into
base: 0_15
Choose a base branch
from
Open

Add HUB75 support #3777

wants to merge 9 commits into from

Conversation

netmindz
Copy link
Contributor

@netmindz netmindz commented Feb 26, 2024

Add support to drive HUB75-compatible LED matrix panels. It's a great way to get started with 2D effects in WLED at very low prices.

@netmindz netmindz marked this pull request as ready for review February 27, 2024 02:09
@robertlipe
Copy link

(I'm not a WLED maintainer. My comments mean nothing.)

Wow! I'm shocked at how cleanly that slots in. Nice. I have both a Matrix S3 and a Mesmerizer (nightdriverled.com) so I may try spinning a build. What kind of frame rates are you seeing on the 2D animations? (We have a lot of the same effects in NightDriver and I've flirted with using the Faptastic HUB75 layer, too...)

Why are ESP32_FORUM_PINOUT, ARDUINO_ADAFRUIT_MATRIXPORTAL_ESP32S3, etc. compile-time flags (and not defined in a derivation of esp32dev_hub75) and not runtme-selectable flags like APA102 vs. WS2814 vs WS2812, etc.?

Given how differently -S3 and -Nothing have to be built, can you really rely on board = esp32dev? Or is this a "draw the rest of the owl" that needs to have another custom_platform_mps3.ini written that derives from an appropriate S3 with the 8MB flash, 2MB PSRAM combination? (https://github.com/platformio/platform-espressif32/blob/master/boards/adafruit_matrixportal_esp32s3.json ?) Do you need help with that, perhaps?

Would this be likely to plan nicely with the Virtual Display (chained panels - limited only by color depth and refresh rates) and UDP/DDP inputs and such?

You can see I'm pretty excited to see this as I've traveled a lot of similar paths. I'm a bit engaged in the short term, but may be able to help land this if you need extra eyes and fingers on it.

Copy link
Collaborator

@blazoncek blazoncek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this already looks great, though I have some remarks.

The most important:

  • no modifications in platformio.ini
  • if possible avoid compile time differentiation

Unfortunately I do not own Hub75 panels but I'll try to work on some enhacnements using logic.

platformio.ini Outdated Show resolved Hide resolved

// mxconfig.driver = HUB75_I2S_CFG::SHIFTREG;

#if defined(ARDUINO_ADAFRUIT_MATRIXPORTAL_ESP32S3) // MatrixPortal ESP32-S3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in another comment, this should in fact be a runtime option.
I know it will/may be a lot of work/selection options, but I hate the idea that such configuration is compile-time based.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit surprised by this comment as I messaged you during the development and specifically discussed the challenges relating to the usability of configuration when so many pins are needed and that they are non configurable if you are using one of the ready made boards such as the Adafruit Matrix Portal S3

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sorry if I forgot, I interact with several (possibly in range of 50) users and developers at any time.
So things may slip my mind and I do not heave the time to revisit all communication made. I apologise.

Nevertheless users may build clones or try their own PCBs following HW layout of the existing boards. So it would be more natural to select any Hub75 compatible board instead of compile-time choice. Similar as it is with Ethernet.

After all, the only difference I can see is in GPIO allocation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ideal solution would be a total refactor whereby the front-end requests what config the bus requires, rather than the current mess of having a large number of elements that you then need to work out what to hide for that bus type. Then you can remove all the isType calls.

But this is of course a big change and should be a PR in it's own right

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it is a mess. Still, a little better than it was.


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

pinManager.allocatePin(mxconfig.gpio.r1, true, PinOwner::HUB75);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also an allocateMultiplePins() method available.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, now I've swapped to this library for the implementation, it supports config of pins by array so I can flip to that and then use the multi call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a struct for the gpio pins, not array so can't really swap over easily

@@ -280,6 +280,9 @@
#define TYPE_LPD8806 52
#define TYPE_P9813 53
#define TYPE_LPD6803 54

#define TYPE_HUB75MATRIX 100 // 100 - 110
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need revisiting as it somehow clashes with @Aircoookie 's bit oriented approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain this comment further?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to hide the fact that this was a bitmasked value in 0.15 macros (check marcos in 0.14 or previous). But I would still like it to follow the original idea of particular bit defining LED type if possible.
There is no need for you to do anything at this point. It was more of a reminder for myself.

@@ -23,6 +23,20 @@
function isD2P(t) { return t > 47 && t < 64; } // is digital 2 pin type
function is16b(t) { return t == 26 || t == 29 } // is digital 16 bit type
function isVir(t) { return t >= 80 && t < 96; } // is virtual type
function isHub75(t) { return t >= 100 && t <= 110; } // is Hub75 type
function hideHub75() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer the other way around. Instead of hiding Hub75 types, insert them into SELECT.
It will require more effort in xml.cpp and some modified code here but should allow for enhancements in the future.

I will tackle this problem and push modifications when I'm done and the solution is viable. No need for you to do anything.

@robertlipe
Copy link

robertlipe commented Feb 27, 2024 via email

@blazoncek
Copy link
Collaborator

Also, if you have PSRAM (and what new ESP32 doesn't these days?) are you really limited to one panel?

PSRAM is slow. Too slow for anything LED related.

@robertlipe
Copy link

robertlipe commented Feb 27, 2024 via email

@netmindz
Copy link
Contributor Author

Wow! I'm shocked at how cleanly that slots in. Nice.
Thanks :)

I have both a Matrix S3 and a Mesmerizer (nightdriverled.com) so I may try spinning a build. What kind of frame rates are you seeing on the 2D animations? (We have a lot of the same effects in NightDriver and I've flirted with using the Faptastic HUB75 layer, too...)

I'm having real issues with wifi with the Matrix S3, so will be interesting to see if you see the same.

Why are ESP32_FORUM_PINOUT, ARDUINO_ADAFRUIT_MATRIXPORTAL_ESP32S3, etc. compile-time flags (and not defined in a derivation of esp32dev_hub75) and not runtme-selectable flags like APA102 vs. WS2814 vs WS2812, etc.?

If you are using the matrix portal, you can't change the pins, so no point asking the user to enter 14 pins. For other boards, just lazy ;)

Given how differently -S3 and -Nothing have to be built, can you really rely on board = esp32dev? Or is this a "draw the rest of the owl" that needs to have another custom_platform_mps3.ini written that derives from an appropriate S3 with the 8MB flash, 2MB PSRAM combination? (https://github.com/platformio/platform-espressif32/blob/master/boards/adafruit_matrixportal_esp32s3.json ?) Do you need help with that, perhaps?

The example env just shows what options you need to enable this feature. If you aren't using a regular esp32 then you need to add the extra options to the env for your board

Would this be likely to plan nicely with the Virtual Display (chained panels - limited only by color depth and refresh rates) and UDP/DDP inputs and such?

In theory yes you could use DDP then Hub75 output or mix of Hub75 and other output types

You can see I'm pretty excited to see this as I've traveled a lot of similar paths. I'm a bit engaged in the short term, but may be able to help land this if you need extra eyes and fingers on it.

Great

@netmindz
Copy link
Contributor Author

Also, if you have PSRAM (and what new ESP32 doesn't these days?) are you
really limited to one panel?

You are not limited to single panels. At the moment it will allow you to select up to 4 panels of 32x32 in horizontal configuration. We can add other layouts later

The ESP32-S3s always have octal PSRAM and can
DMA to and from it

The library being used does allow PSRAM use

@robertlipe
Copy link

Rats. The email gateway ate my response:

I finally tried to check this tree out and build it for MatrixS3. I may fumble with WLED and GitHub, but I'm not an inexperienced dev, so please stick with me.

$ gh repo clone netmindz/WLED hub75-wled
Branches didn't come across, so I did
$ git checkout 421c470
and confirmed the HUB75 changes were in the git log.

$ pio run -e adafruit_matrixportal_s3_hub75

npm run build
[ ... ]

wled@0.15.0-b1 build
node tools/cdata.js

node:internal/modules/cjs/loader:1146
throw err;
^

Error: Cannot find module 'inliner'
Require stack:

  • /Users/robertlipe/src/nightdriverstrip/hub75-wled/tools/cdata.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Module.require (node:internal/modules/cjs/loader:1234:19)
    at require (node:internal/modules/helpers:176:18)
    at Object. (/Users/robertlipe/src/nightdriverstrip/hub75-wled/tools/cdata.js:20:17)
    at Module._compile (node:internal/modules/cjs/loader:1375:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1434:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:142:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/Users/robertlipe/src/nightdriverstrip/hub75-wled/tools/cdata.js'
    ]
    }

I don't do Node, so I'm stumped on that one. (I have built WLED directly for another S3 board from teh main repo about a month ago...)

If I restart it, it starts to chow down on the CPP code:
Compiling .pio/build/adafruit_matrixportal_s3_hub75/lib7c9/FastLED/FastLED.cpp.o
Compiling .pio/build/adafruit_matrixportal_s3_hub75/lib7c9/FastLED/hsv2rgb.cpp.o
: warning: "ARDUINO_USB_CDC_ON_BOOT" redefined
: note: this is the location of the previous definition
In file included from /Users/robertlipe/.platformio/packages/toolchain-xtensa-esp32s3/xtensa-esp32s3-elf/sys-include/sys/reent.h:503,
from /Users/robertlipe/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32s3/include/newlib/platform_include/sys/reent.h:17,
from /Users/robertlipe/.platformio/packages/toolchain-xtensa-esp32s3/xtensa-esp32s3-elf/sys-include/stdio.h:60,
from /Users/robertlipe/.platformio/packages/framework-arduinoespressif32/cores/esp32/esp32-hal.h:25,
from .pio/libdeps/adafruit_matrixportal_s3_hub75/FastLED/src/platforms/esp/32/led_sysdefs_esp32.h:2,
from .pio/libdeps/adafruit_matrixportal_s3_hub75/FastLED/src/led_sysdefs.h:42,
from .pio/libdeps/adafruit_matrixportal_s3_hub75/FastLED/src/FastLED.h:51,
from .pio/libdeps/adafruit_matrixportal_s3_hub75/FastLED/src/bitswap.cpp:7:
/Users/robertlipe/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32s3/include/newlib/platform_include/assert.h:20:10: fatal error: sdkconfig.h: No such file or directory

I agree. There is an assert.h there and it's trying to include an <sdkconfig.h>, but none is in the system header path.

If I look at all the sdkconfig.h's on my entire system, I think the pattern is "projects built with idf.py, not platformio", but I'm not certain of that pattern.

If I change strategies to:
$ pio run -e esp32s3dev_8MB_PSRAM_qspi
I still get the failure in node.js

and the C++ compilles until it gets to
wled00/wled_server.cpp:3:10: fatal error: html_ui.h: No such file or directory
The only html_ui.h I have is in that aforementioned wled build directory, which makes me suspect this is a generated file. I can't help but wonder if it's generated in a step that comes after that nodejs failure.

But that same assert.h is still trying to include a sdkconfig.h that still doesn't exist, so there must be something else going on. I suspect we're getting the wrong assert.h

I see adafruit_matrixportal_esp32s3.json in .platformio/platforms/espressif32/boards so I don't think this board is too new to be supported by platformio, but it would be totally on brand for them to not print "something not found" and just blunder on with the wrong one if they did. (My relationship with PlatformIO is strained.) OTOH, it's clearly finding at JSON because it's expanding out the full name:
PLATFORM: Espressif 32 (6.5.0) > Adafruit MatrixPortal ESP32-S3
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash

So I guess this is a three part question:

  1. What's the solution to the Error: Cannot find module 'inliner' ?
    1a) Is this what's preventing html_ui.h from being built? (Assuming it's generated at all since it's no in my checkout)
  2. Is there something else required to build the adafruit_matrixportal_s3_hub75 target? Maybe something magic in Platformio or arduino32?

As a sanity check $pio run -e esp32dev_hub75 has the same issue with html_ui.h and with node, but does find a happy assert.h.

So I think I just have startup blues. Should this be expected to build from this basic recipe? Is this perhaps divergence from the two wled trees?

Thanx for the hand.

@netmindz
Copy link
Contributor Author

netmindz commented Mar 5, 2024

The simple option @robertlipe would just be to use this ready-made bin

https://github.com/netmindz/WLED/actions/runs/8056668690/artifacts/1276931005

@netmindz
Copy link
Contributor Author

netmindz commented Mar 5, 2024

If you are trying to build from source, you need to run

npm install

To have the right modules installed needed for inliner

@robertlipe
Copy link

robertlipe commented Mar 5, 2024 via email

@netmindz
Copy link
Contributor Author

netmindz commented Mar 5, 2024

@robertlipe - I suspect the wrong version of the platform is being used. We have the option to build on V4, which is what I use for the MoonModules#108

@lboue
Copy link

lboue commented Mar 10, 2024

Thanks @netmindz. I also have Adafruit MatrixPortal S3 board. I will try this.

@lboue
Copy link

lboue commented Mar 10, 2024

The simple option @robertlipe would just be to use this ready-made bin

https://github.com/netmindz/WLED/actions/runs/8056668690/artifacts/1276931005

Should I use the following command to flash Adafruit MatrixPortal S3 board?

esptool.py write_flash 0x10000 adafruit_matrixportal_esp32s3.bin

@netmindz
Copy link
Contributor Author

The simple option @robertlipe would just be to use this ready-made bin

https://github.com/netmindz/WLED/actions/runs/8056668690/artifacts/1276931005

Should I use the following command to flash Adafruit MatrixPortal S3 board?

esptool.py write_flash 0x10000 adafruit_matrixportal_esp32s3.bin

Not sure about that, I just tend to goto the manual ota page of an existing WLED install and upload the bin

@lboue
Copy link

lboue commented Mar 10, 2024

Not sure about that, I just tend to goto the manual ota page of an existing WLED install and upload the bin

Which firmware file did you use for WLED install before going to the manual ota page and upload your HUB75 version?
https://github.com/Aircoookie/WLED/releases/tag/v0.14.1

  • WLED_0.14.1_ESP32-S3_16MB_PSRAM_opi.bin
  • WLED_0.14.1_ESP32-S3_8MB.bin
  • WLED_0.14.1_ESP32-S3_8MB_PSRAM_opi.bin
  • WLED_0.14.1_ESP32-S3_8MB_PSRAM_qspi.bin

@netmindz
Copy link
Contributor Author

Not sure about that, I just tend to goto the manual ota page of an existing WLED install and upload the bin

Which firmware file did you use for WLED install before going to the manual ota page and upload your HUB75 version? https://github.com/Aircoookie/WLED/releases/tag/v0.14.1

  • WLED_0.14.1_ESP32-S3_16MB_PSRAM_opi.bin
  • WLED_0.14.1_ESP32-S3_8MB.bin
  • WLED_0.14.1_ESP32-S3_8MB_PSRAM_opi.bin
  • WLED_0.14.1_ESP32-S3_8MB_PSRAM_qspi.bin

Ah, for the matrix3 I didn't actually try a regular install, just went directly to building from source. Does the web installer give a basic working setup? https://install.wled.me/

@lboue
Copy link

lboue commented Apr 14, 2024

@netmindz
Any news about this PR?

@Linjieqiang
Copy link

Any news about this PR? I have 5 pcs led matrix board

@netmindz
Copy link
Contributor Author

netmindz commented Apr 15, 2024

There is support for hub75 in the latest MoonModules builds, just use V4_S or V4_M builds

As for support in AirCookie, @blazoncek said he would be updating the PR to address an issue he thought was a blocker to accpeting
#3777 (comment)

@blazoncek blazoncek added enhancement keep This issue will never become stale/closed automatically labels Apr 15, 2024
@blazoncek
Copy link
Collaborator

@netmindz I've tried to come up with a better solution regarding conditional UI elements for setting options for Hub panels.
Unfortunately I was not successful as that would require redesign of whole LED settings page and bus manager logic together with available LED types. I tried that but ended efforts as there was too little gain for too much work in the end.

I can see 2 ways forward as a result of this: a) make Hub 75 panels regular option and not a conditional compile or b) not support Hub 75 at all

For a) that would probably increase code size which most users would rather see used by other usermods instead (current flash utilisation is already above 95% while we are still with ESP32 core 3.5.0, newer cores add substantial amount to this).

There is of course still possibility to keep PR as is and hide Hub panels in 99.9% of installations at the expense of few wasted bytes for never used UI elements. I cannot decide either way so I'll leave the decision to @Aircoookie. I have marked the PR with keep label so it will not become stale.

For anyone else interested please upvote this PR so we can see how much interest is there and decide upon it.

@netmindz
Copy link
Contributor Author

Swapping to add the options to the drop-down rather than removing is the smaller problem to solve.

As we have discussed, the bigger issue is that of the pin configuration.

The "proper" fix would be for the UI to query the bus manager to ask what the config choices should be. This would both remove the need for the UI to selectively hide/rename the config choices and also mean that adding new options like say which predefined combination of pins you are using for hub75 could come from the specific bus type class

@blazoncek
Copy link
Collaborator

The "proper" fix would be for the UI to query the bus manager to ask what the config choices should be. This would both remove the need for the UI to selectively hide/rename the config choices and also mean that adding new options like say which predefined combination of pins you are using for hub75 could come from the specific bus type class

Yes, that's what I was referring to. There is no such way ATM (to query) and hence needs hardcoded info in HTML files.

The other problem is also the increase of binary files themselves as mentioned which must not be underestimated as there are several enhancements in the pipeline that require quite a few more bytes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement keep This issue will never become stale/closed automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants