shinyblink / sled

Satanic/Sexy/Stupid/Silly/Shiny LED matrix controller
https://shinyblink.github.io/sled/
ISC License
122 stars 25 forks source link

Question: Will this allow me to use sdl2 and send the output to arduino / matrix? #28

Open JordyMoos opened 6 years ago

JordyMoos commented 6 years ago

Just so I understand this repo correctly, this will allow me to write code with sdl2 and use arduino / matrix as the output? That would be exactly what I have been looking for then ;P

Cheers

vifino commented 6 years ago

Well, sort of.

It allows you to write effects generically, one of the possible outputs is SDL2. You yourself can't use SDL2 functions in the effects, but you can definitly write effects and run them both on a real matrix and on a virtual one.

We don't have an Arduino port, we have..

One could probably send pixel data out to serial if you don't have an esp8266 or a raspberry pi.

Still needs a Linux machine to run the effects, though.

orithena commented 6 years ago

@vifino: I'm not sure whether that meets @JordyMoos' intention.

I read it as: "Can I write an effect (animation, game, whatever) in SDL2 while taking advantage of SDL2 functions and still transfer the result to an LED matrix".

This isn't quite how SLED is built, but it might be possible. Off the top of my head, this requires a new gfx module that initializes and takes care of its own SDL window; then reads the resulting pixels from that window and writes them into the SLED framebuffer using matrix_set(x,y,rgb). Then any out module of SLED can be used for display.

This might be slow, depending on the output size; however, it might be possible to write e.g. a matrix_memcpy() function to speed up the process of copying the framebuffer. This, however, would require the SDL framebuffer to run in the same memory model as the SLED framebuffer (and I'm not fluent enough in SDL to know whether this is possible at all).

vifino commented 6 years ago

@orithena Good point. Not sure if that's much help, as there are only very limited algorithms implemented in SDL2/relevant to drawing pixels. Drawing lines, rectangles and circles(?) is already supported with simple methods.

All the other actual drawing will still be done by some algorithm and setting the pixels, so it doesn't make much difference, in my opinion.

vifino commented 6 years ago

@orithena Actually, now I understand what you meant.

It is not just about graphical effects, but rather SDL2 apps and the possibility of drawing to LED matrices!

Yeah, reading the pixels from the SDL2 window of the app and setting it would be the easiest. One could make an SDL2-metawrapper module as a bgm module, with some specific "wake up/go to sleep" function that some app could call if it wants to draw now.

Probably not too hard to repurpose the module loader for this as well. We could load apps compiled to .so's from a subfolder in modules, like modules/sdl2.

orithena commented 6 years ago

Hmmm... probably the most flexible solution would be to perpetually screenshot an SDL window maintained by another process. Don't know whether that works or is practical. This would only require a small gfx module on SLEDs side.

vifino commented 6 years ago

I think that's the simplest and most universal solution too. One could just implement a grabbing-code on the app side, send frames every time SDL render is called.

We already have OpenPixelControl and Pixelflut support, so it should be doable. :)