#include <WiFi.h>
#include <HTTPClient.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#define TFT_CS 15//0
#define TFT_DC 2
#define TFT_MOSI 14
#define TFT_SCK 12
#define TFT_RST 13
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCK, TFT_RST);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
tft.begin();
tft.setRotation(2);
tft.setTextColor(ILI9341_WHITE);
tft.setTextSize(2);
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(0, 0);
//testRects(ILI9341_GREEN);
backgroundFloor(ILI9341_GREEN);
}
void loop() {
// put your main code here, to run repeatedly:
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(30,30);
tft.print("25C");
tft.setCursor(30,60);
tft.print("20%");
}
void backgroundFloor(uint16_t color)
{
/*tft.drawPixel(0,0, ILI9341_WHITE);
tft.drawPixel(0,237, ILI9341_RED);
tft.drawPixel(300,0, ILI9341_YELLOW);
tft.drawPixel(300, 237, ILI9341_GREEN);*/
tft.drawRect(4, 0, 232, 300, color); //x1,y1,x2,y2
tft.drawLine(4, 100, 100, 100, color);
tft.drawLine(4, 200, 234, 200, color);
tft.drawLine(135, 160, 234, 160, color);
tft.drawLine(135, 115, 234, 115, color);
tft.drawLine(135, 60, 234, 60, color);
tft.drawLine(100, 0, 100, 200, color);
tft.drawLine(135, 0, 135, 115, color);
tft.drawLine(145, 160, 145, 200, color);
}
unsigned long testRects(uint16_t color) {
unsigned long start;
int n, i, i2,
cx = tft.width() / 2,
cy = tft.height() / 2;
tft.fillScreen(ILI9341_BLACK);
n = min(tft.width(), tft.height());
start = micros();
for(i=2; i<n; i+=6) {
i2 = i / 2;
tft.drawRect(cx-i2, cy-i2, i, i, color);
}
return micros() - start;
}
Loading
ili9341-cap-touch
ili9341-cap-touch