#WLED-MM-P4 USB JPEG Magic

167 messages · Page 1 of 1 (latest)

tulip willow
#

A lot to explain, but basically:

  1. My own WS281x driver, via Parallel IO on the P4. 16 Pins of hardware accelerated goodness and no extra hardware.

  2. "Raw" pixel data access. You don't need to draw pixel by pixel any more. Bitmaps are cool.

  3. USB Mass Storage is working. You can hot plug USB drives into a running system. You can even mount two. Storage limitations are now gone.

  4. Pixel Processing Accelerator pipelines are fully working. Memory is now 2D-aware and RGB enabled.

  5. JPEG decoder working. Bitmaps are smaller.

  6. Combine 2,3,4,5 and we can steam image sequences off the USB disk live - and live rescale them as we like - to a certain extent. It only can downscale to 0.1 so below that maybe needs 2 steps but so far so good. 😁

This is 6 proof-of-concepts in a trenchcoat so it's far from optimized - but it's stable.

tulip willow
#

You can read more about what the Pixel Processing Accelerator can do here:

https://docs.espressif.com/projects/esp-idf/en/stable/esp32p4/api-reference/peripherals/ppa.html

Basically memory is 2D-DMA, so you can address a block of RGB memory as a 2D rectangle. No need to think about translating X,Y - just tell it to use X,Y,X2,Y2.

This also has optional alpha channels, so 2D bitmaps can be "ARGB" and compositing them together will do transparency effects on the fly.

Sadly it's "just" rectangles and rotations are 90° increments only, but it's quick.

tulip willow
#

This is a 128x64 image sequence of 120 JPEG frames on the USB disk.

At an output of 128x64 it can just decode->display, but at 128x128 it needs to decode->scale->display.

Still pretty quick. Less images is also faster... my original "globe" tests had 900 frames and that seems to bog down the USB Mass Storage stuffs and was running between 30 and 8 FPS. Less frames are running MUCH faster.

tulip willow
crimson echo
#

that is... wow!

#

Can we have a look at your code? can you share your branch? that is truely awesome. Maybe that can be "merged" with the "GIF image" effect? or this is too specific and tied to the hardware platform? (PPA unfortunately only available on esp32P4...) is this a usermod or in code and use compilation flags?

latent quarry
#

Awesome

tulip willow
tulip willow
#

Lots of new stuff today - a little attempt at Resolume-style "video" effects via the PPA

tulip willow
#

PSRAM for caching has really shown it's the USB and the very common "bunch of tiny files" problem found on just about every OS in existence.... that's what is making it "slow".

Move it into PSRAM and it absolutely screams.

tulip willow
#

Now it caches everything - in the background - into PSRAM, keeping 80% free. We have 32MB so that's a LOT of tiny JPEG files.

#

And also a full set of Transforms which work in real-time.

latent quarry
#

Great job Troy 👍🏻

tulip willow
#

This is all pretty easy as well. The Transforms are all done in the PPA, so anyone can code things that use the PPA in WLED-MM-P4 without much knowledge.

It's very much abstracted by Espressif for ease of use.

#

What I really wanted was MIDI-over-USB to be working, but right now you can only have High-Speed (USB drives) or Full-Speed devices in use at once.

That's on Espressif's TODO list. 😁

I thought "video" was more interesting.

golden panther
tulip willow
# golden panther Does using a hub in between work? Iirc on some legacy macs running newer unsuppo...

There ARE hubs with "Multi-TT" that might be useful, yes. I don't know in which direction - but they are mentioned in the Espressif documentation.

If it moves High-Speed down to Full-Speed that's not as useful.

If it's Full-Speed up to High-Speed that could work?

Hubs do absolutely work with the ESP32-P4. This board actually has a hub chip inside it for all the ports - but it doesn't appear to be the kind that converts things.

Either way, I did find a WaveShare USB hub that claims to have MTT. I'll give it a shot tomorrow. 😁

golden panther
tulip willow
golden panther
tulip willow
tulip willow
# golden panther I know some real midi devices use usb 2 so couldn’t you technically just get ano...

I don't think the USB Host mode will work even with a fancier MTT USB hub now that I read the docs a bit more closely:

"The External Hub Driver: No Transaction Translator layer (No FS/LS Devices support when a Hub is attached to HS Host)."

This doesn't seem like a "to be fixed" - just how it goes.

"ESP32-P4 includes two USB 2.0 OTG peripherals: one High-Speed and one Full-Speed. Both support USB Host functionality. However, due to a current software limitation, only one can operate as a USB Host at a time. Support for dual USB Host operation is planned for a future update."

