Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: ILI9341 Color Values / grayscale..

  1. #1

    ILI9341 Color Values / grayscale..

    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

  2. #2
    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);

    }

  3. #3
    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?

  4. #4
    Nevermind, LOL! I got it to work! Thank you again!!

  5. #5
    check out Display.setTextColor(TextColor, BackColor);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •