Start a new topic

Color codes

 Patrick,


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?


it just use a 565 schema ...

5 bits R
6 bits G
5 bits B

rrrrrggggggrrrrr

convert a full 24Bit RGB into 16Bit 565

565value=int(R/8)*2048+int(G/4)*32+int(B/8)


Gerry


I know you asked Patrick But may this will help 

Read the thread most answers are there 

http://support.iteadstudio.com/support/discussions/topics/1000064883


"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


"




Thank you all!

 

Login or Signup to post a comment