Wemos 1.44“ inch TFT LCD shield examples

In this example we look at the 1.44“ inch TFT LCD shield from Wemos. It can display 128×128 resolution and 18-bit color

The TFT is based on an ST7735S driver. Here is a picture of the LCD shield

The shield uses the following pins

D1 mini Shield
RST*(D0/D3/D4)) TFT_RST
D3*(D0/D4/D8) TFT_DC
D4*(D0/D3/D8) TFT_CS
D7 MOSI
D5 SCK
NC*(D0/D3/D4/D8) TFT_LED
*default

 

Code

You need to install the Adafruit_GFX and Adafruit_ST7735 libraries. You can do this in the Arduino libraries

Here are several examples

Example 1

 

[codesyntax lang=”cpp”]

#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#define TFT_RST -1
#define TFT_CS D4
#define TFT_DC D3

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void)
{
tft.initR(INITR_144GREENTAB);
tft.setTextWrap(false); // Allow text to run off right edge
tft.fillScreen(ST7735_BLACK);
}

void loop(void)
{
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0, 0);
tft.setTextColor(ST7735_BLUE);
tft.setTextSize(2);
tft.println("ESP8266");
tft.setRotation(tft.getRotation() + 1);
delay(3000);
}

[/codesyntax]

 

Example 2

 

[codesyntax lang=”cpp”]

//triangles
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#define TFT_RST -1
#define TFT_CS D4
#define TFT_DC D3

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void)
{
tft.initR(INITR_144GREENTAB);
}

void loop(void) 
{
tft.fillScreen(ST77XX_BLACK);
int color = 0xF800;
int t;
int w = tft.width()/2;
int x = tft.height()-1;
int y = 0;
int z = tft.width();
for(t = 0 ; t <= 15; t++) 
{
tft.drawTriangle(w, y, y, x, z, x, color);
x-=4;
y+=4;
z-=4;
color+=100;
}
delay(500);
}

[/codesyntax]

 

 

Example 3

 

[codesyntax lang=”cpp”]

//round rectangles
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#define TFT_RST -1
#define TFT_CS D4
#define TFT_DC D3

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void)
{
tft.initR(INITR_144GREENTAB);
}

void loop(void) 
{
tft.fillScreen(ST77XX_BLACK);
int color = 100;
int i;
int t;
for(t = 0 ; t <= 4; t+=1) 
{
int x = 0;
int y = 0;
int w = tft.width()-2;
int h = tft.height()-2;
for(i = 0 ; i <= 16; i+=1) 
{
tft.drawRoundRect(x, y, w, h, 5, color);
x+=2;
y+=3;
w-=4;
h-=6;
color+=1100;
}
color+=100;
}
delay(500);
}

[/codesyntax]

 

 

Example 4

 

[codesyntax lang=”cpp”]

//text examples
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#define TFT_RST -1
#define TFT_CS D4
#define TFT_DC D3

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void)
{
tft.initR(INITR_144GREENTAB);
}

void loop(void) 
{
float p = 3.1415926;
tft.setTextWrap(false);
tft.fillScreen(ST77XX_BLACK);
tft.setCursor(0, 30);
tft.setTextColor(ST77XX_RED);
tft.setTextSize(1);
tft.println("Hello World!");
tft.setTextColor(ST77XX_YELLOW);
tft.setTextSize(2);
tft.println("Hello World!");
tft.setTextColor(ST77XX_GREEN);
tft.setTextSize(3);
tft.println("Hello World!");
tft.setTextColor(ST77XX_BLUE);
tft.setTextSize(4);
tft.print(1234.567);
delay(2500);
tft.setCursor(0, 0);
tft.fillScreen(ST77XX_BLACK);
tft.setTextColor(ST77XX_WHITE);
tft.setTextSize(0);
tft.println("Hello World!");
tft.setTextSize(1);
tft.setTextColor(ST77XX_GREEN);
tft.print(p, 6);
tft.println(" Want pi?");
tft.println(" ");
tft.print(8675309, HEX); // print 8,675,309 out in HEX!
tft.println(" Print HEX!");
tft.println(" ");
tft.setTextColor(ST77XX_WHITE);
tft.println("Sketch has been");
tft.println("running for: ");
tft.setTextColor(ST77XX_MAGENTA);
tft.print(millis() / 1000);
tft.setTextColor(ST77XX_WHITE);
tft.print(" seconds.");
delay(2500);
}

