Color Slider instead of wheel ...?

I currently achieved to integrate a slider in my code. It has a value range from 0…255 an basically I pass the value to a function that sets the brightness in my WLED implementation with “brigthness(int value)”:

void brightness_value(lv_event_t * e)
{
	// brightness();
	lv_obj_t * slider = lv_event_get_target (e);
	int32_t v = lv_slider_get_value(slider);
	brightness(v);
}

That works!

Now I would like to have a single additional color slider (not wheel!) to set the RGB values.

My receiving function for WLED is called “color(int red, int green, int blue)

How can I achieve that?

You can create a slider with a custom background image of a HUE colour scale and then convert its single value to R/G/B components.

1 Like

Awesome thanks for the tip! This is what I came up with and it works:

extern "C" void color(int angle) {
  // Normalize the angle to be between 0 and 360
  angle = angle % 360;
  int red, green, blue;

  // Define color transitions based on the angle
  if (angle < 120) {
    red = map(angle, 0, 120, 255, 0);
    green = map(angle, 0, 120, 0, 255);
    blue = 0;
  } else if (angle < 240) {
    red = 0;
    green = map(angle, 120, 240, 255, 0);
    blue = map(angle, 120, 240, 0, 255);
  } else {
    red = map(angle, 240, 360, 0, 255);
    green = 0;
    blue = map(angle, 240, 360, 255, 0);
  }
  
  httpRequest("win&R="+String(red)+"&G="+String(green)+"&B="+String(blue)+"");

}

I have a slider with value 0…360 and I put this value in the “color(int angle)” function. There I split into R,G,B and call the WLED color change!

This is the color range: