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

FSEQ Playback from LittleFS and SD #2413

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fastbytes
Copy link
Contributor

Credit goes to @constant-flow for the original idea and structure created for TPM2 playback!
#2292

Adds support for playback of FSEQ files from xLights or Vixen
Includes support for both SD_MMC and SD via SPI (e.g. TTGO devices)
Uses FSEQFile class to prevent overlapping functions

NOTE: Created REALTIME_MODE_FSEQ using 10 instead of 9 (next available value) to keep compatibility with TPM2RECORD once both are merged

Credit goes to @constant-flow for the original idea and structure created for TPM2 playback!
Aircoookie#2292

Adds support for playback of FSEQ files from xLights or Vixen
Includes support for both SD_MMC and SD via SPI (e.g. TTGO devices)
Uses FSEQFile class to prevent overlapping functions

NOTE: Created REALTIME_MODE_FSEQ using 10 instead of 9 (next available value) to keep compatibility with TPM2RECORD once both are merged
@harueg
Copy link

harueg commented Dec 12, 2021

Hi @guardmedia

Wow, great !

How do I activate it ? shouldn't it be on the drop down menu together with the now missing ddp, artnet and so on.
What pins do I use for the sd card ?

Thanks

Harald

@harueg
Copy link

harueg commented Dec 12, 2021

What type of fseq files ?

@fastbytes
Copy link
Contributor Author

fastbytes commented Dec 12, 2021

Hi @guardmedia

Wow, great !

How do I activate it ? shouldn't it be on the drop down menu together with the now missing ddp, artnet and so on. What pins do I use for the sd card ?

Thanks

Harald

Hi @harueg,

Take a look at the comments in https://github.com/Aircoookie/WLED/pull/2413/files#diff-d81c4924f6e5d3564ea86ee4f97939e6ef6273897f4b2d002c9bf93ab5a08113 which should explain most of your questions.

The pins you use will depend on the module being used. You will want to check the pinout specifications for your board, or you may be lucky enough to just use the SD_MMC library as-is (doesn't require SPI pins to be defined).

What type of fseq files ?

Technically any V1 or V2 file without compression should work. This is compatible with the default FSEQ output from xLights.
https://manual.xlights.org/xlights/chapters/chapter-five-menus/file

// reference spec of FSEQ: https://github.com/Cryptkeeper/fseq-file-format
// first-party FPP file format guide: https://github.com/FalconChristmas/fpp/blob/master/docs/FSEQ_Sequence_File_Format.txt

@harueg
Copy link

harueg commented Dec 19, 2021

Hi @guardmedia

Thanks for the quick answer ! Will go through all this information.
What pins for sd card did you define, when you compiled the binary ?

Thanks

Harald

@fastbytes
Copy link
Contributor Author

Hi @guardmedia

Thanks for the quick answer ! Will go through all this information. What pins for sd card did you define, when you compiled the binary ?

Thanks

Harald

This was covered already in the links I shared above, which includes the PINs used for a TTGO T8 board as well. Here's the link again for reference.

@haubke
Copy link

haubke commented May 7, 2022

i'm trying this on my own build pcb. it loads a fsec file. this file length should be 30 sec. only it takes 1 sec to complete. any idea? i do not get any error.

log:
15:52:23.202 -> FSEQ load animation on LED 0 to 50
15:52:23.202 -> Read file from SD: /rainbow.fseq
15:52:23.202 -> FSEQ file_header:
15:52:23.202 -> channel_data_offset = 108
15:52:23.202 -> minor_version = 0
15:52:23.202 -> major_version = 2
15:52:23.202 -> header_length = 72
15:52:23.202 -> channel_count = 152
15:52:23.202 -> frame_count = 1200
15:52:23.202 -> step_time = 25
15:52:23.202 -> flags = 0
15:52:23.202 -> JSON buffer released. (11)
15:52:23.202 -> JSON buffer released. (12)
15:52:23.401 -> Finished playing recording, disabling realtime mode

Never mind. I am sleeping. It is working.

@blazoncek blazoncek self-assigned this Jun 14, 2022
@harueg
Copy link

harueg commented Aug 7, 2022

Hi guardmedia

Successfully compiled your fork. But the fseq features didn't show on the UI.
Are there settings to be made before compiling ? In platformio.ini ? Or elsewhere ?

It always wants to compile D1 mini, although platformio setting is default_envs = esp32dev
Is there a manual for the compiler settings ?

Thank you so much
Harald

@blazoncek
Copy link
Collaborator

@guardmedia could you talk to @constant-flow about making this a usermod?
It has a much greater chance of being merged that way and since both of your solutions work complementing each other it should be better to have them in one usermod.

@harueg
Copy link

harueg commented Aug 8, 2022

Hi Guys !
Sounds great !
Would that maybe also activate the sd card on the https://github.com/srg74/WLED-ESP32-universal-controller ?
Or did I miss something in this code ?

Thanks

Harald

@constant-flow
Copy link
Contributor

constant-flow commented Aug 14, 2022

@blazoncek I guess this is a good idea to make the mod format-independent. @guardmedia I'm currently (and slowly) progressing with the implementation as a usermod. You can see the current state here. My plan is to not only support TPM2, but multiple formats like FSEQ and maybe others if someone writes the code.

The code for the mod was quite similar to the original, you may be able to prep a snippet of code for the FSEQ any time soon, so I could merge it into my branch.

I'm currently thinking it might be even cleaner to split SD (MMC & SPI) and playback-rec into two usermods so others could built something completely different with SD-support than playback.

@harueg there's quite some high chance it will support the mentioned board, but as I don't have one of these i can't test it

@harueg
Copy link

harueg commented Aug 16, 2022

Hi @constant-flow

I am not dependent on a special board design at the moment.

Thanks for your efforts !

@Aircoookie
Copy link
Owner

Thank you for your work! Looks good at first glance.
I too think we should treat .fseq playback and general SD support as two different things, although I would like both to be included in WLED by default!
This is since a small sequence could also be stored in the integrated LittleFS filesystem and SD could also be used for e.g. config/preset storage and/or backup.

The upcoming QuinLED Dig-Octa Brainboard will have a native SD slot by the way :)