golden panther
#

Or a P4 + MAX3421E

tulip willow
#

@golden panther I'm kidding-not-kidding. The ESP32-P4 has been a solo adventure and I'm surprised I've gotten this far.

Any assistance would be extremely welcomed.

golden panther
#

I genuinely do have 2 spare P4 boards and a max chip lol, I just don’t enough experience with c++ and the esp idf

tulip willow
#

@golden panther I was excited to find I had another MIDI controller in my pile of random that's USB-C, but it's still FS, not HS, despite the USB-C connector.

Damn you, backwards protocol and pin compatibility!

#

@golden panthercome be a developer! You know you wanna.

golden panther
#

I might take a look in a few days once I get the chance but most of my experience is with python and AI doesn’t know shit about the esp32 p4

tulip willow
golden panther
tulip willow
#

With the new ImageCacheManager background task pumping away, it's just a random and occasional USB error crash that seems to be Espressif's issue to worry about. I'll finally get to submit an Issue. 😁

turbid basin
#

I was wondering if using MicroSD would change that but looking at the waveshare board, it doesn't have it 😛

#

Oh no wait it does, on the back 😛

tulip willow
# turbid basin I was wondering if using MicroSD would change that but looking at the waveshare ...

Yeah, SD card is on the list as well.

The nice thing about this new ImageCacheManager is that it shouldn't care where you're caching from. I can most certainly extend it to "add multiple paths" so you could be storing and caching from multiple places.

The other thinking is loading configs, presets, LED maps, firmware updates, etc from external storage.

That may mean still keeping a copy on flash as a failsafe, but otherwise you could plug in a USB drive (or SD card) with your config

turbid basin
tulip willow
# turbid basin Yeah that's certainly cool. I know in the Chirstmas type of community, being abl...

Honestly I don't think it'll be too terribly hard to get SD working.

USB Mass Storage is working, SD should be comparatively simple.

IDFv5 was extremely scary when I started but now it's becoming much more friendly to my brain. I'm seeing the patterns in how everything is being laid out.

Also learning C++ as you go means lots of missteps. 40+ years of programming experience gives me the required programming patterns, but there's still a lot to learn.

I never thought I'd get it this far. 😁

turbid basin
teal fjord
tulip willow
# teal fjord Can you recommend a P4 dev board for testing? I've been looking at your repo and...

No need to hot air.

This one is good and you can get 26-pin ribbon cables with 26-pin screw terminal breakout boards.

https://www.waveshare.com/esp32-p4-nano.htm

#

Sadly there's only 15 usable pins on the best side. 😁

#

This is my general dev board because it has 4 USB-A ports.

https://www.waveshare.com/esp32-p4-module-dev-kit.htm

There's also this version which came out a bit later and I guess has 3.5mm output (sadly not input) and the same 4 USB-A ports. I don't see a difference otherwise.

https://www.waveshare.com/esp32-p4-wifi6-dev-kit.htm

teal fjord
#

Thanks, I'll check those out

teal fjord
teal fjord
tulip willow
tulip willow
# teal fjord Is your branch geared around a particular board?

Not in particular.

I can confirm the WaveShare ones I listed are the best.

I own just about every P4 board in existence, and those 3 are the ones I recommend.

The Parallel IO system uses hardcoded GPIOs at the moment, but it's entirely possible to ask for every GPIO and it'll just pick the ones not in use.

The nice thing about the P4 is that the pins that are for peripherals are generally hidden. Like you don't need to exclude the camera or display or PSRAM pins, those are not "GPIOs" in the list.

teal fjord
tulip willow
# teal fjord Thanks for the detailed explanation, I'll grab a wave share board.

Boards NOT to buy;

Espressif's original ESP32-P4 EV board. Beta version of the P4 chip, which has issues.

Wireless-Tag version of the P4 board which actually has an ESP32-C5 on it so it can do 5Ghz WiFi in theory. It's all kinds of weird and the C5 doesn't even have the WiFi firmware (ESP-Hosted) on it. Works fine on Ethernet but doesn't do WiFi because the C5 is barely supported by Espressif at the moment and support didn't exist at all when they made the board. I may support it eventually but it's not correct at the moment. It will also require additional steps that I don't even have instructions for.

...and many of the other P4 boards have some sort of drawbacks or issues during testing. Most work fine for the basics but have different bugs with other things.

#

⚠️ Also at the moment your WiFi setup is entirely hard coded during build. I need to fix that. There's no SoftAP mode for setup and the wireless setup page in WLED is ignored, even if you get in over Ethernet and change the WiFi credentials.

