1.54英寸240x240 IPS TFT LCD显示模块:高分辨率与低功耗的完美结合

电子说

1.4w人已加入

描述

1.54英寸240x240 IPS TFT LCD显示模块:高分辨率与低功耗的完美结合

在电子设计领域,显示模块的性能对于产品的整体表现至关重要。今天要给大家介绍一款极具特色的1.54英寸240x240 IPS TFT LCD显示模块,它以高分辨率、低功耗等优势,在众多显示应用场景中脱颖而出。

文件下载:DFR0649.pdf

一、模块特性

1. 高分辨率与小尺寸

该模块采用1.54英寸的IPS显示屏,具备240×240的分辨率,能够提供清晰、细腻的显示效果。小尺寸的设计使其在空间有限的应用场景中也能完美适配,如电子礼品盒、电子天气装饰品等。

2. 低功耗设计

模块可在3.3V - 5V的电压下工作,最大功耗仅为24mA,全屏功耗约为17mA(3.3V和5V时典型值)。这种低功耗特性使得它在对功耗要求较高的设备中表现出色,能够有效延长设备的续航时间。

3. 宽视角与易接线

IPS显示屏提供80/80/80/80的视角,无论从哪个角度观看,都能获得清晰、准确的显示效果。同时,模块采用SPI和GDI接口,与带有GDI端口的主控制器配合使用,大大降低了接线的复杂度。

二、规格参数

参数 详情
工作电压 3.3V - 5V
IPS视角 80/80/80/80
颜色深度 16位(RGB565)
像素 240 × 240
连接端口 SPI
驱动芯片 ST7789
亮度 250(Typ)cd/m²
SKU DFR0649
工作温度 -30℃ - +70℃
显示区域 27.72×27.72mm
安装孔直径 2mm
尺寸 44.00x39.00mm

三、引脚说明

编号 标签 说明
1 VCC 电源正极
2 GND 电源负极
3 SCLK 时钟信号
4 MOSI 数据(主发送;从接收)
5 MISO 数据(主接收;从发送)
6 CS 屏幕芯片选择
7 RES 复位
8 DC 数据/命令
9 BL 背光灯(已设置默认值,可不连接;连接时,高电平开启最大亮度,低电平关闭)
10 SDCS SD卡芯片选择

四、使用教程

1. 硬件要求

  • DFRduino UNO R3(或类似)x 1
  • 1.54" 240x240 LCD模块 x 1
  • M - M/F - M/F - F跳线线
  • 电线

2. 软件要求

  • Arduino IDE
  • 下载并安装DFRobot_GDL库

3. 注意事项

  • GDI接口只能与带有GDI的主控制器配合使用。
  • 建议使用Arduino 1.8.10及以上版本。
  • 如果SD卡接触不良,可能会导致初始化失败,此时可尝试重新插拔。

五、示例代码

1. 基本绘图示例

此示例展示了如何在模块上绘制点、圆、线和矩形等图形。通过设置不同的颜色和参数,可以实现各种图形的绘制效果。

#include "DFRobot_GDL.h" 

// 根据不同主板设置引脚
#if defined ARDUINO_SAM_ZERO 
#define TFT_DC 7 
#define TFT_CS 5 
#define TFT_RST 6 
#elif defined(ESP32) || defined(ESP8266) 
#define TFT_DC D3 
#define TFT_CS D4 
#define TFT_RST D5 
#else 
#define TFT_DC 2 
#define TFT_CS 3 
#define TFT_RST 4 
#endif 

DFRobot_ST7789_240x240_HW_SPI screen(TFT_DC, TFT_CS, TFT_RST); 

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); 
  testPrint(); 
} 

// 测试绘制像素点
void testDrawPixel() { 
  screen.fillScreen(COLOR_RGB565_BLACK); 
  int x = 0; 
  int y = screen.height(); 
  for(int i = 0; i <= screen.width()/2; i += 10) { 
    for (x = screen.width() - i; x >= i; x -= 10) { 
      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 <= screen.width() - i + 1; x += 10) { 
      screen.drawPixel(x, y, COLOR_RGB565_ORANGE); 
      delay(10); 
    } 
    for (y = i; y <= screen.height() - i + 1; y += 10) { 
      screen.drawPixel(x, y, COLOR_RGB565_ORANGE); 
      delay(10); 
    } 
  } 
} 

