Hi All,
In sln_local2_iot_local_demo the LED colour is controlling using RGB_LED_SetColor() function.In this function there are multiple cases(different pwm values) for each colour.I want to add more colours.I want to control the led colour from hex colour code.I tried to convert the hex code of colour(example RGB(255,255,255)) to PWM value by using the below equation
redPWMval = hex value of red/255*100
greenPWMval = hex value of green/255*100
bluePWMval =hex value of blue/255*100
Then all pwm duty cycle will be updated using the function PWM_UpdatePwmDutycycle().
But I am not getting the colours as expected.Instead of white I am getting yellowish colour.
Is there any method to control RGB LED PWM from HEX code of colours ?
Thank you so much for your interest in our products and for using our community.
Sorry for the inconvenience, but we don't have that official specific code example. Although surely there must be many on the web. The PWM_UpdatePwmDutycycle() function takes dutyCyclePercent <= 100 as a parameter, so your equation looks fine. If you are sending white (255,255,255) and you get yellow (255,255,0) then the bluePWMval is not being updated properly.
Have a nice day!
Hi @_Leo_ ,
Thank you for the response.But in the sln-local2-iot local demo (sdk), already 8 colours are defined.In that for white colour(example) following are the pwm values given in the sdk .
case LED_COLOR_WHITE:
redPWMval = 15;
greenPWMval = 100;
bluePWMval = 100;
break;
Hex code for white is 255,255,255 .and corresponding pwm values should have been 100,100,100.but in sdk it is RGB(15,100,100) and why?
Hi @jackking ,
I will check on that.But can you comment on the above mentioned query?why 15 is given instead of 100 for red pwm value to generate white colour? I didn't get that logic.my use case is from hex colour code i have to control the colour of the led.
I don't know the specifics of this use case (I use an external driver chip for my RGB LEDs) or what LED you are using.
I would scope the PWM outputs and see what the change in duty cycle does to the signals and match that to the specific LED datasheet.
I also assume that the LED will have different brightness responses for each of the red, green and blue elements. They are not usually perfectly matched, so the values the example have defined may actually be the best combination to achieve white with the EVK board LED (?)
You might want to start with the the individual colors and measure the relative brightness at different duty cycles and then create a mapping function that gives the best matched values.
Hi @jackking ,
In sln-local2-iot hardware scheme low(0 value) pwm out will turn on the led and high (1 value) pwm out will turn off the led.But in our case High pwm out will turn on the led and low pwm out will turn off the led.Ie just opposite of RGB led hardware scheme in the sln-local2-iot kit.How can I invert the logic in the software to make it work?What all changes should I change in the sdk to make it inverse?Please help me