Lantern Simulator

I’ve been struggling to get my lantern animation software done. One of the main distractions is the difficulty in testing. In short, I can only see the lights well at night, and I tend to code better in the morning.

After some back and forth I decided it might be worth trying to throw together a quick simulator. This was my second attempt and it didn’t turn out to be too hard.

I ended up building a static web page that used BabylonJS, which is a 3D javascript library for browsers. To get the changes from my code, I had it open a websocket back to the local host and in my Mocha (test framework). I then added a mock mode to my WLED handler to open a server side socket in test mode. The browser code receives the same messages as WLED and lights the LEDs accordingly.

In all, 40 lines of HTML and 150 lines of Javascript for the simulator. The modifications to my existing code were probably under 50 lines of code. It took a bit longer than I desired as I had to hunt around the Babylon APIs to get it to do what I want, but I suspect I will be using that library for future projects.

Edit: test

Leave a Reply

Your email address will not be published. Required fields are marked *