I'm continuously storing outputs in a CSV file. I'm able to read this data and trigger a change in lighting with the code below. The transition in lighting is sudden but, ideally, I'd like to attempt a smooth transition from one color to another in a non-linear way using only a RPi3 and neopixels/ws2812b.
df = pd.read_csv("output.csv")
second_last = df['modes'].iloc[-2]
last = df['modes'].iloc[-1]
if second_last == last and last == "one" :
pixels.fill((255,0,0))
if second_last == last and last == "two" :
pixels.fill((0,255,0))
if second_last == last and last == "three" :
pixels.fill((0,0,255))
I've found that a smoothstep function may be used for this but am unsure how to make practical use of it.
How can RGB values be made to follow a curve where the initial color is 0 and the color it transitions to is 1 if, for example, the following function is used? Is this a viable approach?
y = 0.5 * (1 + sin((x*pi)-(pi/2)))