esp8266驱动TFT_LCD

/*  
 Test the tft.print() viz embedded tft.write() function

 This sketch used font 2, 4, 7
 
 Make sure all the display driver and pin connections are correct by
 editing the User_Setup.h file in the TFT_eSPI library folder.

 Note that yield() or delay(0) must be called in long duration for/while
 loops to stop the ESP8266 watchdog triggering.

 #########################################################################
 ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ######
 #########################################################################
 */
//安装库 TFT_eSPI
//先修改 TFT_eSPI库下面的 User_Setup.h
// 选择驱动芯片
// #define ST7735_DRIVER 
// 选择屏幕大小
// #define TFT_WIDTH  128
// #define TFT_HEIGHT 160
// 配置引脚
// #define TFT_CS   D8  // Chip select control pin D8
// #define TFT_DC   D3  // Data Command control pin
// #define TFT_RST  D4  // Reset pin (could connect to NodeMCU RST, see next line)

// 默认SCL D5  SDA D7
//配置下显示颜色 不然颜色显示不正确

#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
#include <SPI.h>

TFT_eSPI tft = TFT_eSPI();  // Invoke library, pins defined in User_Setup.h

#define TFT_GREY 0x5AEB // New colour

void setup(void) {
  tft.init();
  tft.setRotation(1);
}

void loop() {
  
  // Fill screen with grey so we can see the effect of printing with and without 
  // a background colour defined
  tft.fillScreen(TFT_GREY);
  
  // Set "cursor" at top left corner of display (0,0) and select font 2
  // (cursor will move to next line automatically during printing with 'tft.println'
  //  or stay on the line is there is room for the text with tft.print)
  tft.setCursor(0, 0, 2);
  // Set the font colour to be white with a black background, set text size multiplier to 1
  tft.setTextColor(TFT_WHITE,TFT_BLACK);  tft.setTextSize(1);
  // We can now plot text on screen using the "print" class
  tft.println("Hello World!");
  
  // Set the font colour to be yellow with no background, set to font 7
  tft.setTextColor(TFT_YELLOW); tft.setTextFont(2);
  tft.println(1234.56);
  
  // Set the font colour to be red with black background, set to font 4
  tft.setTextColor(TFT_RED,TFT_BLACK);    tft.setTextFont(4);
  tft.println((long)3735928559, HEX); // Should print DEADBEEF

  // Set the font colour to be green with black background, set to font 2
  tft.setTextColor(TFT_GREEN,TFT_BLACK);
  tft.setTextFont(2);
  tft.println("Groop");

  // Test some print formatting functions
  float fnumber = 123.45;
   // Set the font colour to be blue with no background, set to font 2
  tft.setTextColor(TFT_BLUE);    tft.setTextFont(2);
  tft.print("Float = "); tft.println(fnumber);           // Print floating point number
  tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary
  tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal

  while(1) yield(); // We must yield() to stop a watchdog timeout.
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在ESP8266TFT LCD上显示汉字,你需要进行以下几个步骤: 1. 确保你的TFT LCD模块支持显示汉字。有些模块可能需要额外的库或驱动来实现这个功能。 2. 在Arduino IDE或VSCode + PlatformIO中导入相应的库,例如Adafruit_GFX库和Adafruit_ILI9341库。这些库提供了在TFT LCD上显示文本和图形的功能。 3. 使用合适的字库文件来支持汉字显示。你可以在互联网上找到一些开源的字库文件,例如GB2312字库或UTF-8字库。将字库文件添加到你的项目中,并在代码中引用它们。 4. 使用相应的函数来显示汉字。根据你选择的字库文件,你可以使用相应的函数来将汉字转换为字节码,并在TFT LCD上显示出来。这些函数通常会接受汉字的Unicode编码作为参数。 请注意,具体的代码实现可能会因你使用的TFT LCD模块和字库文件而有所不同。你可以参考相关的文档和示例代码来了解更多细节和具体操作步骤。 #### 引用[.reference_title] - *1* *2* [ESP8266-Arduino编程实例-二维码(QR Code)生成与TFT LCD显示](https://blog.csdn.net/wujuxKkoolerter/article/details/127087528)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [基于STM32+ESP8266+TFTLCD的天气预报显示](https://blog.csdn.net/m0_46225622/article/details/108969736)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值