SKU:DFR0649 (https://www.dfrobot.com/product-2072.html)
(https://www.dfrobot.com/product-2072.html)
Introduction
This display module features high resolution, low power consumption, wide angle
and easy wiring. It employs IPS display with a small size of 1.54 inches, offering
240×240 resolution. The module adopts SPI and GDI interface(work with
maincontrollers with GDI port). This LCD display can be powered by 3.3V~5V, and
the maximum is power consumption is 24Ma. This product can be used in many
display applications: waveform monitor display, electronic gift box, electronic
weather decorations, etc.
Specification
Operating Voltage: 3.3V~5V
IPS Angle of View: 80/80/80/80
Color Depth: 16-bit (RGB565)
Pixels: 240 × 240
Connection Port: SPI
Driver Chip: ST7789
Brightness: 250 (Typ) cd/m2
Brightness: 250 (Typ) cd/m2
Full-screen Power Consumption: about 17mA (3.3V) 17mA (5V) (Typ)
Operating Temperature: -30℃~+70℃
Display Area: 27.72×27.72mm
Mount Hole Diameter: 2mm
Dimension: 44.00x39.00mm
Weight: g
Board Overview
Num
Label
Description
1
VCC
Positive
2
GND
Negative
3
SCLK
Clock
4
MOSI
Data (Master send; Slave receive)
5
MISO
Data (Master receive; Slave send)
6
CS
Screen Chip Select
7
RES
Reset
8
DC
Data/Command
9
BL
Backlight
The backlight has been set to a default value, and can be turned on without connecting the backlight pin.
When the backlight pin is connected, input High level(1) to turn the backlight brightness to maximum; Input Low level to
turn off backlight.
10
SDCS
SD card chip select
Dimension Diagram
Dimension:44.00x39.00mm/1.73x1.54”
Mount Hole Pitch:40mm/35mm
Mount Hole Size:2.0mm
Tutorial
The product is a Breakout module. It adopts SPI communication and has onboard GDI interface, which reduces the complexity of wiring and can
easily display the contents read from SD card.
NOTE
1. GDI interface could only work well with maincontrollers with GDI.
2. It is recommended to use Arduino 1.8.10 and above.
3. If the SD card is not in good contact, it may fail to initialize, and then please try to replug it.
Requirements
Hardware
DFRduino UNO R3 (https://www.dfrobot.com/product-838.html) (or similar) x 1
1.54" 240x240 LCD Module x 1
M-M/F-M/F-F Jumper wires
Wires
Software
Arduino IDE (https://www.arduino.cc/en/Main/Software)
Download and install the DFRobot_GDL Library (https://codeload.github.com/DFRobot/DFRobot_GDL/zip/master) (About how to
install the library? (https://www.arduino.cc/en/Guide/Libraries#.UxU8mdzF9H0))
DFRobot_GDL API Function, click to find more detailed information (https://github.com/DFRobot/DFRobot_GDL/wiki/English-WIKI)
NOTE
1. All the demo files of this product are stored in file DFRobot_GDL->example->basic.
p
p
2. Please open the corresponding constructed functions (DFRobot_ST7789_240x240_HW_SPI) before burning demo into your device.
Connection Diagram
Sample Code 1
This is a basic sample to show you how to draw point, circle, line, and rectangle on the module.
v/*!
* @file basicTest.ino
* @brief Demonstrate various graphic painting effects
* @n This demo supports Arduino Uno, Leonardo, Mega2560, FireBeetle-ESP32, FireBeetle-ESP8266, and FireBeetle-M0.
* @copyright Copyright (c) 2010 DFRobot Co. Ltd (http://www.dfrobot.com)
* @licence The MIT License (MIT)
* @author [LuoYufeng] (yufeng.luo@dfrobot.com)
* @version V0.1
* @date 2020-01-07
* @url https://github.com/DFRobot/DFRobot_GDL
*/
#include "DFRobot_GDL.h"
/*M0*/
#if defined ARDUINO_SAM_ZERO
#define TFT_DC 7
#define TFT_CS 5
#define TFT_RST 6
/*ESP32 and ESP8266*/
#elif defined(ESP32) || defined(ESP8266)
#define TFT_DC D3
#define TFT_CS D4
#define TFT_RST D5
/*AVR series mainboard*/
#else
#define TFT_DC 2
#define TFT_CS 3
#define TFT_RST 4
#endif
/**
* @brief Constructor Constructor of hardware SPI communication
* @param dc Command/data line pin for SPI communication
* @param dc Command/data line pin for SPI communication
* @param cs Chip select pin for SPI communication
* @param rst reset pin of the screen
*/
DFRobot_ST7789_240x240_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
//DFRobot_ST7789_240x320_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
//DFRobot_ILI9341_240x320_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
//DFRobot_ILI9488_320x480_HW_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
/* M0 mainboard DMA transfer */
//DFRobot_ST7789_240x240_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
//DFRobot_ST7789_240x320_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
//DFRobot_ILI9341_240x320_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
//DFRobot_ILI9488_320x480_DMA_SPI screen(/*dc=*/TFT_DC,/*cs=*/TFT_CS,/*rst=*/TFT_RST);
/*
*User-selectable macro definition color
*COLOR_RGB565_BLACK
COLOR_RGB565_NAVY
*COLOR_RGB565_MAROON COLOR_RGB565_PURPLE
*COLOR_RGB565_DGRAY
COLOR_RGB565_BLUE
*COLOR_RGB565_RED
COLOR_RGB565_MAGENTA
*COLOR_RGB565_WHITE
*/
COLOR_RGB565_DGREEN
COLOR_RGB565_OLIVE
COLOR_RGB565_GREEN
COLOR_RGB565_YELLOW
void setup() {
Serial.begin(115200);
screen.begin();
}
void loop(){
testDrawPixel();
testLine();
testFastLines(COLOR_RGB565_PURPLE,COLOR_RGB565_YELLOW);
testRects(COLOR_RGB565_BLACK,COLOR_RGB565_WHITE);
testRoundRects();
testCircles(24,COLOR_RGB565_BLUE);
testTriangles(COLOR_RGB565_YELLOW);
t tP i t()
COLOR_RGB565_DCYAN
COLOR_RGB565_LGRAY
COLOR_RGB565_CYAN
COLOR_RGB565_ORANGE
testPrint();
}
/* Test to draw a pixel*/
void testDrawPixel() {
//Clear screen
screen.fillScreen(COLOR_RGB565_BLACK);
int x = 0;
int y = screen.height();
for(int i = 0; i = i; x-=10 ){
/*
* @ brief draw a pixel
* @ param x coordinate
*
y coordinate
* c pixel color
*/
screen.drawPixel(x, y, COLOR_RGB565_ORANGE);
delay(10);
}
for (y = screen.height() - i; y >= i; y-=10){
screen.drawPixel(x, y, COLOR_RGB565_ORANGE);
delay(10);
}
for (x = i; x = 0; y-=6) {
screen.drawLine(screen.width()/2, screen.height()/2, 0, y, color+=0x0700);
}
}
/* Test to fast draw line(need to set delay), only horizontal line and vertical line */
void testFastLines(uint16_t color1, uint16_t color2) {
for (int16_t y=0; y < screen.height(); y+=4) {
/*
* @ brief draw a line
* @ param x The x-coordinate of the first vertex
*
Th
di t
f th fi t
t
*
y The y-coordinate of the first vertex
*
w Length of line segment
*
c line color
*/
screen.drawFastHLine(/*x=*/0, /*y=*/y, /*w=*/screen.width(),/*c=*/color2);
delay(10);
}
for(int16_t x=0; x < screen.width(); x+=3) {
/*
* @ brief draw a line
* @ param x The x-coordinate of the first vertex
*
y The y-coordinate of the first vertex
*
h length of line segment
*
c line color
*/
screen.drawFastVLine(/*x=*/x, /*y=*/0, /*h=*/screen.height(), /*c=*/color1);
delay(10);
}
}
/* Test to draw a rectangle*/
void testRects(uint16_t color1, uint16_t color2) {
screen.fillScreen(COLOR_RGB565_BLACK);
int16_t x=screen.width()-12;
for (; x > 100; x-=screen.width()/40) {
/*
* @ brief draw a hollow rectangle
* @ param x The x-coordinate of the vertex
* @ param y The y-coordinate of the vertex
* @ param w horizontal side length
* @ param h longitudinal side length
* @ param color Fill color, RGB color with 565 structure
*/
screen.drawRect(/*x=*/screen.width()/2 -x/2, /*y=*/screen.height()/2 -x/2 , /*w=*/x, /*h=*/x, /*color=*/color2+=0x0F00);
delay(100);
}
/*
* @ brief draw a filled rectangle
* @ param x The x-coordinate of the vertex
* @ param y The y-coordinate of the vertex
* @ param w horizontal side length
* @ param h longitudinal side length
* @ param color Fill color, RGB color with 565 structure
*/
screen.fillRect(/*x=*/screen.width()/2 -x/2, /*y=*/screen.height()/2 -x/2 , /*w=*/x, /*h=*/x, /*color=*/color2);
delay(100);
for(; x > 6; x-=screen.width()/40){
screen.drawRect(screen.width()/2 -x/2, screen.height()/2 -x/2 , x, x, color1);
delay(100);
}
}
/* Test to draw a rounded rectangle */
void testRoundRects() {
screen.fillScreen(COLOR_RGB565_BLACK);
// 0xF00F is the color data in the format of RGB565
int color = 0xF00F;
int i;
int x = 0;
int y = 0;
int w = screen.width()-3;
int h = screen.height()-3;
for(i = 0 ; i