Both of these are up next for fixes.

I don't recommend using WiFi anyway - this level of power you really want Ethernet. But it'll be fixed in the next few weeks.

teal fjord
#

100% agree, I'm looking at driving 3072 LEDs and the WiFi throughout is definitely causing lag

tulip willow
teal fjord
#

It's just the jitter when running DDP to the device, I have a fairly busy WiFi environment and experience has taught me to use wired if I care about any sort of realtime performance.

turbid basin
tulip willow
tulip willow
# turbid basin I actually also looked at using the ESP32-C5 in my design I'm working on but nex...

The answer is "not much but still a measurable amount".

I noticed a small percentage less FPS when WiFi was just simply enabled. The tasks run at like 25 priority and they don't do much when Ethernet is enabled - but still "some" CPU is eaten. Not a lot, just enough for the tasks. But still any active connection is chatty nowadays.

When you're chasing FPS and A/B testing you can see a slight decrease. Otherwise fine.

turbid basin
latent quarry
#

Hey @tulip willow ,

Thanks for the awesome project! From the title, I understand that it displays JPEGs from a USB drive. I noticed there’s a “PPA Tester” effect shown in the video, and it seems that the slider is used to select JPEG files — is that correct?

I don’t have a P4 board, but I do have an ESP32-S3 with USB OTG support. Would it be possible to run this project on the ESP32-S3, or is the S3 not powerful enough to handle JPEG decoding and display?

For reference, I’m using a 128×64 HUB75 LED panel.

Thanks again for your work and time!

tulip willow
#

The next stage is MJPEG files, so you don't need image sequences. That might also speed things up a bit as it's not dealing with tons of tiny files.

latent quarry
#

But. I can use USB thumb drive to otg as storage.

latent quarry
#

Is decoding MJPEGs is easier than GIF .

tulip willow
tulip willow
tulip willow
#

Ok, fine... touch screen is working - and the start of a GUI.

Preview is auto scaling (128x64 to 720x360 here) and limited to 30 updates per second. PPA is doing the heavy lifting.

The information bar is drawn every second, and the button bar is displayed if the state changes.

The GUI graphics library is LovyanGFX as they have a nice simple system that doesn't require directly driving a screen and can output RGB888 or ARGB8888 if you need alpha blending. This is very easily integrated with the PPA.

FPS is showing Art-Net output as this box doesn't have any pins - but even without physical outputs, it could make for a very nice WLED remote.

The box is from WaveShare and is meant to be wall-mounted into a standard electrical box. There are also two simple to use relays and even RS-485 if you wanted to use DMX. It can accept any DC power from 6v to 30v via screw terminals on the back, making for a very clean installation.

Audio isn't working yet on this particular model. Same pins, same codec, but they added some echo cancellation thingy that might require a different I2C codec init.

The USB OTG port isn't powered on this device - and I don't know if that's by design or I'm missing something - hence the power injection thing for the USB stick for image loading. It's meant to allow you to use USB-C headphones and charge your phone at the same time, but clearly it works well for any devices. 😁

GUI is also synced to the web interface, so charging in one changes in the other.

latent quarry
#

When I see the USB 🥹

tulip willow
#

The USB is weird on this box - all my other P4 devices have USB-A ports that are powered.

tulip willow
# latent quarry Why not GIF? I think it would be much easier. Why is MJPEG better specifically f...

MJPEG is mostly to overcome the "many small files" problem. It's easier and faster to load one big file with all the images rather than many small files. This problem is common even on my big beefy desktop.

And yeah, JPEG is hardware accelerated - as I mentioned - but it's also full color rather than a 256-color palette in a GIF.

This is holding all the images in PSRAM (once cached) as compressed JPEG data and decoding them on the fly. Caching takes a while, and I assume MJPEG will be faster..

Not that you can't get good results from GIFs, mind you.

latent quarry
#

I've done some research and the ESP32‑P4: Has dedicated hardware blocks that can decode JPEG and H.264 images/videos directly, which makes image/video processing much faster and less CPU-intensive. It also supports USB OTG, so it can read/write USB devices more efficiently. Not like ESP S3 it's kinda so hard .
I'm still failing to make it work with s3 otg . Even one picture . No idea how to decode . . . I'm still embraced of your project .

#

I mean 400MHZ is enough

tulip willow
#

There are JPEG decoders for the S3.

tulip willow
#

Presets are labeled. Playlists are a different color. Playlist stays lit so you know you're on a playlist.

