[HN Gopher] Over-engineering an RGB LED strip: let's make a cust...
       ___________________________________________________________________
        
       Over-engineering an RGB LED strip: let's make a custom programming
       language
        
       Author : misterdata
       Score  : 68 points
       Date   : 2022-07-17 17:28 UTC (5 hours ago)
        
 (HTM) web link (pixelspark.nl)
 (TXT) w3m dump (pixelspark.nl)
        
       | flaviut wrote:
       | This is very cool. And very generalizable, there are many
       | situations where you want something like a scripting language for
       | a MCU, and the VM implementation here is very straightforward.
        
       | dtagames wrote:
       | You had me at Lua. It's cool to think that runs on an RGB strip.
       | I'd do it there but kudos on going all the way down!
        
       | claxo wrote:
       | Kudos to the author.
       | 
       | The readme links to a protocol.md that lives in a private
       | repository, any posibility it gets copied to the github repo?
        
       | solarkraft wrote:
       | This is nice. I once tried to get programmatic animations running
       | on MicroPython, but it seemed to fail to load even the simplest
       | color conversion class (I didn't have an ESP32 back then).
       | 
       | I also tried streaming patterns (could've been really cool to
       | hook it up to something like ColorCord), but my Wifi connection
       | was definitely also too unreliable for that (hmmm, what about PoE
       | LED strips?).
       | 
       | There's some project based on Javascript (I think) with in-
       | browser previews for the patterns, but it's proprietary and only
       | sold as pre-flashed modules. I forgot the name, but I think it
       | has been posted here.
       | 
       | This bytecode-custom-language solution definitely looks over-
       | engineered (wish I could use a language I already know to make an
       | animation), but damn, it should be efficient. I think I'll play
       | around with it bit.
        
         | thanatos519 wrote:
         | > There's some project based on Javascript (I think) with in-
         | browser previews for the patterns, but it's proprietary and
         | only sold as pre-flashed modules. I forgot the name, but I
         | think it has been posted here.
         | 
         | That would be the PixelBlaze from https://electromage.com/
         | 
         | ... and it's super-duper-amazing for _actually finishing_ LED
         | projects. While the code on the ESP32 is proprietary,
         | everything else is very open and the community is awesome.
         | 
         | If your name is Sisyphus or you just want to hack on LED
         | electronics and maybe make some lights blink, anything else is
         | fine.
        
       | jedberg wrote:
       | There already is a custom programming language for LED lights.
       | It's called E1.31, and there are open source programs that exist
       | to program in it (one of the most popular is called Xlights).
       | It's what most people use to make their programable Christmas
       | lights shows, and it also is the same protocol used in stage
       | lighting.
        
         | misterdata wrote:
         | If I understand correctly that's 'Streaming ACN' e.g. more or
         | less DMX512 over IP. In that case the image is generated on a
         | beefy lighting desk/computer, not on the microcontroller inside
         | the fixture (which is what this and e.g. the Lua project linked
         | in another comment does)
         | 
         | WLED (firmware for ESP8266) appears to support E1.31 [1] as
         | well as Art-Net and the WLED custom protocol referenced in the
         | article.
         | 
         | [1] https://github.com/Aircoookie/WLED/wiki/E1.31-DMX
        
       | garaetjjte wrote:
       | I'm surprised you didn't use floating point math, it seems
       | cumbersome to make animations that way. My attempt at
       | programmable LED strips used Lua (like that:
       | https://gist.githubusercontent.com/Milek7/760a683f3480a4ff95...),
       | though they were driven directly from Linux SBC.
       | https://milek7.pl/.stuff/26gru.webm
        
         | misterdata wrote:
         | Floating point is just not very fast on ESP8266 (I believe it
         | could even be softfloat, so emulated in software?).
         | 
         | Nevertheless it shouldn't be that difficult to change the
         | interpreter to use floats instead of ints as base type (mixing
         | the two would be more involved I think).
        
       | manofmanysmiles wrote:
       | This might interest you as well:
       | 
       | https://www.bhencke.com/pixelblaze
        
       | redfast00 wrote:
       | Related: a multi-program programmable LED strip (in Lua, allows
       | the led strip to be split up into multiple segments)
       | https://zeus.gent/blog/21-22/ledstrip_sandbox/ with the code on
       | https://github.com/ZeusWPI/ledstrip_sandbox
        
         | misterdata wrote:
         | This looks cool! Lua obviously is a much more mature language.
         | I'd expect it to use a fairly complex interpreter (LuaJIT is
         | not available for esp8266 I assume..) so this is likely a bit
         | less efficient (even though the Lua interpreter is probably
         | well-optimized, it is simply more complex) but obviously much
         | more functional than my toy language.
        
       | Tempest1981 wrote:
       | How did you implement "sleep"? For timing the effects?
       | 
       | I see a 'get_precise_time' command. I guess you could poll that,
       | if you aren't worried about power use. (LEDs using far more power
       | than your CPU.)
        
         | misterdata wrote:
         | The interpreter will throttle the program to a certain frame
         | rate - it will suspend the program on each 'yield' instruction
         | and resume the program when a new frame is needed. It can also
         | ignore the yields to get as high a frame rate as possible.
         | Programs should not poll but use get_precise_time to draw what
         | is necessary for that time stamp.
         | 
         | (And yes, the LEDs use way more power than the CPU here)
        
       ___________________________________________________________________
       (page generated 2022-07-17 23:00 UTC)