Actions

Difference between revisions of "WS2811 "Water torture""

From Just in Time

m
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
Quickie project based on the [[Driving the WS2811 at 800 kHz with an 8 MHz AVR|8MHz WS2811 driver]]
 
Quickie project based on the [[Driving the WS2811 at 800 kHz with an 8 MHz AVR|8MHz WS2811 driver]]
  
The source code is part of the [https://github.com/DannyHavenith/ws2811 driver demonstration sources]. This particular demo is in [https://github.com/DannyHavenith/ws2811/blob/master/src/water_torture.hpp water_torture.hpp].  
+
The source code is part of the [https://github.com/DannyHavenith/ws2811 driver demonstration sources]. This particular demo is in [https://github.com/DannyHavenith/ws2811/blob/master/effects/water_torture.hpp water_torture.hpp].  
  
 
{{#ev:youtube|_wkTtAk2V_k}}
 
{{#ev:youtube|_wkTtAk2V_k}}

Latest revision as of 00:14, 8 November 2019

Quickie project based on the 8MHz WS2811 driver

The source code is part of the driver demonstration sources. This particular demo is in water_torture.hpp.

The code is in C++ and uses a class, "droplet" to maintain the state of the droplets that are animated on the LED string. At most 2 droplets are animated at the same time and when droplets overlap, their colors are mixed.

Each droplet can be in one of four states, which are traversed in order:

inactive
the droplet does nothing and is not visible.
swelling
the droplet stays at the top of the led string and slowly increases in intensity, until it reaches a randomly chosen intensity.
falling
the droplet falls downwards and accelerates. This state ends when the droplet passes the bottom position.
bouncing
the droplet has bounced of the ground. A smaller, less intensive droplet bounces up while a part remains on the ground. The droplet moves upwards, decelerates and falls down again. After hitting the ground while in the bouncing state, the droplet returns to the inactive state.

The droplet animation is smooth because positions are maintained in 8.8 fixed point, meaning that there are 256 positions between two adjacent LEDs. When a droplet is is positioned between two leds, its intensity is divided over the two leds.