Adding or removing presets in the web GUI will update the display - small race bug there, but will be fixed. Currently it paints the main UI before the background loop has painted the UI element, so you don't see the buttons change until you pick a different one.

Everything is dynamic so you can ask for more or less buttons and everything scales. This is compile time options but could be live too.

...like if you only have 7 or 8 presets it could just show one row, etc.

teal fjord
latent quarry
#

@tulip willow i I did it 😄.

tulip willow
latent quarry
#

I just understand how it will decode the GIF

tulip willow
latent quarry
#

Next Usb Otg .

teal fjord
golden panther
#

@tulip willow Is there any way to get around not having support for usb TT on esp32 p4 boards that have a built in usb hub?

tulip willow
tulip willow
golden panther
#

Does it let you force only FS?

golden panther
#

I've been working on a project that uses the P4's host support to read game controller data but nearly every mainstream controller is USB 2 FS excluding the Google Stadia controller

tulip willow
tulip willow
golden panther
#

So realistically its better to avoid the waveshare p4 boards that have the built in hub if you want both FS/LS and HS devices?

tulip willow
tulip willow
# latent quarry Next Usb Otg .

"ESP32-S3 and ESP32-S2 support USB 2.0 OTG (supporting full-speed mode), and both support Host and Device functions."

So no USB drives on the S3 unfortunately, unless you can find one that works in full-speed mode - there may be some.... somewhere. Very old models. I do not own any.

Contrary to the term "full speed", it's actually slower than "high speed". 🤣

Your best bet would be to use the MicroSD card slot on many S3 boards.

golden panther
tulip willow
#

So I was vastly wrong about using the microSD slot on the ESP32-P4 at least... it's WAAAAY faster than USB OTG with a USB drive.

Also MJPEG files are now supported in Image Player so it's even more efficient as it can load one big blob.

@latent quarry this means in theory Image Player can be ported to devices with SD card slots - you'll just need PSRAM and a JPEG decoder library. MJPEG is decoded within the image cache manager so no extra libs.

@golden panther this also means because nearly every ESP32-P4 has a microSD card slot (I own 99% of them and they all have microSD slots), I can start experimenting with using it in "Full Speed" mode, so controllers can now be a possibility.

latent quarry
#

S3 only

tulip willow
#

Ability to work with non-uniform Art-Net setups now. Even save and load presets for your Art-Net setups depending on what you're doing.

#

Also a LOT of bugs fixed for weird sized panels. I was getting away with a few things as everything was 64-bit aligned entirely by accident.

Now everything is 64-bit aligned intentionally. Always. 😁

#

Also full support for Pioneer Pro Link networks to pull all kinds of data from your decks - including phrasing data for triggering preset changes on exact beats.

Also access to both BPM and beat/bar data.

latent quarry
#

Yoo Tory every time your panel getting bigger 😂🌟 i like it

tulip willow
latent quarry
#

Damn that's a lot of pixel

#

That amount of pixels 24 FPS is crazy

#

I'm switching to raspberry pi

#

“I’m learning about Raspberry Pi

#

But since you using p4 I think it can handle it so will .

tulip willow
# latent quarry Damn that's a lot of pixel

Well, there's other paths to the Pioneer data without needing that effect.

Scrolling Text has new combinable macros for all the Pioneer metadata so you can make a segment called "#TT - #TA" which will give you "Track Title - Track Artist"

This is great in "overlay" mode so you can have song data overlayed on effects.

latent quarry
tulip willow
latent quarry
#

How is that 24 FPS it is so smooth .

tulip willow
#

You'll notice the percentage hit 99.9% and the effect changes.

That's live phrasing data from the decks.

#

It even recognizes "fill" which the MM Mascot does.

tulip willow
# latent quarry Dude that's genius .

That's all pulled from the decks - assuming you use "phrase analysis" on your files, Pioneer embeds this.

WLED-MM-P4 pretends to be a CDJ/XDJ player on the Pioneer network so it can grab all the data same as another player could.

Heck, it could even download songs from decks.

I have a vague idea of recording timecode and other values so in theory you could "record a mix" - or at least the data stream of a mix.

Then a custom plugin could read that and your USB stick and bring the entire set into a DAW for fixes.

#

Here the P4 is also using line-in from the board @coral sinew built for the P4 Nano boards, so I guess if you really wanted to, it could also be an actual mix/field recorder too. We're sampling the music already.

Would need to move up from our 22050Hz sampling rate tho. 🤣

#

Particle Effects are now running as well. I modified @remote temple 's system so the PPA dumps the PS framebuffer directly to my display framebuffer, which is about 2x faster than setPixelColor on every pixel.

