Hi all. I am currently trying to hack together a bluetooth app for android to allow me to set the color of my lights. I am using the example app from funkboxing as a starting point . I have modified this app now to include a color picker found here http://cketti.github.io/HoloColorPicker_slides/HoloColorPicker.html#/. The problem is I am not sure how to get the hue value for the color selected and was wondering if there is any Android developers on here that might be able to tell me how to do this or suggest an alternative color wheel that I might use.
To get the hue from the color picker, you’ll want
float[] hsv = new float[3] ; Color.colorToHSV(ColorPicker.getColor(),hsv);
Where hsv[0] would be the hue.
More details can be found on the Color api page http://developer.android.com/reference/android/graphics/Color.html
FastLED deals with Hue differently to android though… FastLED uses 0-255 and android uses 0-360, so you might want to send RGB data instead
You can map the 0-360 value to 0-255 value easily enough on the android side - uint8_t hue = ((hsv[0]*256)/360) - though it’ll be a little chunky - but then this way you can still do all sorts of fun color rotation stuff after the fact w/FastLED (more difficult to do w/RGB)
Hi thanks for the help I can now set the color of the leds and get good results. The way it functions at the minute is you select a colour then press a button to change the colour .what I would like it to do not is track the color change as you scroll round the wheel .I am trying to use the OnColorChangeListener but can’t figure out how to make this work any help with this would be greatly appreciated. I will share this app once I get it sorted
You’d want something like
mColorPicker.setOnColorChangedListener(new ColorPicker.OnColorChangedListener() {
@Override
public void onColorChanged(int i) {
float[] hsv = new float[3] ;
Color.colorToHSV(i,hsv);
sendValue(hsv[0]);
}
});
Where mColorPicker is your Color Picker and
sendValue(hsv[0]); is your method to send the values over bluetooth.
Thanks very much for your help have this working now will tidy it up a bit and then share