// 测试绘制直线
void testLine() { 
  uint16_t color = 0x00FF; 
  screen.fillScreen(COLOR_RGB565_BLACK); 
  for (int16_t x = 0; x < screen.width(); x += 6) { 
    screen.drawLine(screen.width()/2, screen.height()/2, x, 0, color); 
  } 
  for (int16_t y = 0; y < screen.height(); y += 6) { 
    screen.drawLine(screen.width()/2, screen.height()/2, screen.width(), y, color += 0x0700); 
  } 
  for (int16_t x = screen.width(); x >= 0; x -= 6) { 
    screen.drawLine(screen.width()/2, screen.height()/2, x, screen.height(), color += 0x0700); 
  } 
  for (int16_t y = screen.height(); y >= 0; y -= 6) { 
    screen.drawLine(screen.width()/2, screen.height()/2, 0, y, color += 0x0700); 
  } 
} 

// 测试快速绘制直线(仅水平和垂直线)
void testFastLines(uint16_t color1, uint16_t color2) { 
  for (int16_t y = 0; y < screen.height(); y += 4) { 
    screen.drawFastHLine(0, y, screen.width(), color2); 
    delay(10); 
  } 
  for (int16_t x = 0; x < screen.width(); x += 3) { 
    screen.drawFastVLine(x, 0, screen.height(), color1); 
    delay(10); 
  } 
} 

// 测试绘制矩形
void testRects(uint16_t color1, uint16_t color2) { 
  int16_t x = screen.width() - 12; 
  for (; x > 100; x -= screen.width()/40) { 
    screen.fillScreen(COLOR_RGB565_BLACK); 
    screen.drawRect(screen.width()/2 - x/2, screen.height()/2 - x/2, x, x, color2 += 0x0F00); 
    delay(100); 
  } 
  screen.fillRect(screen.width()/2 - x/2, screen.height()/2 - x/2, x, x, 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); 
  } 
} 

// 测试绘制圆角矩形
void testRoundRects() { 
  screen.fillScreen(COLOR_RGB565_BLACK); 
  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 <= 16; i += 2) { 
    screen.drawRoundRect(x, y, w, h, 20, color); 
    x += 5; 
    y += 5; 
    w -= 10; 
    h -= 10; 
    color += 0x0100; 
    delay(50); 
  } 
  for (i = 0; i <= 16; i += 2) { 
    screen.fillRoundRect(x, y, w, h, 10, color); 
    x += 5; 
    y += 5; 
    w -= 10; 
    h -= 10; 
    color += 0x0500; 
    delay(50); 
  } 
} 

// 测试绘制圆形
void testCircles(uint8_t radius, uint16_t color) { 
  screen.fillScreen(COLOR_RGB565_BLACK); 
  for (int16_t x = radius; x <= screen.width() - radius; x += radius * 2) { 
    for (int16_t y = radius; y <= screen.height() - radius; y += radius * 2) { 
      screen.drawCircle(x, y, radius, color); 
      if (x == y || x == -y || x == y + 2 * radius) { 
        color += 800; 
        screen.fillCircle(x, y, radius, color); 
      } 
      delay(100); 
    } 
  } 
} 

// 测试绘制三角形
void testTriangles(uint16_t color) { 
  screen.fillScreen(COLOR_RGB565_BLACK); 
  for (int16_t i = 0; i <= screen.width(); i += 24) { 
    screen.drawTriangle(i, 0, 0, screen.height() - i, screen.width() - i, screen.height(), color); 
  } 
  for (int16_t i = 0; i < screen.width(); i += 24) { 
    screen.drawTriangle(screen.width(), i * 4/3, 0, screen.height() - i * 4/3, i, 0, color); 
  } 
  for (int16_t i = 0; i < screen.width(); i += 24) { 
    screen.drawTriangle(screen.width(), i * 4/3, i, 0, screen.width() - i, screen.height(), color); 
  } 
  color = COLOR_RGB565_RED; 
  for (int16_t i = 0; i <= screen.width(); i += 24) { 
    screen.fillTriangle(i, 0, 0, screen.height() - i, screen.width() - i, screen.height(), color); 
  } 
  for (int16_t i = 0; i < screen.width(); i += 24) { 
    screen.fillTriangle(screen.width(), i * 4/3, 0, screen.height() - i * 4/3, i, 0, color += 100); 
  } 
  for (int16_t i = 0; i < screen.width(); i += 24) { 
    screen.fillTriangle(screen.width(), i * 4/3, i, 0, screen.width() - i, screen.height(), color += 100); 
  } 
} 

// 测试打印文本
void testPrint() { 
  int16_t color = 0x00FF; 
  screen.setTextWrap(false); 
  screen.fillScreen(COLOR_RGB565_BLACK); 
  screen.setCursor(0, 50); 
  screen.setTextColor(color += 0x3000); 
  screen.setTextSize(0); 
  screen.println("Hello World!"); 
  screen.setTextColor(color += 0x3000); 
  screen.setTextSize(1); 
  screen.println("Hello World!"); 
  screen.setTextColor(color += 0x3000); 
  screen.setTextSize(2); 
  screen.println("Hello World!"); 
  screen.setTextColor(color += 0x3000); 
  screen.setTextSize(3); 
  screen.println("Hello World!"); 
  screen.setTextColor(color += 0x3000); 
  screen.setTextSize(4); 
  screen.println("Hello!"); 
  screen.setTextSize(5); 
  screen.print("Hello!"); 
  delay(2000); 
  screen.setCursor(0, 0); 
  screen.fillScreen(COLOR_RGB565_BLACK); 
  screen.setTextSize(2); 
  screen.setTextColor(color += 0x3000); 
  screen.print("a = "); 
  screen.setTextColor(color += 0x3000); 
  int a = 1234; 
  screen.println(a, 1); 
  screen.setTextColor(color += 0x3000); 
  screen.print(8675309, HEX); 
  screen.println("this is HEX!"); 
  screen.println(""); 
  screen.setTextColor(color += 0x0F00); 
  screen.println("running for: "); 
  screen.setTextColor(color += 0x0F00); 
  screen.print(millis()); 
  screen.setTextColor(color += 0x0F00); 
  screen.println("/1000 seconds."); 
  char *text = "Hi DFRobot!"; 
  screen.setTextColor(color += 0x0F00); 
  screen.setTextWrap(true); 
  screen.setTextSize(3); 
  screen.println(text); 
  delay(2000); 
}

2. 图标显示示例

此示例展示了如何在屏幕上显示一些常用图标。首先需要使用GIMP2将图标转换为代码,然后通过代码在屏幕上显示这些图标。


#include "DFRobot_GDL.h" 
#include "Icon.h" 

// 根据不同主板设置引脚
#if defined ARDUINO_SAM_ZERO 
#define TFT_DC 7 
#define TFT_CS 5 
#define TFT_RST 6 
#elif defined(ESP32) || defined(ESP8266) 
#define TFT_DC D3 
#define TFT_CS D4 
#define TFT_RST D5 
#else 
#define TFT_DC 2 
#define TFT_CS 3 
#define TFT_RST 4 
#endif 

DFRobot_ST7789_240x240_HW_SPI screen(TFT_DC, TFT_CS, TFT_RST); 

void setup() { 
  Serial.begin(115200); 
  screen.begin(); 
} 

void loop() { 
  int w = screen.width(); 
  int h = screen.height(); 
  int a = millis()/1000; 
  uint16_t color = 0x00FF; 
  screen.fillScreen(COLOR_RGB565_WHITE); 
  while (1) { 
    for (int i = 0; i < 12; i++) { 
      screen.fillRect(16, 16, w - 16 * 2, 35, COLOR_RGB565_WHITE); 
      screen.setTextWrap(false); 
      screen.setTextColor(0x30FF); 
      screen.setTextSize(3); 
      screen.setCursor(30, 30); 
      screen.println("Time:"); 
      screen.setTextColor(0x00FF); 
      screen.setTextSize(3); 
      screen.setCursor(120, 30); 
      a = millis()/1000; 
      screen.println(a, 1); 
      screen.fillRoundRect(w/2 - 48 - 12, h/2 - 16 - 8, 32 * 3 + 12 * 2, 32 + 8 * 2, 20, 0x0000); 
      for (int x = 0; x < 16; x++) { 
        screen.drawFastVLine(x, 0, h, color); 
      } 
      screen.drawFastHLine(16, 0, w - 16 * 2, color); 
      for (int y = 0; y < 16; y++) { 
        screen.drawFastHLine(16, y, w - 16 * 2, color); 
打开APP阅读更多精彩内容
声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

全部0条评论

快来发表一下你的评论吧 !

×
20
完善资料,
赚取积分