@constant-flow
Copy link
Contributor

constant-flow commented Sep 3, 2022

So i found some time to split both into separate usermods and am quite happy with it. To be clear i didn't add fseq-parsing based of @guardmedia 's code. I'd be happy to merge a tested adjustment (as this whole thing is now a usermod) but would stay away from patching/debugging it myself to fit the new shape.

The mod for Playback-Recordings can be found here
The mod for SD-Card can be found here

@Aircoookie I bodged together an SD-adapter-card with soldered wires dead-bugging into an ESP32 to test the SPI mode with the same pin config as the QuinLED Dig-Octa Brainboard. I used those pins as the default for now ... and 🎉 SPI and MMC behave the same, tho SPI is more configurable :)

Further more I added a repeat option to repeat x-times or loop for-∞, as well as a fps option to define a framerate used for playback speed.

@blazoncek General feedback is welcome, if everything is fine I'd start another PR.

@blazoncek
Copy link
Collaborator

@constant-flow I'll have a look later this week.

@softhack007
Copy link
Collaborator

Question about interaction with other usermods and effects, especially audioreactive usermod.

Audioreactive has a kind of 'kill switch' in certain realtime modes, if WLED built-in animations (fx.cpp) no longer control LEDs.The reason is that audioreactive is quite cpu intensive, and we try to give back cpu ressources when all LEDs are under external control, so WLED can achieve higher FPS.

Created REALTIME_MODE_FSEQ using 10 instead of 9 (next available value) to keep compatibility with TPM2RECORD once both are merged.

Is your new usermod also controlling all LEDs, so I should update our realtime modes 'kill list' in audioreactive, once the playback usermod code is merged?

@constant-flow
Copy link
Contributor

I'm sorry, but I can't tell how this behaves with other mods modifying the LEDs, especially with the reactive-mod.

So far the Playback-Recordings mod is build using no special functions, to manipulate the LEDs. It can control all or one segment right now. The Realtime-mode is basically just an identifier for the web interface what to display and is using right now the default-realtime-mode ID, but could deserve a custom one in the future 😄. You referred to a code in this PR, which was based off my original PR, where SD + Playback were still combined and where I wasn't using the full potential of Usermods.

