Hi There ![]()
I have a 2.2" QVGA TFT color screen connected to an Arduino pro mini 3v3 8MHz using hardware SPI.
I used the following code to make the display work and plot on position 0.0 a blue square.
int xpos = 0; //position of cursor x direction
int ypos = 0; // position of cursor y direction
int color = 31; value 31 represents 0000 0000 0001 1111 or 0x001F which is in RGB 565 format: full Blue
#include "SPI.h"
#include <Adafruit_ILI9341.h>
#define TFT_CLK 13
#define TFT_MISO 12
#define TFT_MOSI 11
#define TFT_DC 9
#define TFT_CS 10
#define TFT_RST 8
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
void setup()
{
tft.begin();
}
void loop(void) {
tft.drawRect(xpos,ypos, 1, 1, color); // (x position , y position , rectangle width, reactangle length, Color in RGB 565 format)
}
Now the problem:
The variable "color" wants RGB565 (16bit) format data.
I want a function that accepts RGB888(24bit) format data ![]()
The reason for this is that i than easily can apply 1 8 bit variable for each color ( red, green, blue).
So i was tinking, isnt there a function like shown below for this ILI9431 driver?
screen.background(red,green,blue);// Red,green,blue values in 8 bit
This function in above code is from the Arduino TFT example which uses RGB888 input and controls a rgb565 tft display.
Another idea would be to convert RGB888 data with some code/math to RGB565. But i prefer to us a function which just accepts RGB888.
Kind regards