MoonModules / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi! MoonModules adds features on top of upstream.
https://mm.kno.wled.ge
European Union Public License 1.2
224 stars 68 forks source link

Best way to use GIFs with HUB75 screens. #172

Open 1liminal1 opened 2 weeks ago

1liminal1 commented 2 weeks ago

Is your feature request related to a problem? Please describe. I have a HUB75 64x64 screen that I'm using in a BMO. I want to create a face and then have it go to an effect after 3 seconds or so.

IMG_1739

Ive tried using https://github.com/ajotanc/PixelMagicTool But 64x64 may not work;

https://github.com/ajotanc/PixelMagicTool/issues/4#issuecomment-2431751858

Ive tried using https://github.com/werkstrom/WLED-PixelArtConverter/ and while this does allow me to upload frames to the device, I cant seem to save these as presets. (well I can, but they dont seem to save as different "images" though I see the different images on the HUB75 device. I posted about this issue here https://discord.com/channels/700041398778331156/1298611305002831912/1298611309029490708)

Describe the solution you'd like An easy way to add pixel art to WLED with either

Gif branch https://github.com/Aircoookie/WLED/tree/gif , the bins are here if you cant compile from source https://github.com/dosipod/WLED_gif_update/actions/runs/10116313741 , as I re-based that on 15 Usermod (client and server ) https://github.com/hughc/wled-pixelart-client

Describe alternatives you've considered Stated above

Additional context Add any other context or screenshots about the feature request here.

Thank you for your ideas for making WLED better!

softhack007 commented 1 week ago

Hi, nice project 😃

the main problem with all options is available RAM. The HUB75 driver is very hungry for RAM, however storing a 64x64 bitmap in a preset creates a huge JSON file that cannot be parsed / read on classic esp32 due to size. Are you using esp32, or esp32-S3? On an esp32-S3 with PSRAM you might be lucky, and it could work.

As alternative solution, try to make your "face" segment smaller than the panel - like 32x32 or maybe 24x24. For a smaller segment, it should be possible to show a pixel graphic.

Or - in case you don't mind a "blocky" look - you can set the segment to "grouping: 2" (plus "spacing: 1" for real blocks) and keep it at full 64x64 size.

softhack007 commented 1 week ago

@1liminal1 @dosipod I've played with images a bit. WLEDMM needed a small patch to display images from json or preset --> https://github.com/MoonModules/WLED/commit/f14c4cbe5b42974237a6b5c7de1f4afc255029fc

Now it works the same way as in upstream.

Using PixelArtConverter, i was able to upload images to my HUB75 test setup (esp32-S3 with PSRAM, 128x64 HUB75 panel).

image


Copy & Paste for creating a 64x64 preset first did not work, but I managed with a bit of manual "post-processing". Basicially you need to join all the sections manually; i.e. join the array segments into one array --> use one , to replace ]}} <NEXT COMMAND (multiple commands not supported in API/preset setup)> {"on":true,"bri":128,"seg":{"id":0,"i":[

If you want to test something, copy everything from the attached file into a new preset in WLEDMM: preset64x64_donkey.json It should display our king from the 1980's.

For the future, we could look into adopting the "GIF" branch from Aircoookie. Plus there is a nice API from espressif for loading JPG files, which we could use to add a "static background" for effects.

Edit: PNG seems promising, too. However decoding a PNG requires lots of RAM (>50KB). We could check if NetPBM formats (.ppm, .pnm) work better.

dosipod commented 1 week ago

@softhack007 Excellent and I will surely test that . I would just like to mention that PixelArtConverter was not really meant to be used with gifs but rather with pics and I was closely involved with the owner during initial stage and sadly he is not having the time to improve it when it comes to gif and the use of playlist and multiple presets is a door to a lot of issues even if that is used with small matrix on a normal esp32 . Adopting the "GIF" branch from AC might be something to focus on long term as it is truly better when we tested and I would really love to see that on MM or HUB75 is added to AC . The usermod is also very much a good option which I personally use and solved the space issue but might be the standalone option is what is practical at this time for the masses . Thank you .

1liminal1 commented 1 week ago

Copy & Paste for creating a 64x64 preset first did not work, but I managed with a bit of manual "post-processing". Basicially you need to join all the sections manually; i.e. join the array segments into one array --> use one , to replace ]}} <NEXT COMMAND (multiple commands not supported in API/preset setup)> {"on":true,"bri":128,"seg":{"id":0,"i":[

Thanks so much for that :) I thought that might be the case and tried joining the parts last week, but I guess I need that update? Is that now in the nightly for MM? (LOL, Im prob getting the lingo wrong, I come from a systems background) Let me know and I'll update.

Im guessing I need to wait till its the 29th? I'm not really sure how these things work;

https://wled-install.github.io/

image

Ill test the DK json when I get home and let you know if that works. If I can get three frames of BMOs face in a playlist ill be happy :)

The plan is that a mmwave will turn him on when I walk in the room, it's his face for 3s and then goes to soap or something :) I think it will be cool. Ill be posting the remix for the STLs at some point, if you love BMO and want to make him, I'll post the link at some point :)