The original poster could adjust their fseq playback code to match the new approach, so it can be merged in as another format allowed for playback.

When it comes to signalling the end of the realtime playback, it seems like there is still a bug, because the Web interface still shows the RT-mode on, while it signalled the end of it via exitRealtime(), but i guess this is some kind of simple race condition, so the web isn't updated properly.

@ElToberino
Copy link

ElToberino commented Nov 6, 2022

@constant-flow:
I tried your great usermod "Playback-Recordings" with 0.13.3 (ESP32dev) but I had two issues with it:

  1. In the usermod descrpition you wrote that default fps rate is 25. But when I played a tpm2-file without defining a fps rate, the animation (recorded with Jinx! @ 25 fps) was way too fast. Manually setting the fps rate to 25 via preset worked and the animation was played with the proper speed.

  2. Skipping / Leaving the real time mode didn't work. In opposite to the web interface which behaved properly and left the realtime mode, the leds still continued playing the animation - flickering and overlayed by the now chosen WLED effect.

@harueg
Copy link

harueg commented Nov 6, 2022

Hi @ElToberino

Where did you find this usermod ? Really looked hard @constant-flow 's fork.
Couldn't find fesqrecord.h neither.
In the header of a fseq file there is usually a frame rate setting, not in tpm2 ?

@ElToberino
Copy link

@harueg
It's linked some posts above.

I use Jinx! as a tpm2 recorder which always outputs 25 fps. So it should run properly out of the box without manually configuring fps rate.

@harueg
Copy link

harueg commented Nov 6, 2022

Thanks !
Are there different versions of the fork on github ? Strange.

Did you store the files on sd card or flash ?
and uploaded them with /edit ? any special directory ?

Did some projects with Jinx! as well. The developer even made a special edition for me with up to 60.000 leds.
And promised he would get back at it with enhancements. That was 4 years ago.
I really liked the ease of use.

@ElToberino
Copy link

It's just another branch of his fork - but that's indeed a little confusing...

I haven't tested the sd card support yet - I just uploaded my file via ..../edit (no special directory).

Jinx! is indeed a great software (I even think it's the best matrix software) and it's really regrettable that its developer has stopped any further development.

@constant-flow
Copy link
Contributor

Hi, sorry if things got a bit confusing (I tried my best to put links to what I refer to). For now I'll leave this PR (FSEQ Playback from LittleFS and SD) thread and will do updates on my original PR FSEQ Playback from LittleFS and SD. I posted here to basically inform @guardmedia that the base of this PR has changed and they could add fseq capabilities to my mod so it supports TPM2 and FSEQ. I'll answer open points concerning my TPM2 mod there. k/thx/bye 😃

@harueg
Copy link

harueg commented Nov 6, 2022

yep, I cloned exactly that fork to platformio, was also without this usermod. worked as zip file.

You should have a look at xlights, once you are over the slightly complicated workflow, it is really versatil.

@harueg
Copy link

harueg commented Nov 6, 2022

Did you get this error as well ?
xtensa-esp32-elf-g++: error: wled00/wled00.ino.cpp: No such file or directory

@constant-flow
Copy link
Contributor

constant-flow commented Nov 8, 2022

xtensa-esp32-elf-g++: error: wled00/wled00.ino.cpp: No such file or directory

@harueg I think that's the "compile it again and it will succeed"-bug I have with WLED from time to time.

@harueg
Copy link

harueg commented Nov 8, 2022

Yep, saw quindors video last night about compiling wled

But thank you

@softhack007
Copy link
Collaborator

softhack007 commented Nov 9, 2022

Did you get this error as well ? xtensa-esp32-elf-g++: error: wled00/wled00.ino.cpp: No such file or directory

Yep, happens for me also, randomly. I think it's a problem in platformio, and nothing related to WLED. only known solution is to compile again.

@softhack007 softhack007 added the usermod usermod related label Jan 7, 2023
@srg74
Copy link
Contributor

srg74 commented May 8, 2023

Hi, sorry if things got a bit confusing (I tried my best to put links to what I refer to). For now I'll leave this PR (FSEQ Playback from LittleFS and SD) thread and will do updates on my original PR FSEQ Playback from LittleFS and SD. I posted here to basically inform @guardmedia that the base of this PR has changed and they could add fseq capabilities to my mod so it supports TPM2 and FSEQ. I'll answer open points concerning my TPM2 mod there. k/thx/bye 😃

Is there any news on Usermod with playback capabilities? Hardware is ready to use microSD card ;)

