/*
Adafruit_ILI9341 TFT LCD顯示器
需要函式:U8g2_for_Adafruit_GFX
Adafruit SSD1306 library.
支援中文-UTF-8
所有字型提供:https://github.com/olikraus/u8g2/wiki/fntlistall
*/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
#include "U8g2_for_Adafruit_GFX.h"
//SPI 介面
#define TFT_DC 21
#define TFT_CS 22
//顯示器名稱:display
Adafruit_ILI9341 display = Adafruit_ILI9341(TFT_CS, TFT_DC);
U8G2_FOR_ADAFRUIT_GFX u8g2; //物件名稱
void setup() {
display.begin(); //啟動
display.setRotation(1); //右轉90°配合顯示器方向
display.fillScreen(ILI9341_BLACK);//清除畫面
u8g2.begin(display); // 連結U8G2到Adafruit GFX
}
unsigned long x = 0; //迴圈計數器
void loop() {
u8g2.setFontMode(0); //設置字體模式為透明
u8g2.setFontDirection(0); //內定由左至右
u8g2.setForegroundColor(ILI9341_WHITE); //前景色白色
u8g2.setFont(u8g2_font_helvR14_tf); //選用字型
//支援Unicode Values for the ASCII
u8g2.drawUTF8(0, 20, "ASCII Code \u00A7 \u00A9 \u00AE"); //
u8g2.setForegroundColor(ILI9341_GREEN); //前景色綠色
u8g2.setFont(u8g2_font_ncenB14_tr); //選用字型
u8g2.setCursor(0,40); // (x,y)
u8g2.print("Hello World");
u8g2.setFont(u8g2_font_unifont_t_chinese2); //中文字型2
u8g2.setForegroundColor(ILI9341_RED); //文字顏色
u8g2.setCursor(0,60); // 定位顯示(x,y)=(0,60)
u8g2.println("有中文真好~"); // 顯示中文
//u8g2.println("每年農曆8月15日的中秋節,");
//u8g2.println("和端午、春節並稱華人三大節日"); // 顯示中文
u8g2.setFont(u8g2_font_inb63_mn); // 選用字型
u8g2.setFontMode(0); //透明模式
u8g2.setCursor(0,220); //定位
u8g2.setForegroundColor(ILI9341_BLUE); //藍字
u8g2.print(x); //顯示計數值
x++;
delay(1000);
}