1liminal1 commented 1 week ago

The usermod is also very much a good option which I personally use and solved the space issue but might be the standalone option is what is practical at this time for the masses .

Ok, so you're saying if I use the https://github.com/hughc/wled-pixelart-client this as a usermod and compile my own binary, it will work?

Sorry to be a pain, I have compiled stuff before, but just to be clear, so I download the MM code base(?) and then following these instructions

https://mm.kno.wled.ge/advanced/compiling-wled/

Set up VSCode and PlatformIO ect and then following the instructions on wled-pixelart-client to get the usermod to add in the usermod. And this will have hub75. Or I need to add that as well?

1liminal1 commented 1 week ago

Oh, and last comment lol. Im using a Trinity ESP32

dosipod commented 1 week ago

For the usermod ,you would have to add it to MM first , i have added it to AC here https://github.com/dosipod/WLED_15/tree/ALDIY_15/usermods/pixelart_client and then try it with MM HUB75 bin which i never did .

I am not really sure of how stable HUB75 on a esp32 as I faced issue with that a while back so I got HD-WF2 and it works fine ( this is a cheap s3 board ) https://www.aliexpress.com/item/1005002258734810.html You might also want to take a peek at what is done with HUB75 panels in MM discord https://discord.gg/JxHzbzu5 as I am a bit out of touch with that but will for sure do a lot of hardcore testing around December as I will be getting more HW and guys to help in testing if all goes to plan

Cheers

1liminal1 commented 1 week ago

Awesome :) thanks for that.

Im happy to help testing as well. I have a few more HUB75 64x64 and Trintys coming. I want to see if I can string 3 64x64s together and make one of my Prisms out of it. WHen you see some of the things Troy is doing with HUB75 on the S3 with 128x128... Its just amazing!

dosipod commented 1 week ago

That is good you are aware of what is going on , since you are aware of what Troy is doing ,might be you are on discord already and I think that would be the place to help for testing but not really sure about using more "Trintys" as it seems to be too much for esp32 vs s3 board I listed if the performance okay for you then why not

1liminal1 commented 1 week ago

HAHA, we have spoken a couple of times on Discord :) You and Wildcats helped me with Pixel Mapping for my prisms.

image

I actually posted in support and the standard WLED discord about this

image

But its easy for things to get lost on Discord, people are busy with their own projects ect ect. SO thanks for taking the time to give me some advice, I appreciate it :)

https://esp32trinity.com/

This is the Trinity, its working well actually with any of the default effects. Not sure how it will scale, but will see.

softhack007 commented 1 week ago

This is the Trinity, its working well actually with any of the default effects. Not sure how it will scale, but will see.

Hi @1liminal1, the trinity is based on "classic" esp32, right? Esp32 works well up to 64x64, but it gets unstable if you have a larger setup with more panels.

For more than 64x64 pixels HUB75, you should use esp32-S3 - preferably with octal PSRAM.

See https://mm.kno.wled.ge/2D/HUB75/#panel-size-and-chain-length

dosipod commented 1 week ago

I have only tested MM briefly on a normal esp32 I was using with https://github.com/mrcodetastic/ESP32-HUB75-MatrixPanel-DMA and in that I faced few issues but might be that is fixed or something about trinity that is different . It is still the case that the guys recommend s3 hence I got HD-WF2 but I also only plan to use single 64x64 per esp so might be esp32 is okay . And I thought the avatar looked familiar :)

1liminal1 commented 1 week ago

Apologies guys, I haven't had time to test the JSON or do any more testing with the Trinity.

Too many projects!!! LOL been working on this Retro Pi BMO :)

image

But hopefully ill get to it tomorrow.

Thanks again for taking the time to help me with this :)

dosipod commented 6 days ago

I normally do not like to send others on a wild guess chase so I was trying to test each option and the first one is the usermod which I have now added to MM but the size was an issue so i had to kill animatrix for it to fit on the HD-WF2 s3 board

image The bin i used is the env esp32S3_4MB_S_ALDIY in here https://github.com/dosipod/MM_OCT_29/blob/mdev/platformio.ini

After that some of the pics worked okayish ( some crashes are there ) but gifs never worked at all on HD-WF2 , i have a node.js local server somewhere which i could try also but things do not look so promising . The full video of the test is too large to fit here so I had to reduce the size mm_gif_07

softhack007 commented 6 days ago