@ElToberino
Copy link

Is there any news on Usermod with playback capabilities? Hardware is ready to use microSD card ;)

Please take a look into this PR..
In pinciple the usermod works fine - but there are problems with a larger amount of leds. (Please read the discussion.) I hope someone can fix or modify it.

@blazoncek
Copy link
Collaborator

@Aircoookie & @softhack007 I think it is time we finally tackle this PR (with help from @guardmedia and @constant-flow) as there are a few controller boards with SD card slots readily available. Would you agree?

@softhack007
Copy link
Collaborator

Would you agree?

👍

yes, I think this would be a good enhancement. I actually have some esp32 devices with SD support, including one -S3. Guess that others would also love to see what WLED can do with an SDCard.

@constant-flow
Copy link
Contributor

Hi, yes it would be nice to see it integrated. For my part i've to say I didn't touch it for quite some time now, but might be able to help here and there.

Conceptually this PR here is based off from an older approach/PR by me and replaced TPM2 playback for FSEQ playback.
In a newer version of my PR I prepared the code to allow multiple formats to be parsed/played back. My newer PR would mean there would be only one Plugin for "any" (implemented) format and not every format needs its custom plugin, which should also speed up the support for new playback formats in the future. There might be the case where another formats needs a completely different approach of parsing, where my PR's approach would create more hassle than a helpful boilerplate; but FSEQ and TPM2 parse quite similar I think, and any other sequential format should too.

Having said this, I heard that the most recent version of my PR is in questionable state. It was working as expected and either by a WLED update or my fixing of playback on 2D matrices (latter is more likely 😅), the plugin doesn't work as expected, from what other users say. Maybe @ElToberino can elaborate a bit more what (code link) works and what not, I'm referencing this quote

Looking forward to get this functionality integrated. A full rewrite using only parts/concepts is also an acceptable way of approaching this 🗑 🔁

So my suggestion would be to take my other PR, test and fix it and add FSEQ playback over there

@Aircoookie
Copy link
Owner

I agree! Would love to have both SD support and native FSEQ playback as native WLED features, but it makes it more managable to merge them separately.
FSEQ I yet have to look into, but it could also be added to the "Image" effect I have added in the "gif" branch (WIP, can natively display .gif still images and animations on a matrix), renaming the effect to "Image / Seq."

For SD support, ideally it would be possible to take advantage of it for all files WLED uses (including sequences and images, but also presets, config (excluding wsec.json potentially), custom palette and LED mapping files)
Something like this (pseudocode)

  WLEDFS::open(const char *path, const char *mode = "r") {
    File f = nullptr;
    if (SD && SD.exists(path)) {
      f = SD.open(path, mode);
      if (f) return f;
    }
    f = WLED_FS.open(path.mode);
    return f;
  }

Essentially you have already implemented this in loadRecording()!

This could even be extended by a backup functionality down the line, which could automatically or manually backup all files (exluding wsec.json) in the internal LittleFS filesystem to SD and restore them manually on demand.

@constant-flow
Copy link
Contributor

Thx for remembering me: The base of this PR had SD and Playback mixed. This PR which is accepted already separated SD from the playback.

@fastbytes
Copy link
Contributor Author

fastbytes commented Jul 28, 2023 via email

@softhack007 softhack007 added this to the 0.14.2 candidate milestone Sep 5, 2023
@softhack007 softhack007 added the major This is a non-trivial major feature and will take some time to implement label Jan 3, 2024
@softhack007 softhack007 added the keep This issue will never become stale/closed automatically label May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep This issue will never become stale/closed automatically major This is a non-trivial major feature and will take some time to implement usermod usermod related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Play .tpm2/.fseq/Jinx .dat files from sd card
9 participants