#Color-wheel math

1 messages · Page 1 of 1 (latest)

dawn aurora
#

I’m trying to make a neopixel strip that is reactive to openweather API data.

I want to set a neopixel color to represent the current atmospheric temperature, in a range of temperatures from the daily high to the daily low. So, looped over a 24-hour period, the neopixel should range through the rainbow.

I think I need to use “colorwheel” and maybe the math min and max functions?

So, if the high is 80’, and the current temp is 80’, the neopixel would be the “hottest” color (Red, or 0 in colorwheel I think). If the current temp is 60’, which is also the daily low, the neopixel would be the “coolest” color (255, or violet). The “middle” would be 70’, and represented by color-wheel 127)

(I know that the physical temperature of color is different from the psycho-social color temp, but I live where red means hot, so please bear with me)

I’ve got most of the program down, other than the math and colorwheel. I think its probably a simple formula, but I’m coming up blank.

TY!

rotund zodiac
green skiff
#

you might want to test what the colors of colorwheel() map to, it loops around (like a wheel) so 0 and 255 are actually very close

dawn aurora
#

Awesome. Thanks Neradoc and Foamyguy

green skiff
#

I use that to light a neopixel to warn of the temperature of my 3D printer bed, it goes yellow above 30 and then follows the wheel to red, then purple (it's usually around 60 degrees which is orange-red on the wheel with this formula) I don't think that's quite what you would want

if temp_bed < 30:
    color = (0,0,0)
else:
    index = min(280, 256 - 65 + temp_bed)
    color = wheel(int(index))