After that some of the pics worked okayish ( some crashes are there ) but gifs never worked at all on HD-WF2

@1liminal1 @dosipod the "unexpected restart" messages might be a crash when free RAM on your device went too low. You'll find "Heap" and "Max used heap" on the info page - if these values are around 85% or above, usually WLED-MM gets unstable.

You could tinker with the HUB75 bit depth limits in the code to gain some free RAM: https://github.com/MoonModules/WLED/blob/85035e54e852cb837f19451c6a469c45f0ea8a8a/wled00/bus_manager.cpp#L555-L558

for example, replace with lower values from the -S2 section which gives you 4bit (instead of 8) on 64x64

  #define MAX_PIXELS_8BIT ( 48 * 48)
  #define MAX_PIXELS_6BIT ( 64 * 48)
  #define MAX_PIXELS_4BIT ( 96 * 64)
softhack007 commented 6 days ago

@dosipod another way of saving a bit on RAM is by adding this to your build_flags

  -D JSON_BUFFER_SIZE=18432 -D MIN_HEAP_SIZE=6144

or even try lower values for JSON_BUFFER_SIZE (minimum size is ~12000). This might work for the "usermod" option, but it won't work with other options that send images via JSON API.


Edit: another workaround if RAM is very low:

  -D WLED_DISABLE_WEBSOCKETS

This removes "live preview", but it also reduces RAM fragmentation (ws is very wild on malloc/free) and could make your firmware more stable.

dosipod commented 6 days ago

@softhack007 I will try all you listed as I have setup node.js locally now but seeing a bit of odd behavior when testing on latest AC which may have to do with the gif sizes ( the same gifs worked fine on AC gif branch ) and once i sort that out I will for sure test a lot on MM , I am still hoping that might be with the change of license that we could focus on the end goal ( either gif branch on MM or HUB75 on ac ) as this is just a temporary option but will try our best .

dosipod commented 6 days ago

@softhack007 Thank you , I updated bus_manager.cpp and also set the build flag as you listed -D JSON_BUFFER_SIZE=18432 -D MIN_HEAP_SIZE=6144 -D WLED_DISABLE_WEBSOCKETS

And HD-WF2 is really much more stable now and the pics playlist works fine exactly the same as on AC esp32 with 16x16 matrix , so that is for sure a good progress . Gifs are still not stable but some of them worked and I will do more stress testing from xlights just to make sure too much traffic is not the cause although I suspect we might need to reduce the files sizes even further . I could not add video here at the moment but will do once we have a good progress with gifs . Really appreciate your quick response and help on this Maestro.

1liminal1 commented 4 days ago

Hey guys, Just going though the posts now.

I have ordered some HD-WF2, wish I had of known about those before I ordered the Trinitys, far far cheaper :( lol, Anyway.

If you want to test something, copy everything from the attached file into a new preset in WLEDMM: preset64x64_donkey.json It should display our king from the 1980's.

So, just to be clear, I copy the json and put it into a preset yes? I get this error.

image

I am not really sure of how stable HUB75 on a esp32 as I faced issue with that a while back so I got HD-WF2 and it works fine ( this is a cheap s3 board )

I missed that before :( lol, wish I had of seen that before ordering more Trinities LOL

So I guess the Trinities are a dead end lol

OK, so I just tried merging my own file and it only reads the first few lines. I guess that's why pixel art splits them in the first place.

So I tried making a playlist out of that and it does work;

https://github.com/user-attachments/assets/b30dd36f-3f2a-402b-a883-41ca72e76fa5

But the issue is I added soap to the end and when It tries to play that it just goes turns off (I see the power button on the webUI go off).

image

Also I cant set the playlist lengthy for anything less then 1 sec, so its super janky anyway lol

EDIT!

SO I managed to get soap to play at the end, it was just presets being presets lol

BUT, Is there anyway to speed up the preset playing so that the playlist will play everything at once?

"playlist":{"ps":[1,2,3],"dur":[01,01,30]

I tried changing it to 01,01,30 but I cant seem to edit it directly :(

Ahh!!! min duration is 0.2

Nice :)..

dosipod commented 2 days ago

@softhack007 @1liminal1 A stable workaround found , I used the gif branch ( only changed MAX_LEDS_PER_BUS 4096 in const.h so I could use DDP with 64x64 running on MM ) https://github.com/dosipod/WLED_gif_update/tree/gif_64x64 https://github.com/dosipod/WLED_gif_update/actions/runs/11676697887 ( use firmware-ALDIY_esp32dev_audioreactive_gif.bin ) And behold gifs are working on 64x64 without any issue . The below video is from a classic esp32 running AC 15.0.b4 gif branch and controlling MM build with hub75 64x64 mm_gif_via_ddp

Might be we could see value in adding gifs to MM else this will have to do for now