Skip to content

Add WEB chipset and Unix platform - #698

Closed
kw217 wants to merge 6 commits into
FastLED:masterfrom
kw217:add-websocket
Closed

kw217 wants to merge 6 commits into
FastLED:masterfrom
kw217:add-websocket

Conversation

@kw217

@kw217 kw217 commented Dec 13, 2018

Copy link
Copy Markdown

This PR adds support for the following to FastLED:

  • The DUMMY chipset. This performs no output. It's useful for stubbing out code, or for testing a new platform.
  • The __unix__ platform. This allows building the library for Linux, without requiring AVR or Arduino specials.
  • The WEB chipset. This provides live output to a browser. It's only supported on __unix__.

I wanted to test my FastLED patterns without having to flash them to my Arduino or look at my LED array (which is fixed to the outside of my house and hence difficult to view from my workstation). So I added this new chipset, which runs a small webserver to which you can connect your browser. When you do so, the LEDs are displayed in the browser.

Use it like this:

  FastLED.addLeds<WEB, 9002, 0>(leds, NUM_LEDS);

and then connect your browser to http://localhost:9002/ to see the show. Multiple LED strings are supported - just specify an index in place of 0. Any port can be used - 9002 is just an example.

Obviously to run typical Arduino code in this way you'll need to provide a main() which calls setup() and loop(), and define any Arduino functions you use. If you guard these things and the addLeds all above with #ifdef __unix__ then the same code will work for Arduino and Linux. To build for Linux you will need to install libwebsocketpp-dev (https://github.com/zaphoyd/websocketpp), and link with -lboost_system -lpthread.

Please let me know if there is anything I need to add to or change in this code to meet the FastLED project requirements.

Enjoy!

How it works: It runs a small combined web and websocket server. For web requests it serves a page with some Javascript, which then makes a websocket request back to the origin server. Each call to showPixels renders an n x 1 PNG image of the LEDs and pushes it over the websocket to the browser, which displays it.

This allows the code to link even if XY isn't filled in by the
application, as long as the calling method is not used. The syntax is
GNU-specific.
@kw217 kw217 changed the title Add websocket Add WEB chipset and Unix platform Dec 13, 2018
@kriegsman

Copy link
Copy Markdown
Member

This is an awesome piece of work -- thank you for all of this!
@focalintent and I are discussing what's the best way to make it available, and maintainable, etc., but this is great, and I think a lot of people will be happy to get their hands on this capability. Clearly a really valuable contribution!

@kw217

kw217 commented Dec 15, 2018

Copy link
Copy Markdown
Author

Thanks! Please do let me know what needs to be done, I'd love to get this out there. If anyone could try it out and let me know how it goes that would be useful - I tried to make it as self-contained and standard as I could, but I've only tested it on my own system (Ubuntu, gcc, Firefox). Really pleased you like it!

@kw217

kw217 commented Dec 23, 2018

Copy link
Copy Markdown
Author

Hi @kriegsman @focalintent - any thoughts about whether/how you can merge this? Guessing it's best to wait until after the holiday season now :-)

@gnkarn

gnkarn commented Dec 24, 2018

Copy link
Copy Markdown

Hi, excellent, Why not just to " stream or publish" via Wifi the leds[i] data , with a simple format , that could then be used on any client we may need , so that way we can achieve the purpose on many different ways . JS, P5js, processing , Java , etc .

@kw217

kw217 commented Dec 25, 2018

Copy link
Copy Markdown
Author

PNG is pretty universally easily rendered. I don't understand what you mean by "stream or publish via WiFi"? WebSockets have the advantage over plain sockets that they can easily be accessed from a browser, so no app needs to be installed on the client.

@focalintent

Copy link
Copy Markdown
Contributor

I spent some time talking to mark about this - and I really want to keep the library focused on just directly driving LEDs on embedded platforms - and I would rather see things like this be projects that used FastLED rather than incorporated into FastLED itself.

However, I know that's not easily doable right now - but I have a solution on my RGBW/16-bit branch - which is a NULL platform. Setting the platform to NULL means that you have to define your own CLEDController classes and instances, but would allow building/using all the color code and other management code of FastLED on platforms that we don't have hardware out for.