Remapping is a post-process now, so you don't need to worry about it - everything in WLED-MM-P4 is drawn on a flat framebuffer so you can directly access pixel data, use the PPA, do direct memory copies, moves, fills, etc.

It's also now "aware" that the bus needs to be big enough for every pixel, so that's adjusted automatically in case you fuck up, or you want to run a smaller display.

Regular effects and accelerated 2D framebuffer effects run side by side, even as different layers.

And the live preview is now simply taking the framebuffer and scaling it down. Stupidly fast for the live preview - which I now run scaled to the resolution - so here it's running at maybe 5 FPS where it might run at 30 FPS on a 64x64 matrix.

tulip willow
#

A little "quality of life" enhancement too.

LED map names are now used everywhere (in the main GUI and in making presets)

And if you have a bunch of generic presets without an LED map specified, they will load the "default" map (ie, most likely no map) when you click them by default.

The little "Lock" checkbox is persistent across reboots (provided you save your config at some point) and always forces that LED map to be applied, regardless of if the preset has "unchanged" or a different map set.

#

This is useful if you have a setup where you want to run generic presets in different locations or on different fixtures without making presets for each map.

teal fjord
#

@tulip willow can you recommend a particular make of hub75 panel? I see a lot of requirements for the library but most panels don't advertise the ICs used. Thanks.

tulip willow
teal fjord
tulip willow
teal fjord
tulip willow
#

Offloading LED processing to something else is highly useful at scale - this is why I use Art-Net hardware for my huge installations.

...or in this case, a RPi5 as a bridge/

teal fjord
#

I was wondering what approach to take for a modest set of a few 128x128 tiles built up from 128x64 or 64x64 panels and was veering towards putting an ESP32-P4 on a 128x128 block and seeing if I could build up multiples of those into a larger wall. My install space is into a book shelf system which lends itself to modular tiles in terms of the layout.

tulip willow
#

ParallelIO on the ESP32-P4 actually has Espressif demo code for HUB75 driving.

teal fjord
tulip willow
#

That's more constrained by network on the P4 than anything else.

teal fjord
#

I have a digi-octa running 32x96 ws2812b matrixes but 29fps on those wasn't enough to get smooth music response for my eyes, so I'm wary about going too large.

#

That's 1024 LEDs per output, meant to rewire to 512 each over holidays but stuff got in the way

#

60fps would be nice I think.

tulip willow
#

Art-Net offload (or this HUB75 offload I'm doing via FPP) is useful as it's giving the pixel pushing over to dedicated hardware.

The Art-Net FPGA devices DO. NOT. GLITCH.

#

Also WLED-MM-P4 can output up to 16 pins directly so you could drive each of those twelve 16x16 panels at 130 FPS - and Parallel IO at that count is "guaranteed" glitch-free. Up to ~340 pixels x 16 outputs is one Parallel IO transaction and is ensured to be sent perfectly via hardware acceleration.

teal fjord
#

Would be nice if there was a 16 input level shifter board available. I considered using 16 single ws2812b LEDs near the gpio pins as a hack for 5V data levels but it might not work correctly.

#

I have another 4 panels ready for installation so I can get a 16x16 on each of the 16 pins for a total 64x64 ws2812b array. That'd be fun but I've been dreading the wiring and installation work. Got to get it done!

turbid basin
turbid basin
tulip willow
tulip willow
remote temple
coral sinew
tulip willow
teal fjord
teal fjord
#

I had seen https://shop.myhome-control.de/en/ABC-WLED-ESP32-P4-shield/HW10027 but was looking for something that handled power as well as data like the stackable power + data boards in my QuinLED Dig-Octa.

#

As with 5V matrix panels, the amp requirements can be quite high.

#

Not sure about the mounting holes - this doesn't look vastly different to the hole pattern on the QuinLED Dig-Octa but I bet it wouldn't line up, certainly doesn't include the power-delivery post in the centre of the board.

turbid basin
teal fjord
teal fjord
#

Is there a way to upload images via API calls? Would like to display album art but avoid moving to ESPhome and lvgl just to show a 64x64 image.

teal fjord
#

FYI I got up to some fun with Hub75 and album art display on WLED via HA DDP sync and reported over on the MM discord: #1466425745378250846 message

finite wadi
teal fjord
tulip willow
#

@finite wadi you can also use that second USB-C port for a USB drive, but weirdly it doesn't provide power - so you need a powered hub or something.

I have code in WLED-MM-P4 that shows how to init/mount/use a USB HS drive.