Hello all,
As I’m starting patterns that get DMX channels for color information, I get on my Pixelblaze r,g,b information when using a color picker from most DMX consoles (using Resolume and QLC+ so far). I intend to create it as a framework that would allow any pattern to be controlled through DMX/Artnet/Flamecaster
But I would like to transform this data into h,s,v values to be used in my existing patterns, since they almost all use HSV for practical reasons.
I have asked my friend chatGPT to cook me a nice function using the code reference, and it looks correct (as in “no bug detected”), but executing it absolutely crashes my Pixelblaze and restarts it with a “No LED” configuration and very hot temperature.
What did we mess up ? I don’t see anything that could lead to a crash, and even though I’m not sure exactly about the math between, it looks correct.
Thank you !
export var rgb = [0, 1, 1] // Some RGB values
export var hsvValues = array(3)
function rgb2hsv(r, g, b) {
RGBmax = max(r, g)
RGBmax = max(RGBmax, b)
RGBmin = min(r, g)
RGBmin = max(RGBmin, b)
deltaRGB = RGBmax - RGBmin
h = 0
s = (RGBmax == 0 ? 0 : deltaRGB / RGBmax)
v = RGBmax
if (RGBmax != RGBmin) {
if (RGBmax == r) {
h = (g - b) / deltaRGB + (g < b ? 6 : 0)
} else if (RGBmax == g) {
h = (b - r) / deltaRGB + 2
} else if (RGBmax == b) {
h = (r - g) / deltaRGB + 4
}
h /= 6
}
return [h, s, v]
}
export function beforeRender(delta) {
//t1 = time(.1)
hsvValues = rgb2hsv(rgb[0], rgb[1], rgb[2])
}
export function render2D(index,x,y) {
hsv(hsvValues[0], hsvValues[1], hsvValues[2])
//h = t1 + index/pixelCount
//s = 1
//v = 1
//hsv(h, s, v)
}