Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8941873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:23:58+00:00 2026-06-15T11:23:58+00:00

I am working on a project with a TFT touch screen. With this screen

  • 0

I am working on a project with a TFT touch screen. With this screen there is an included library. But after some reading, I still don’t get something. In the library there are some defines regarding colors:

/* some RGB color definitions                                                 */
#define Black           0x0000      /*   0,   0,   0 */
#define Navy            0x000F      /*   0,   0, 128 */
#define DarkGreen       0x03E0      /*   0, 128,   0 */
#define DarkCyan        0x03EF      /*   0, 128, 128 */
#define Maroon          0x7800      /* 128,   0,   0 */
#define Purple          0x780F      /* 128,   0, 128 */
#define Olive           0x7BE0      /* 128, 128,   0 */
#define LightGrey       0xC618      /* 192, 192, 192 */
#define DarkGrey        0x7BEF      /* 128, 128, 128 */
#define Blue            0x001F      /*   0,   0, 255 */
#define Green           0x07E0      /*   0, 255,   0 */
#define Cyan            0x07FF      /*   0, 255, 255 */
#define Red             0xF800      /* 255,   0,   0 */
#define Magenta         0xF81F      /* 255,   0, 255 */
#define Yellow          0xFFE0      /* 255, 255,   0 */
#define White           0xFFFF      /* 255, 255, 255 */
#define Orange          0xFD20      /* 255, 165,   0 */
#define GreenYellow     0xAFE5      /* 173, 255,  47 */
#define Pink                        0xF81F

Those are 16-bit colors. But how do they go from: 0, 128, 128(dark cyan) to 0x03EF. I mean, how do you convert a 16-bit color to a uint16? This doesn’t need to have an answer in code, because I just want to add some colors in the library. A link to a online converter (which I could not find) would be okay as well 🙂

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:23:59+00:00Added an answer on June 15, 2026 at 11:23 am

    From these one can easily find out the formula:

    #define Red             0xF800      /* 255,   0,   0 */  
    #define Magenta         0xF81F      /* 255,   0, 255 */
    #define Yellow          0xFFE0      /* 255, 255,   0 */
    

    F800 has 5 MSB bits set and FFE0 has 5 LSB not set.
    0xF81F has obviously both 5 LSB’s and 5 MSB’s set, which proves the format to be RGB565.

    The formula to convert a value 173 to Red is not as straightforward as it may look — you can’t simply drop the 3 least significant bits, but have to linearly interpolate to make 255 to correspond to 31 (or green 255 to correspond to 63).

    NewValue = (31 * old_value) / 255;
    

    (And this is still just a truncating division — proper rounding could be needed)

    With proper rounding and scaling:

    Uint16_value = (((31*(red+4))/255)<<11) | 
                   (((63*(green+2))/255)<<5) | 
                   ((31*(blue+4))/255);
    

    EDIT Added parenthesis to as helpfully suggested by JasonD.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'll try to be concise this time around! I'm still working Project Euler, this
EDIT:This is from a working project of mine. Working. I declared some char arrays
I had a working project. After rearranging some code, I tried to recompile my
I have a working project that Im amending, it crashes after trying to use
I'm currently editing a working project with some experience on PHP. I know a
I have opened a project in netbeans to view the project but there is
I have a working project, one of the screen is for example ViewController 1
This is supposed to be a working project from my friend. He demonstrated the
I'm copying some objective c++ files over from another (working) project. I get no
Im working on project to display rate on some field and I'm already get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.