could you explain how R, G, B values map into the color codes the Nextion is using?
Since WHITE is 65535, it looks like the Nextion has 16 bits to specify colors, so we theoretically have 5 bits each for red, green and blue - but how are they distributed and what does the 16th bit?
I know you asked Patrick But may this will help
Read the thread most answers are there
"The colors are in 16-bit 565 format. Hue Sat Lum is calculated when RGB is entered.
For sake of correctness, H/S/L input could also calculate RGB, but most people never think in H/S/L.
24 bit RGB in binary is RRRRRRRR GGGGGGGG BBBBBBBB or in Hexadecimal as FF FF FF
565 uses 5 upper bits of red, 6 from green, and 5 from blue: RRRRRRRR GGGGGGGG BBBBBBBB
Therefore your color 33973: red is 128 green is 148 and blue is 21. in RGB Hexadecimal 8094A8.
33973 / 2048 = 16. 16 * 8 = 128 Red
(33973 % 2048) / 32 = 37. 37 * 4 = 148 Green
(33973 % 32) = 21. 21 * 8 = 168 Blue
How do I convert HSL to 16bit 565 format.
Internet would have algorithms for HSL to 565 format.
Certainly fewer people would think in terms of HSL
effects like fading or gradients are nothing magic, even not in RGB and 565 ...
but indeed you need some knowledge to code it ...
your hobby, your choice, your duty ...
Nextion is an HMI device. Human Machine Interfacing.
Although HSL to 565 conversion for entered values can probably be achieved if someone invests their time to accomplish, realizing a color chooser is perhaps more challenging. Nextion was not designed for this purpose, and it does not have an NVidia graphics card to assist. Touch coordinates of a touch for selection will need to be looped to an MCU over serial and sent back to Nextion. Touch on Resistive or even the Capacitive display may have higher resolution on the inner, but will lose coordinate resolution accuracy the closer to the edge you go.
So perhaps interesting as a Proof of Concept, but less efficient use of cycles to perform such calculations and other than font color will have no value. The final resolution of 16 bit color 0 to 65535 will become your most limiting factor - HSL tends to be for 24 bit, 32 bit and higher - such resolution is indeed lost on 16 bit.