/* Im using double in this sketch to gain more precition*/
//
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
// For the Adafruit shield, these are the default.
#define TFT_DC 9
#define TFT_CS 10
// Color definitions
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
void setup() {
/*
// Begin Serial Comm
Serial.begin(9600);
Serial.println("ILI9341 Test!");
*/
//Begin TFT
tft.begin();
/*
// Read diagnostics (optional but can help debug problems)
uint8_t x = tft.readcommand8(ILI9341_RDMODE);
Serial.print("Display Power Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDMADCTL);
Serial.print("MADCTL Mode: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDPIXFMT);
Serial.print("Pixel Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDIMGFMT);
Serial.print("Image Format: 0x"); Serial.println(x, HEX);
x = tft.readcommand8(ILI9341_RDSELFDIAG);
Serial.print("Self Diagnostic: 0x"); Serial.println(x, HEX);
*/
//set screen rotation
tft.setRotation(1);
//fill screen black
tft.fillScreen(BLACK);
//set text wrap
tft.setTextWrap(true);
}
// the loop routine runs over and over again forever:
void loop() {
tft.setCursor(70,90);
tft.setTextSize(3);
tft.setTextColor(BLUE);
tft.println("Test1");
tft.setCursor(70,130);
tft.println("eiei");
tft.drawRoundRect(210,40,90,45,25,GREEN);
tft.setCursor(230,50);
tft.setTextSize(2);
tft.setTextColor(RED);
tft.println("pH =");
tft.setCursor(230,60);
tft.println("xx");
tft.drawRect(210,100,90,45,WHITE);
tft.fillRect(211,101,88,43,RED);
tft.setCursor(220,115);
tft.setTextSize(2);
tft.setTextColor(WHITE);
tft.println("ON/OFF");
delay(4000); // delay in between reads for stability
}
Loading
ili9341-cap-touch
ili9341-cap-touch