I need to make some changes to it to bring back to this branch (the RGBW/16-bit branch has diverged enough that it won't be a straight copy over) - but once I do that, then you can then have a project that includes FastLED and builds on top of it.

If I'm lucky, I'll be able to get this done before the end of the month - and I'll leave the pull request open until I've done it, just to make sure that it stays on my radar.

@focalintent focalintent mentioned this pull request Jan 20, 2019
@kw217

kw217 commented Jan 20, 2019

Copy link
Copy Markdown
Author

Thanks, this sounds like a good solution - I realise it's a tricky balance to strike.

Once you've added the NULL platform and I've refactored this WEB chipset into a new project built on top of it, would you mind linking to my project from the FastLED docs? As @kriegsman says, I think a lot of people will be happy to get their hands on this capability - I've certainly found it very useful in my own FastLED development. Obviously if you'd rather not that's fine too.

@kw217

kw217 commented Feb 23, 2019

Copy link
Copy Markdown
Author

Hi @focalintent - have you been able to make any progress with the NULL platform code?

@kriegsman

Copy link
Copy Markdown
Member

Dan's a bit under water just now, but he and I are both definitely in favor of adding the NULL platform; we'll get to that as soon as we can -- and then we'll definitely loop you in, and link to your web-based project. Thanks again for the contributions, of code and ideas!

@kw217

kw217 commented Feb 26, 2019

Copy link
Copy Markdown
Author

Thanks!

@kw217

kw217 commented Aug 26, 2019

Copy link
Copy Markdown
Author

Hi @focalintent - well done on getting 3.3 out! How would you like me to proceed with my PR - is there an easy way I can make this functionality available to people? I love the idea of making it a project that builds on top of FastLED. Thanks.

@kw217

kw217 commented Nov 11, 2019

Copy link
Copy Markdown
Author

@focalintent any update on this?

@kriegsman

Copy link
Copy Markdown
Member

Hi Keith @kw217, and thanks for following up.
I’m sorry to have to be the one to bring you the sad news that we lost Dan @focalintent in the “Conception” boat fire off the coast of California in early September. We are all heartbroken.
The families and I are still dealing with private matters this month, but I am hoping before the end of the year to have a plan for how I’m going to move forward with FastLED.
Dan and I both really liked your project and we really wanted to get it into peoples hands — and I still feel that way.
Thank you again for your contributions, and for your patience as I, and we all, deal with Dan’s loss.
-Mark

@kw217

kw217 commented Nov 25, 2019

Copy link
Copy Markdown
Author

Oh no, I'm really sorry to hear that terrible news. Obviously take as much time as you need - and I'm sending my best wishes for all of you. Thanks.

@kriegsman

Copy link
Copy Markdown
Member

Thank you again, @kw217. I was just speaking with @uberjay (now a FastLED maintainer), and we're going to try to get this going, and merge it as best we can so people can use what you've built here.
I don't (yet) have access to all of @focalintent's github branches, so I'm not sure how far along he was with the NULL platform implementation. But for now, @uberjay is going to try to see what we can get going here.

@marmilicious

Copy link
Copy Markdown
Contributor

@kw217 At some point when things get updated, please share your project/some video of this in the FastLED Reddit group. There are most certainly others that will be interested in this. I was definitely interested when Dan had mentioned the idea of a NULL platform. Thank you.

@kw217

kw217 commented Jan 27, 2020

Copy link
Copy Markdown
Author

Sure - I'll see what I can do. Thanks! Presumably it's better if I wait until @uberjay has reviewed and we're en route to merging.

@kriegsman

Copy link
Copy Markdown
Member

I agree- let’s get the plan for merging this going and then it’ll be time for show and tell. I’ll loop back with @uberjay. Thanks, all.

@kw217

kw217 commented Sep 15, 2020

Copy link
Copy Markdown
Author

Hi @kriegsman @uberjay are you still interested in proceeding with this? Christmas is coming up and I'll be using this again soon :-)

@chadrockey

Copy link
Copy Markdown

I'm on Yocto and getting the web and boost dependencies would have taken a few days. I updated #422 with the latest main branch if anyone comes across this and needs something quick. Should work on raspberry pi, etc:
https://github.com/chadrockey/FastLED/tree/linux

@zackees

zackees commented Aug 31, 2024 •

Copy link
Copy Markdown
Member

We have a "stub" compile mode that works on linux and windows, and presumably macos. It's continuously tested so this its stable to use.

linux_native

Let me know if this doesn't work for you.

@zackees zackees closed this Aug 31, 2024
@kw217

kw217 commented Sep 3, 2024

Copy link
Copy Markdown
Author

Hi @zackees - does this stub mode provide something like the "WEB" chipset this PR implements, which provides live LED output in your browser? If not, I'd like to add it - is this something you'd be interested in? I was hoping to get this in around 2020 but everything got put on hold with the sad news re @focalintent .

@zackees

zackees commented Sep 4, 2024

Copy link
Copy Markdown
Member

You have 6 commits in this PR and I can't evaluate exactly what has changed.

If you have a clean PR that is minimal and does not break anything then yes, I will merge it.

@zackees zackees reopened this Sep 6, 2024
@zackees

zackees commented Sep 6, 2024

Copy link
Copy Markdown
Member

Keeping this open. Please issue a new PR for this

@zackees
zackees force-pushed the master branch 7 times, most recently from 6fdf45c to f18be6e Compare September 24, 2024 20:55
@zackees

zackees commented Oct 12, 2024 •

Copy link
Copy Markdown
Member

wasm

Will be in with the FastLED 4 release. You can preview it in the master branch now.

Thanks to @shlomozippel for the prototype.

image

@zackees zackees closed this Oct 12, 2024
@kw217

kw217 commented Oct 21, 2024

Copy link
Copy Markdown
Author

Ah brilliant - thank you! Doing it in WASM is a much cleaner solution now (don't think it would have been practical in 2018). Thank you @zackees and @shlomozippel .

Happy to prepare this PNG code for use if it's ever of interest, but I'm assuming it's irrelevant now.

@zackees

zackees commented Oct 22, 2024

Copy link
Copy Markdown
Member

You are using our wasm build right? We now have native support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants