Referring to the python library neopixel
(rpi_ws281x), to control WS2812B RGB LED strips, does trimming the brightness by scaling the byte for each sub-LED in a pixel from 255 to 127 limits us from rendering certain colors?
According to the library, for dimming purposes, the following code is executed:
def setBrightness(self, brightness):
"""Scale each LED in the buffer by the provided brightness. A brightness
of 0 is the darkest and 255 is the brightest.
"""
ws.ws2811_channel_t_brightness_set(self._channel, brightness)
However, if I would like to render the color of RGB (255, 187, 120) at 50% brightness: seems to me, the data frame bits are clipped capped at a maximum (127, 127, 127) per pixel - according to code above, by which, the above color is not displayable?
Am I right?
Could anyone explain how the brightness control/dimming function from that library works? Shouldn't it decrease the PWM duty cycle to decrease brightness (power)?
Please explain. Thank you.
UPDATE:
By plotting brightness against CCT, at lower brightnesses (100% --> 75% --> 50% --> 25%), the CCT increases. How to correct this?
import colour
import numpy as np
import matplotlib.pyplot as plt
data = np.array([255, 187, 120])
data75 = data*0.75
data50 = data*0.5
data25 = data*0.25
datas = [data, data75, data50, data25]
methods = ['daylight','kang2002','mccamy1992','hernandez1999']
def rgb2cct(x,y):
RGB = np.array(x)
XYZ = colour.sRGB_to_XYZ(RGB / 255)
xy = colour.XYZ_to_xy(XYZ)
CCT = colour.xy_to_CCT(xy, y)
#print(CCT)
return CCT
X =[100,75,50,25]
Y = []
for j in methods:
print(j)
for k,v in enumerate(datas):
u = rgb2cct(v,j)
Y.append(u)
def chunks(lst, n):
for i in range(0, len(lst), n):
yield lst[i:i + n]
plot = list(chunks(Y,4))
for i,j in zip(plot,methods):
plt.plot(X,i, label = j)
plt.axhline(y=3200, color = 'black', linewidth=0.5)
plt.legend()
plt.show()