user33987: I have the Arduino MEGA and an adafruit touch screen 2.8 inches.
My goal is to draw a pixel given a specific RGB
I am using the ILI9341, GFX, and TFT.h libraries to draw and control the touch screen. I noticed the drawPixel function given, in which it takes in three parameters and draws the pixel:
tft.drawPixel(4,4,ILI9341_BLUE);

But, I am trying to draw a pixel with specific a RGB. So instead, the function would ideally need 5 parameters instead of 3, x, y, and then R, G, and B:
tft.idealDrawPixel(5,6,89,234,76);

I tried putting in a number as the third parameter and not ILI9341_COLOR, and the screen just prints blue:
tft.drawPixel(45,67,255);

Is there a function that allows me to draw RGB pixels specifically? Thanks for any help!

user3917: As noted in the second paragraph on Adafruit's Graphics Library webpage, 

First thing to note is that color is 16-bit, and that includes Red, Green and Blue in a 16-bit variable. The way the color is packed in is the top 5 bits are red, the middle 6 bits are green and the bottom 5 bits are blue.

If you want to specify 8-bit color components, you could write an intermediary routine to translate from that form to the 565 form.  For example:
#define rgbDrawPixel(x,y,r,g,b) drawPixel(x,y,(((r)&0b11111000)<<8)|(((g)&0b11111100)<<3)|(((b)&0b11111000)>>3))

Note, this assumes the TFT library you're using has the same specs as Adafruit's.  That might or might not be; I don't know how to account for a 255 color number showing up as blue rather than white.

33987: <p>I have the Arduino MEGA and an adafruit touch screen 2.8 inches.</p>

<p><strong>My goal is to draw a pixel given a specific RGB</strong></p>

<p>I am using the <code>ILI9341</code>, <code>GFX</code>, and <code>TFT.h</code> libraries to draw and control the touch screen. I noticed the <code>drawPixel</code> function given, in which it takes in three parameters and draws the pixel:</p>

<pre><code>tft.drawPixel(4,4,ILI9341_BLUE);
</code></pre>

<p>But, I am trying to draw a pixel with specific a RGB. So instead, the function would ideally need 5 parameters instead of 3, x, y, and then R, G, and B:</p>

<pre><code>tft.idealDrawPixel(5,6,89,234,76);
</code></pre>

<p>I tried putting in a number as the third parameter and not <code>ILI9341_COLOR</code>, and the screen just prints blue:</p>

<pre><code>tft.drawPixel(45,67,255);
</code></pre>

<p>Is there a function that allows me to draw RGB pixels specifically? Thanks for any help!</p>
 3917: <p>As noted in the second paragraph on <a href="https://learn.adafruit.com/2-8-tft-touchscreen/graphics-library" rel="nofollow noreferrer">Adafruit's Graphics Library webpage</a>, </p>

<blockquote>
  <p>First thing to note is that color is 16-bit, and that includes Red, Green and Blue in a 16-bit variable. The way the color is packed in is the top 5 bits are red, the middle 6 bits are green and the bottom 5 bits are blue.</p>
</blockquote>

<p>If you want to specify 8-bit color components, you could write an intermediary routine to translate from that form to the 565 form.  For example:</p>

<pre><code>#define rgbDrawPixel(x,y,r,g,b) drawPixel(x,y,(((r)&amp;0b11111000)&lt;&lt;8)|(((g)&amp;0b11111100)&lt;&lt;3)|(((b)&amp;0b11111000)&gt;&gt;3))
</code></pre>

<p>Note, this assumes the TFT library you're using has the same specs as Adafruit's.  That might or might not be; I don't know how to account for a 255 color number showing up as blue rather than white.</p>