[/codesyntax]

 

 

Example 5

 

[codesyntax lang=”cpp”]

//rectangle examples
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#define TFT_RST -1
#define TFT_CS D4
#define TFT_DC D3

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void)
{
tft.initR(INITR_144GREENTAB);
}

void loop(void) 
{
tft.fillScreen(ST77XX_BLACK);
//rectangles
for (int16_t x=0; x < tft.width(); x+=6) 
{
tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, ST77XX_WHITE);
}
delay(2500);
//filled rectangles
tft.fillScreen(ST77XX_BLACK);
for (int16_t x=tft.width()-1; x > 6; x-=6) 
{
tft.fillRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, ST77XX_YELLOW);
tft.drawRect(tft.width()/2 -x/2, tft.height()/2 -x/2 , x, x, ST77XX_MAGENTA);
}
delay(2500);
}

[/codesyntax]

 

 

Example 6

 

[codesyntax lang=”cpp”]

//circle examples
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#define TFT_RST -1
#define TFT_CS D4
#define TFT_DC D3

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void)
{
tft.initR(INITR_144GREENTAB);
}

void loop(void) 
{
int radius = 10;
tft.fillScreen(ST77XX_BLACK);
//filled circle
for (int16_t x=radius; x < tft.width(); x+=radius*2) 
{
for (int16_t y=radius; y < tft.height(); y+=radius*2) 
{
tft.fillCircle(x, y, radius, ST77XX_YELLOW);
}
}
delay(2500);
//circles
tft.fillScreen(ST77XX_BLACK);
for (int16_t x=0; x < tft.width()+radius; x+=radius*2) 
{
for (int16_t y=0; y < tft.height()+radius; y+=radius*2) 
{
tft.drawCircle(x, y, radius, ST77XX_MAGENTA);
}
}
delay(2500);
}

[/codesyntax]

 

 

Example 7

 

[codesyntax lang=”cpp”]

//play button
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#define TFT_RST -1
#define TFT_CS D4
#define TFT_DC D3

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void)
{
tft.initR(INITR_144GREENTAB);
}

void loop(void) 
{
tft.fillScreen(ST77XX_BLACK);
tft.fillRoundRect(25, 10, 78, 60, 8, ST77XX_WHITE);
tft.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_RED);
delay(500);
// play color
tft.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_BLUE);
delay(500);
// play color
tft.fillTriangle(42, 20, 42, 60, 90, 40, ST77XX_GREEN);
}

[/codesyntax]

 

 

Example 8

 

[codesyntax lang=”cpp”]

#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#define TFT_RST -1
#define TFT_CS D4
#define TFT_DC D3

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void)
{
tft.initR(INITR_144GREENTAB);
}

void loop(void) 
{
uint16_t color = ST77XX_YELLOW;
tft.fillScreen(ST77XX_BLACK);
for (int16_t x=0; x < tft.width(); x+=6) 
{
tft.drawLine(0, 0, x, tft.height()-1, color);
delay(0);
}
for (int16_t y=0; y < tft.height(); y+=6)
{
tft.drawLine(0, 0, tft.width()-1, y, color);
delay(0);
}
}

[/codesyntax]

 

 

Example 9

 

[codesyntax lang=”cpp”]

#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>

#define TFT_RST -1
#define TFT_CS D4
#define TFT_DC D3

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void)
{
tft.initR(INITR_144GREENTAB);
}

void loop(void) 
{
for (uint8_t i=0; i<4; i++) 
{
tft.fillScreen(ST77XX_BLACK);
tft.drawCircle(10, 30, 10, ST77XX_YELLOW);
tft.setRotation(tft.getRotation()+1);
}
delay(500);
for (uint8_t i=0; i<4; i++) 
{
tft.fillScreen(ST77XX_BLACK);
tft.fillRect(10, 20, 10, 20, ST77XX_GREEN);
tft.setRotation(tft.getRotation()+1);
}
delay(500);
}

[/codesyntax]

 

Video

A youtube video we made of  these examples

 

Link

ESP8266 TFT 1.4 Shield V1.0.0 Display Screen Module for D1 mini 1.44″ inch 128X128 SPI LCD ST7735S

LEAVE A REPLY

Please enter your comment!
Please enter your name here