ILI9341 Color Values / grayscale..

AshPowers

Well-known member
Hi!

I'm trying to understand the 0xXXXX color values that are used in this library but not having a lot of luck searching for what I specifically am trying to do.

As a very simple example: I want to have a black screen that transitions through all available shades of grey up to pure white. How would one go about writing the code to do this? I'm familiar with how to write the loop to increment the color value and all of the basic stuff. Just trying to figure out how to increment the hex color value to produce ONLY shades of gray, from black to white.

Thanks!
-Ash
 
these displays are 65535 color depth (color565) meaning 16 bit color depth (5 bits for red, 6 for green, 5 for blue). The library has a method to covert true color to 565

This tested code should work

byte i;
uint16_t YourColor;

for (i = 0; i < 255; i++){

YourColor = tft.color565(i,i,i);

tft.fillScreen(YourColor);

}
 
THanks for the reply again, Kris!

Unfortunately my simple example fails to work in the actual application. I am wanting a string of text to shade up from black to white on a black background. I ran your code and it did exactly as I asked for, LOL, but I dont think rgb color values work for text?
 
Back
Top