├── .gitignore ├── image ├── SD.jpg ├── image4.jpg └── pinmap.jpg ├── firmware ├── esp32-1.png ├── esp32-2.png ├── firmware.bin └── README.MD ├── 3d_file ├── README.md ├── T-Display.step ├── prt0003_23.stl └── prt0005_14(2).stl ├── TFT_eSPI ├── Fonts │ ├── TrueType │ │ └── Not_yet_supported.txt │ ├── Font16.h │ ├── Font32rle.h │ ├── Font64rle.h │ ├── Font72rle.h │ ├── Font7srle.h │ ├── Font72x53rle.h │ └── GFXFF │ │ ├── license.txt │ │ └── print.txt ├── Tools │ ├── Images │ │ ├── star.bmp │ │ └── README.md │ ├── RPi_TFT_mod.png │ ├── RPi_TFT_Connections.png │ ├── ESP32 UNO board mod │ │ ├── ESP32 UNO board mod.jpg │ │ └── ESP32 UNO board pinout.jpg │ ├── Create_Smooth_Font │ │ └── Create_font │ │ │ ├── data │ │ │ └── Final-Frontier.ttf │ │ │ └── FontFiles │ │ │ └── Final-Frontier28.vlw │ └── PlatformIO │ │ └── Configuring options.txt ├── examples │ ├── Sprite │ │ ├── Animated_dial │ │ │ └── data │ │ │ │ └── dial.jpg │ │ ├── Rotated_Sprite_3 │ │ │ └── data │ │ │ │ ├── EagleEye.jpg │ │ │ │ └── Eye_80x64.jpg │ │ └── Sprite_image_4bit │ │ │ └── sample_images.h │ ├── Generic │ │ ├── TFT_SPIFFS_BMP │ │ │ ├── data │ │ │ │ └── parrot.bmp │ │ │ ├── TFT_SPIFFS_BMP.ino │ │ │ └── BMP_functions.ino │ │ ├── ESP32_SDcard_jpeg │ │ │ └── Data │ │ │ │ ├── Baboon40.jpg │ │ │ │ ├── EagleEye.jpg │ │ │ │ ├── Mouse480.jpg │ │ │ │ └── lena20k.jpg │ │ ├── drawXBitmap │ │ │ ├── drawXBitmap.ino │ │ │ └── xbm.h │ │ ├── TFT_Flash_Bitmap │ │ │ └── TFT_Flash_Bitmap.ino │ │ └── Touch_calibrate │ │ │ └── Touch_calibrate.ino │ ├── ePaper │ │ └── Floyd_Steinberg │ │ │ ├── data │ │ │ ├── Tiger.bmp │ │ │ └── TestCard.bmp │ │ │ └── SPIFFS.ino │ ├── Smooth Fonts │ │ ├── SPIFFS │ │ │ ├── Font_Demo_1 │ │ │ │ ├── data │ │ │ │ │ ├── NotoSansBold15.vlw │ │ │ │ │ └── NotoSansBold36.vlw │ │ │ │ └── Notes.ino │ │ │ ├── Font_Demo_2 │ │ │ │ ├── data │ │ │ │ │ ├── NotoSansBold15.vlw │ │ │ │ │ └── NotoSansBold36.vlw │ │ │ │ └── Notes.ino │ │ │ ├── Font_Demo_3 │ │ │ │ ├── data │ │ │ │ │ ├── NotoSansBold15.vlw │ │ │ │ │ ├── NotoSansBold36.vlw │ │ │ │ │ └── NotoSansMonoSCB20.vlw │ │ │ │ └── Notes.ino │ │ │ ├── Font_Demo_4 │ │ │ │ ├── data │ │ │ │ │ ├── NotoSansBold15.vlw │ │ │ │ │ └── NotoSansBold36.vlw │ │ │ │ └── Notes.ino │ │ │ ├── Unicode_test │ │ │ │ ├── data │ │ │ │ │ ├── Unicode-Test-72.vlw │ │ │ │ │ ├── Final-Frontier-28.vlw │ │ │ │ │ └── Latin-Hiragana-24.vlw │ │ │ │ └── SPIFFS_functions.ino │ │ │ ├── Print_Smooth_Font │ │ │ │ └── data │ │ │ │ │ └── Final-Frontier-28.vlw │ │ │ ├── Smooth_font_gradient │ │ │ │ └── data │ │ │ │ │ ├── NotoSansBold15.vlw │ │ │ │ │ └── NotoSansBold36.vlw │ │ │ └── Smooth_font_reading_TFT │ │ │ │ └── data │ │ │ │ ├── NotoSansBold15.vlw │ │ │ │ └── NotoSansBold36.vlw │ │ ├── FLASH_Array │ │ │ ├── Unicode_test │ │ │ │ └── data │ │ │ │ │ ├── Unicode-Test-72.vlw │ │ │ │ │ ├── Final-Frontier-28.vlw │ │ │ │ │ └── Latin-Hiragana-24.vlw │ │ │ ├── Font_Demo_1_Array │ │ │ │ └── Notes.ino │ │ │ ├── Font_Demo_2_Array │ │ │ │ └── Notes.ino │ │ │ ├── Font_Demo_4_Array │ │ │ │ └── Notes.ino │ │ │ └── Font_Demo_3_Array │ │ │ │ └── Notes.ino │ │ └── SD_Card │ │ │ └── ESP32_Smooth_Font_SD │ │ │ └── data │ │ │ └── Final-Frontier-28.vlw │ ├── 320 x 240 │ │ ├── TFT_Ellipse │ │ │ └── TFT_Ellipse.ino │ │ ├── TFT_Starfield │ │ │ └── TFT_Starfield.ino │ │ ├── TFT_Mandlebrot │ │ │ └── TFT_Mandlebrot.ino │ │ ├── TFT_Pie_Chart │ │ │ └── TFT_Pie_Chart.ino │ │ ├── TFT_Spiro │ │ │ └── TFT_Spiro.ino │ │ ├── TFT_Float_Test │ │ │ └── TFT_Float_Test.ino │ │ └── TFT_Print_Test │ │ │ └── TFT_Print_Test.ino │ ├── 480 x 320 │ │ ├── TFT_Ellipse │ │ │ └── TFT_Ellipse.ino │ │ ├── Touch_Controller_Demo │ │ │ └── Touch_Controller_Demo.ino │ │ └── TFT_Print_Test │ │ │ └── TFT_Print_Test.ino │ ├── 160 x 128 │ │ ├── TFT_Ellipse │ │ │ └── TFT_Ellipse.ino │ │ └── TFT_Print_Test │ │ │ └── TFT_Print_Test.ino │ ├── Test and diagnostics │ │ └── Test_Touch_Controller │ │ │ └── Test_Touch_Controller.ino │ └── FactoryTest │ │ └── Button2.h ├── README.txt ├── library.properties ├── .gitattributes ├── TFT_Drivers │ ├── ST7789_2_Init.h │ ├── EPD_Defines.h │ ├── S6D02A1_Rotation.h │ ├── HX8357D_Rotation.h │ ├── ILI9481_Rotation.h │ ├── ILI9488_Rotation.h │ ├── R61581_Rotation.h │ ├── ILI9481_Defines.h │ ├── ILI9488_Defines.h │ ├── R61581_Defines.h │ ├── RM68140_Defines.h │ ├── ILI9163_Rotation.h │ ├── RM68140_Rotation.h │ ├── ST7789_2_Rotation.h │ ├── ILI9486_Rotation.h │ ├── SSD1963_Defines.h │ ├── SSD1963_Rotation.h │ ├── ST7796_Rotation.h │ ├── ILI9163_Init.h │ ├── ILI9481_Init.h │ ├── RM68140_Init.h │ ├── ILI9486_Init.h │ ├── R61581_Init.h │ ├── ST7789_Rotation.h │ ├── S6D02A1_Defines.h │ ├── HX8357D_Defines.h │ ├── ILI9163_Defines.h │ ├── ILI9341_Rotation.h │ ├── ILI9486_Defines.h │ ├── ILI9488_Init.h │ ├── S6D02A1_Init.h │ └── ST7796_Defines.h ├── library.json ├── User_Setups │ ├── Setup22_TTGO_T4_v1.3.h │ ├── Setup22_TTGO_T4.h │ ├── Setup25_TTGO_T_Display.h │ ├── Setup23_TTGO_TM.h │ ├── Setup12_M5Stack.h │ ├── Setup45_TTGO_T_Watch.h │ ├── Setup44_TTGO_CameraPlus.h │ ├── Setup11_RPi_touch_ILI9486.h │ ├── Setup36_RPi_touch_ILI9341.h │ ├── Setup5_RPi_ILI9486.h │ ├── Setup1_ILI9341.h │ ├── Setup15_HX8357D.h │ ├── Setup20_ILI9488.h │ ├── Setup21_ILI9488.h │ ├── Setup6_RPi_Wr_ILI9486.h │ ├── Setup16_ILI9488_Parallel.h │ ├── Setup10_RPi_touch_ILI9486.h │ ├── Setup13_ILI9481_Parallel.h │ ├── Setup19_RM68140_Parallel.h │ ├── Setup14_ILI9341_Parallel.h │ ├── Setup4_S6D02A1.h │ ├── Setup3_ILI9163.h │ ├── Setup8_ILI9163_128x128.h │ ├── Setup2_ST7735.h │ ├── Setup7_ST7735_128x128.h │ ├── Setup26_TTGO_T_Wristband.h │ ├── User_Custom_Fonts.h │ ├── Setup43_ST7735.h │ ├── Setup9_ST7735_Overlap.h │ ├── Setup18_ST7789.h │ ├── Setup30_ILI9341_Parallel_STM32.h │ ├── Setup31_ST7796_Parallel_STM32.h │ ├── Setup34_ILI9481_Parallel_STM32.h │ ├── Setup24_ST7789.h │ ├── Setup17_ePaper.h │ ├── Setup135_ST7789.h │ └── Setup35_ILI9341_STM32_Port_Bus.h ├── .gitignore └── Extensions │ ├── Button.h │ ├── Touch.h │ └── Smooth_font.h ├── schematic └── ESP32-TFT(6-26).pdf ├── kicad └── TTGO_T_Display │ └── README.MD ├── LICENSE └── README.MD /.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | .vscode 3 | other -------------------------------------------------------------------------------- /image/SD.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/image/SD.jpg -------------------------------------------------------------------------------- /image/image4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/image/image4.jpg -------------------------------------------------------------------------------- /image/pinmap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/image/pinmap.jpg -------------------------------------------------------------------------------- /firmware/esp32-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/firmware/esp32-1.png -------------------------------------------------------------------------------- /firmware/esp32-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/firmware/esp32-2.png -------------------------------------------------------------------------------- /firmware/firmware.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/firmware/firmware.bin -------------------------------------------------------------------------------- /3d_file/README.md: -------------------------------------------------------------------------------- 1 | ![image](https://github.com/Xinyuan-LilyGO/TTGO-T-Display/blob/master/image/image4.jpg) 2 | -------------------------------------------------------------------------------- /3d_file/T-Display.step: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/3d_file/T-Display.step -------------------------------------------------------------------------------- /3d_file/prt0003_23.stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/3d_file/prt0003_23.stl -------------------------------------------------------------------------------- /TFT_eSPI/Fonts/TrueType/Not_yet_supported.txt: -------------------------------------------------------------------------------- 1 | TO DO: Add support for converted True Type fonts in an RLE format. -------------------------------------------------------------------------------- /3d_file/prt0005_14(2).stl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/3d_file/prt0005_14(2).stl -------------------------------------------------------------------------------- /schematic/ESP32-TFT(6-26).pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/schematic/ESP32-TFT(6-26).pdf -------------------------------------------------------------------------------- /TFT_eSPI/Tools/Images/star.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/Tools/Images/star.bmp -------------------------------------------------------------------------------- /TFT_eSPI/Tools/RPi_TFT_mod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/Tools/RPi_TFT_mod.png -------------------------------------------------------------------------------- /TFT_eSPI/Tools/RPi_TFT_Connections.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/Tools/RPi_TFT_Connections.png -------------------------------------------------------------------------------- /TFT_eSPI/examples/Sprite/Animated_dial/data/dial.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Sprite/Animated_dial/data/dial.jpg -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/TFT_SPIFFS_BMP/data/parrot.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Generic/TFT_SPIFFS_BMP/data/parrot.bmp -------------------------------------------------------------------------------- /TFT_eSPI/examples/ePaper/Floyd_Steinberg/data/Tiger.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/ePaper/Floyd_Steinberg/data/Tiger.bmp -------------------------------------------------------------------------------- /TFT_eSPI/Tools/ESP32 UNO board mod/ESP32 UNO board mod.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/Tools/ESP32 UNO board mod/ESP32 UNO board mod.jpg -------------------------------------------------------------------------------- /TFT_eSPI/examples/Sprite/Rotated_Sprite_3/data/EagleEye.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Sprite/Rotated_Sprite_3/data/EagleEye.jpg -------------------------------------------------------------------------------- /TFT_eSPI/examples/ePaper/Floyd_Steinberg/data/TestCard.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/ePaper/Floyd_Steinberg/data/TestCard.bmp -------------------------------------------------------------------------------- /TFT_eSPI/Tools/ESP32 UNO board mod/ESP32 UNO board pinout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/Tools/ESP32 UNO board mod/ESP32 UNO board pinout.jpg -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/ESP32_SDcard_jpeg/Data/Baboon40.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Generic/ESP32_SDcard_jpeg/Data/Baboon40.jpg -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/ESP32_SDcard_jpeg/Data/EagleEye.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Generic/ESP32_SDcard_jpeg/Data/EagleEye.jpg -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/ESP32_SDcard_jpeg/Data/Mouse480.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Generic/ESP32_SDcard_jpeg/Data/Mouse480.jpg -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/ESP32_SDcard_jpeg/Data/lena20k.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Generic/ESP32_SDcard_jpeg/Data/lena20k.jpg -------------------------------------------------------------------------------- /TFT_eSPI/examples/Sprite/Rotated_Sprite_3/data/Eye_80x64.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Sprite/Rotated_Sprite_3/data/Eye_80x64.jpg -------------------------------------------------------------------------------- /TFT_eSPI/Tools/Create_Smooth_Font/Create_font/data/Final-Frontier.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/Tools/Create_Smooth_Font/Create_font/data/Final-Frontier.ttf -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_1/data/NotoSansBold15.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_1/data/NotoSansBold15.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_1/data/NotoSansBold36.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_1/data/NotoSansBold36.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_2/data/NotoSansBold15.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_2/data/NotoSansBold15.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_2/data/NotoSansBold36.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_2/data/NotoSansBold36.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_3/data/NotoSansBold15.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_3/data/NotoSansBold15.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_3/data/NotoSansBold36.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_3/data/NotoSansBold36.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_4/data/NotoSansBold15.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_4/data/NotoSansBold15.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_4/data/NotoSansBold36.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_4/data/NotoSansBold36.vlw -------------------------------------------------------------------------------- /TFT_eSPI/Tools/Create_Smooth_Font/Create_font/FontFiles/Final-Frontier28.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/Tools/Create_Smooth_Font/Create_font/FontFiles/Final-Frontier28.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_3/data/NotoSansMonoSCB20.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_3/data/NotoSansMonoSCB20.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Unicode_test/data/Unicode-Test-72.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Unicode_test/data/Unicode-Test-72.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Sprite/Sprite_image_4bit/sample_images.h: -------------------------------------------------------------------------------- 1 | #include // Include the graphics library (this includes the sprite functions) 2 | 3 | extern const uint8_t stars[12800] PROGMEM ; -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Unicode_test/data/Final-Frontier-28.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Unicode_test/data/Final-Frontier-28.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Unicode_test/data/Latin-Hiragana-24.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Unicode_test/data/Latin-Hiragana-24.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/FLASH_Array/Unicode_test/data/Unicode-Test-72.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/FLASH_Array/Unicode_test/data/Unicode-Test-72.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/FLASH_Array/Unicode_test/data/Final-Frontier-28.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/FLASH_Array/Unicode_test/data/Final-Frontier-28.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/FLASH_Array/Unicode_test/data/Latin-Hiragana-24.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/FLASH_Array/Unicode_test/data/Latin-Hiragana-24.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Print_Smooth_Font/data/Final-Frontier-28.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Print_Smooth_Font/data/Final-Frontier-28.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Smooth_font_gradient/data/NotoSansBold15.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Smooth_font_gradient/data/NotoSansBold15.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Smooth_font_gradient/data/NotoSansBold36.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Smooth_font_gradient/data/NotoSansBold36.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SD_Card/ESP32_Smooth_Font_SD/data/Final-Frontier-28.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SD_Card/ESP32_Smooth_Font_SD/data/Final-Frontier-28.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Smooth_font_reading_TFT/data/NotoSansBold15.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Smooth_font_reading_TFT/data/NotoSansBold15.vlw -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Smooth_font_reading_TFT/data/NotoSansBold36.vlw: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Xinyuan-LilyGO/TTGO-T-Display/HEAD/TFT_eSPI/examples/Smooth Fonts/SPIFFS/Smooth_font_reading_TFT/data/NotoSansBold36.vlw -------------------------------------------------------------------------------- /TFT_eSPI/Fonts/Font16.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f16 96 4 | #define chr_hgt_f16 16 5 | #define baseline_f16 13 6 | #define data_size_f16 8 7 | #define firstchr_f16 32 8 | 9 | extern const unsigned char widtbl_f16[96]; 10 | extern const unsigned char* const chrtbl_f16[96]; 11 | -------------------------------------------------------------------------------- /TFT_eSPI/Fonts/Font32rle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f32 96 4 | #define chr_hgt_f32 26 5 | #define baseline_f32 19 6 | #define data_size_f32 8 7 | #define firstchr_f32 32 8 | 9 | extern const unsigned char widtbl_f32[96]; 10 | extern const unsigned char* const chrtbl_f32[96]; 11 | -------------------------------------------------------------------------------- /TFT_eSPI/Fonts/Font64rle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f64 96 4 | #define chr_hgt_f64 48 5 | #define baseline_f64 36 6 | #define data_size_f64 8 7 | #define firstchr_f64 32 8 | 9 | extern const unsigned char widtbl_f64[96]; 10 | extern const unsigned char* const chrtbl_f64[96]; 11 | -------------------------------------------------------------------------------- /TFT_eSPI/Fonts/Font72rle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f72 96 4 | #define chr_hgt_f72 75 5 | #define baseline_f72 73 6 | #define data_size_f72 8 7 | #define firstchr_f72 32 8 | 9 | extern const unsigned char widtbl_f72[96]; 10 | extern const unsigned char* const chrtbl_f72[96]; 11 | -------------------------------------------------------------------------------- /TFT_eSPI/Fonts/Font7srle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f7s 96 4 | #define chr_hgt_f7s 48 5 | #define baseline_f7s 47 6 | #define data_size_f7s 8 7 | #define firstchr_f7s 32 8 | 9 | extern const unsigned char widtbl_f7s[96]; 10 | extern const unsigned char* const chrtbl_f7s[96]; 11 | -------------------------------------------------------------------------------- /TFT_eSPI/Fonts/Font72x53rle.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define nr_chrs_f72 96 4 | #define chr_hgt_f72 75 5 | #define baseline_f72 73 6 | #define data_size_f72 8 7 | #define firstchr_f72 32 8 | 9 | extern const unsigned char widtbl_f72[96]; 10 | extern const unsigned char* const chrtbl_f72[96]; 11 | -------------------------------------------------------------------------------- /kicad/TTGO_T_Display/README.MD: -------------------------------------------------------------------------------- 1 | # This is a KiCad library for TTGO_T_Display. 2 | You need add "TTGO_T_Display.kicad_sym" as symbol library with name TTGO_T_Display to KiCad. 3 | This file is in folder "symbols". 4 | Also you need to add "TTGO_T_Display.pretty" folder as footprint library with name TTGO_T_Display to KiCad. 5 | This folder is in folder footprints. 6 | 7 | Library created by WolodiaM 8 | -------------------------------------------------------------------------------- /TFT_eSPI/README.txt: -------------------------------------------------------------------------------- 1 | This is a standalone library that contains both graphics functions 2 | and the TFT chip driver library. It supports the ESP8266, ESP32 and 3 | STM32 processors with performance optimised code. Other Arduino IDE 4 | compatible boards are also supported but the library then uses 5 | generic functions which will be slower. The library uses 32 bit 6 | variables extensively so this will affect performance on 8 and 16 7 | bit processors. 8 | -------------------------------------------------------------------------------- /TFT_eSPI/library.properties: -------------------------------------------------------------------------------- 1 | name=TFT_eSPI 2 | version=2.2.20 3 | author=Bodmer 4 | maintainer=Bodmer 5 | sentence=TFT graphics library for Arduino processors with performance optimisation for STM32, ESP8266 and ESP32 6 | paragraph=Supports TFT displays using drivers (ILI9341 etc) that operate with hardware SPI or 8 bit parallel. 7 | category=Display 8 | url=https://github.com/Bodmer/TFT_eSPI 9 | architectures=* 10 | includes=TFT_eSPI.h 11 | 12 | -------------------------------------------------------------------------------- /TFT_eSPI/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /firmware/README.MD: -------------------------------------------------------------------------------- 1 | 2 | When you suspect that there is a problem with the hardware, you can brush in our test firmware 3 | 4 | 5 | 1. Download [Flash_download_tool](https://www.espressif.com.cn/sites/default/files/tools/flash_download_tool_3.9.3_0.zip) 6 | 2. Select esp32,UART 7 | ![](esp32-1.png) 8 | 3. Select according to the following figure, finally select START, press RST after writing, or power on again, and then observe the log output from the serial port 9 | ![](esp32-2.png) 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ST7789_2_Init.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that initialises the ST7789 driver 3 | 4 | // Configure ST7789 display 5 | 6 | { 7 | static const uint8_t PROGMEM 8 | st7789[] = { 9 | 8, 10 | TFT_SLPOUT, TFT_INIT_DELAY, 255, 11 | TFT_COLMOD, 1+TFT_INIT_DELAY, 0x55, 10, 12 | TFT_MADCTL, 1, 0x00, 13 | TFT_CASET, 4, 0x00, 0x00, 0x00, 0xF0, 14 | TFT_PASET, 4, 0x00, 0x00, 0x00, 0xF0, 15 | TFT_INVON, TFT_INIT_DELAY, 10, 16 | TFT_NORON, TFT_INIT_DELAY, 10, 17 | TFT_DISPON, TFT_INIT_DELAY, 255 18 | }; 19 | 20 | commandList(st7789); 21 | } 22 | // End of ST7789 display configuration -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/EPD_Defines.h: -------------------------------------------------------------------------------- 1 | // Null set for ePaper 2 | #define TFT_WIDTH 1000 3 | #define TFT_HEIGHT 1000 4 | 5 | #define TFT_INIT_DELAY 0 6 | 7 | #define TFT_NOP 0x00 8 | #define TFT_SWRST 0x00 9 | 10 | #define TFT_CASET 0x00 11 | #define TFT_PASET 0x00 12 | #define TFT_RAMWR 0x00 13 | 14 | #define TFT_RAMRD 0x00 15 | #define TFT_IDXRD 0x00 16 | 17 | #define TFT_MADCTL 0x00 18 | #define TFT_MAD_MY 0x00 19 | #define TFT_MAD_MX 0x00 20 | #define TFT_MAD_MV 0x00 21 | #define TFT_MAD_ML 0x00 22 | #define TFT_MAD_BGR 0x00 23 | #define TFT_MAD_MH 0x00 24 | #define TFT_MAD_RGB 0x00 25 | 26 | #define TFT_INVOFF 0x00 27 | #define TFT_INVON 0x00 28 | -------------------------------------------------------------------------------- /TFT_eSPI/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TFT_eSPI", 3 | "version": "2.2.20", 4 | "keywords": "Arduino, tft, ePaper, display, STM32, ESP8266, NodeMCU, ESP32, M5Stack, ILI9341, ST7735, ILI9163, S6D02A1, ILI9486, ST7789, RM68140", 5 | "description": "A TFT and ePaper SPI graphics library with optimisation for ESP8266, ESP32 and STM32", 6 | "repository": 7 | { 8 | "type": "git", 9 | "url": "https://github.com/Bodmer/TFT_eSPI" 10 | }, 11 | "authors": 12 | [ 13 | { 14 | "name": "Bodmer", 15 | "email": "bodmer@anola.net", 16 | "maintainer": true 17 | } 18 | ], 19 | "frameworks": "arduino", 20 | "platforms": "espressif8266, espressif32, ststm32" 21 | } 22 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup22_TTGO_T4_v1.3.h: -------------------------------------------------------------------------------- 1 | // Setup for the TTGO T4 v1.3 ESP32 board with 2.2" ILI9341 display 2 | 3 | #define ILI9341_DRIVER 4 | 5 | #define TFT_BACKLIGHT_ON HIGH 6 | #define TFT_BL 4 7 | 8 | #define TFT_MISO 12 9 | #define TFT_MOSI 23 10 | #define TFT_SCLK 18 11 | 12 | #define TFT_CS 27 13 | #define TFT_DC 32 14 | #define TFT_RST 5 15 | 16 | #define LOAD_GLCD 17 | #define LOAD_FONT2 18 | #define LOAD_FONT4 19 | #define LOAD_FONT6 20 | #define LOAD_FONT7 21 | #define LOAD_FONT8 22 | #define LOAD_GFXFF 23 | 24 | #define SMOOTH_FONT 25 | 26 | //#define SPI_FREQUENCY 27000000 27 | #define SPI_FREQUENCY 40000000 // Maximum for ILI9341 28 | 29 | #define USE_HSPI_PORT 30 | 31 | #define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V 32 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup22_TTGO_T4.h: -------------------------------------------------------------------------------- 1 | // Setup for the TTGO T4 ("Bitcoin Tracker") ESP32 board with 2.2" ILI9341 display 2 | 3 | // See SetupX_Template.h for all options available 4 | 5 | #define ILI9341_DRIVER 6 | 7 | #define TFT_MISO 12 8 | #define TFT_MOSI 23 9 | #define TFT_SCLK 18 10 | 11 | #define TFT_CS 27 12 | #define TFT_DC 26 13 | #define TFT_RST 5 14 | 15 | #define LOAD_GLCD 16 | #define LOAD_FONT2 17 | #define LOAD_FONT4 18 | #define LOAD_FONT6 19 | #define LOAD_FONT7 20 | #define LOAD_FONT8 21 | #define LOAD_GFXFF 22 | 23 | #define SMOOTH_FONT 24 | 25 | //#define SPI_FREQUENCY 27000000 26 | #define SPI_FREQUENCY 40000000 // Maximum for ILI9341 27 | 28 | #define USE_HSPI_PORT 29 | 30 | #define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V 31 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/S6D02A1_Rotation.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that rotates the S6D02A1 driver coordinate frame 3 | 4 | rotation = m % 4; 5 | 6 | writecommand(TFT_MADCTL); 7 | switch (rotation) { 8 | case 0: 9 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); 10 | _width = _init_width; 11 | _height = _init_height; 12 | break; 13 | case 1: 14 | writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR); 15 | _width = _init_height; 16 | _height = _init_width; 17 | break; 18 | case 2: 19 | writedata(TFT_MAD_BGR); 20 | _width = _init_width; 21 | _height = _init_height; 22 | break; 23 | case 3: 24 | writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR); 25 | _width = _init_height; 26 | _height = _init_width; 27 | break; 28 | } 29 | -------------------------------------------------------------------------------- /TFT_eSPI/.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/HX8357D_Rotation.h: -------------------------------------------------------------------------------- 1 | // This is the command sequence that rotates the ILI9481 driver coordinate frame 2 | 3 | writecommand(TFT_MADCTL); 4 | rotation = m % 4; 5 | switch (rotation) { 6 | case 0: // Portrait 7 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_RGB); 8 | _width = TFT_WIDTH; 9 | _height = TFT_HEIGHT; 10 | break; 11 | case 1: // Landscape (Portrait + 90) 12 | writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_RGB); 13 | _width = TFT_HEIGHT; 14 | _height = TFT_WIDTH; 15 | break; 16 | case 2: // Inverter portrait 17 | writedata(TFT_MAD_RGB); 18 | _width = TFT_WIDTH; 19 | _height = TFT_HEIGHT; 20 | break; 21 | case 3: // Inverted landscape 22 | writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_RGB); 23 | _width = TFT_HEIGHT; 24 | _height = TFT_WIDTH; 25 | break; 26 | } 27 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9481_Rotation.h: -------------------------------------------------------------------------------- 1 | // This is the command sequence that rotates the ILI9481 driver coordinate frame 2 | 3 | writecommand(TFT_MADCTL); 4 | rotation = m % 4; 5 | switch (rotation) { 6 | case 0: // Portrait 7 | writedata(TFT_MAD_BGR | TFT_MAD_SS); 8 | _width = TFT_WIDTH; 9 | _height = TFT_HEIGHT; 10 | break; 11 | case 1: // Landscape (Portrait + 90) 12 | writedata(TFT_MAD_MV | TFT_MAD_BGR); 13 | _width = TFT_HEIGHT; 14 | _height = TFT_WIDTH; 15 | break; 16 | case 2: // Inverter portrait 17 | writedata(TFT_MAD_BGR | TFT_MAD_GS); 18 | _width = TFT_WIDTH; 19 | _height = TFT_HEIGHT; 20 | break; 21 | case 3: // Inverted landscape 22 | writedata(TFT_MAD_MV | TFT_MAD_BGR | TFT_MAD_SS | TFT_MAD_GS); 23 | _width = TFT_HEIGHT; 24 | _height = TFT_WIDTH; 25 | break; 26 | } 27 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9488_Rotation.h: -------------------------------------------------------------------------------- 1 | // This is the command sequence that rotates the ILI9488 driver coordinate frame 2 | 3 | writecommand(TFT_MADCTL); 4 | rotation = m % 4; 5 | switch (rotation) { 6 | case 0: // Portrait 7 | writedata(TFT_MAD_MX | TFT_MAD_BGR); 8 | _width = TFT_WIDTH; 9 | _height = TFT_HEIGHT; 10 | break; 11 | case 1: // Landscape (Portrait + 90) 12 | writedata(TFT_MAD_MV | TFT_MAD_BGR); 13 | _width = TFT_HEIGHT; 14 | _height = TFT_WIDTH; 15 | break; 16 | case 2: // Inverter portrait 17 | writedata(TFT_MAD_MY | TFT_MAD_BGR); 18 | _width = TFT_WIDTH; 19 | _height = TFT_HEIGHT; 20 | break; 21 | case 3: // Inverted landscape 22 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_BGR); 23 | _width = TFT_HEIGHT; 24 | _height = TFT_WIDTH; 25 | break; 26 | } 27 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/R61581_Rotation.h: -------------------------------------------------------------------------------- 1 | // This is the command sequence that rotates the R61581 driver coordinate frame 2 | 3 | writecommand(TFT_MADCTL); 4 | rotation = m % 4; 5 | switch (rotation) { 6 | case 0: // Portrait 7 | writedata(TFT_MAD_BGR | TFT_MAD_MX); 8 | _width = TFT_WIDTH; 9 | _height = TFT_HEIGHT; 10 | break; 11 | case 1: // Landscape (Portrait + 90) 12 | writedata(TFT_MAD_MV | TFT_MAD_BGR); 13 | _width = TFT_HEIGHT; 14 | _height = TFT_WIDTH; 15 | break; 16 | case 2: // Inverter portrait 17 | writedata(TFT_MAD_BGR | TFT_MAD_GS); 18 | _width = TFT_WIDTH; 19 | _height = TFT_HEIGHT; 20 | break; 21 | case 3: // Inverted landscape 22 | writedata(TFT_MAD_MV | TFT_MAD_BGR | TFT_MAD_MX | TFT_MAD_GS); 23 | _width = TFT_HEIGHT; 24 | _height = TFT_WIDTH; 25 | break; 26 | } 27 | -------------------------------------------------------------------------------- /TFT_eSPI/Tools/PlatformIO/Configuring options.txt: -------------------------------------------------------------------------------- 1 | PlatformIO User notes: 2 | 3 | It is possible to load settings from the calling program rather than modifying 4 | the library for each project by modifying the "platformio.ini" file. 5 | 6 | The User_Setup_Select.h file will not load the user setting header files if 7 | USER_SETUP_LOADED is defined. 8 | 9 | Instead of using #define, use the -D prefix, for example: 10 | 11 | [env:esp32dev] 12 | platform = https://github.com/platformio/platform-espressif32.git#feature/stage 13 | board = esp32dev 14 | framework = arduino 15 | upload_port = ESP32-Test-2481CE9C.local 16 | 17 | build_flags = 18 | -Os 19 | -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG 20 | -DUSER_SETUP_LOADED=1 21 | -DILI9163_DRIVER=1 22 | -DTFT_WIDTH=128 23 | -DTFT_HEIGHT=160 24 | -DTFT_MISO=19 25 | -DTFT_MOSI=23 26 | -DTFT_SCLK=18 27 | -DTFT_CS=5 28 | -DTFT_DC=19 29 | -DTFT_RST=-1 30 | -DLOAD_GLCD=1 31 | -DSPI_FREQUENCY=27000000 32 | 33 | lib_extra_dirs = B:\Projects\ESP32\ESP32Lib 34 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup25_TTGO_T_Display.h: -------------------------------------------------------------------------------- 1 | // Setup for the TTGO T4 ("Bitcoin Tracker") ESP32 board with 2.2" ILI9341 display 2 | 3 | // See SetupX_Template.h for all options available 4 | 5 | #define ST7789_DRIVER 6 | 7 | #define TFT_WIDTH 135 8 | #define TFT_HEIGHT 240 9 | 10 | #define CGRAM_OFFSET // Library will add offsets required 11 | 12 | //#define TFT_MISO -1 13 | 14 | #define TFT_MOSI 19 15 | #define TFT_SCLK 18 16 | #define TFT_CS 5 17 | #define TFT_DC 16 18 | #define TFT_RST 23 19 | 20 | #define TFT_BL 4 // Display backlight control pin 21 | 22 | #define TFT_BACKLIGHT_ON HIGH // HIGH or LOW are options 23 | 24 | #define LOAD_GLCD 25 | #define LOAD_FONT2 26 | #define LOAD_FONT4 27 | #define LOAD_FONT6 28 | #define LOAD_FONT7 29 | #define LOAD_FONT8 30 | #define LOAD_GFXFF 31 | 32 | #define SMOOTH_FONT 33 | 34 | //#define SPI_FREQUENCY 27000000 35 | #define SPI_FREQUENCY 40000000 // Maximum for ILI9341 36 | 37 | 38 | #define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V 39 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/320 x 240/TFT_Ellipse/TFT_Ellipse.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Ellipse drawing example 3 | 4 | This sketch does not use any fonts. 5 | */ 6 | 7 | #include // Hardware-specific library 8 | #include 9 | 10 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 11 | 12 | void setup(void) { 13 | tft.init(); 14 | 15 | tft.setRotation(1); 16 | 17 | } 18 | 19 | void loop() { 20 | 21 | tft.fillScreen(TFT_BLACK); 22 | 23 | // Draw some random ellipses 24 | for (int i = 0; i < 40; i++) 25 | { 26 | int rx = random(60); 27 | int ry = random(60); 28 | int x = rx + random(320 - rx - rx); 29 | int y = ry + random(240 - ry - ry); 30 | tft.fillEllipse(x, y, rx, ry, random(0xFFFF)); 31 | } 32 | 33 | delay(2000); 34 | tft.fillScreen(TFT_BLACK); 35 | 36 | for (int i = 0; i < 40; i++) 37 | { 38 | int rx = random(60); 39 | int ry = random(60); 40 | int x = rx + random(320 - rx - rx); 41 | int y = ry + random(240 - ry - ry); 42 | tft.drawEllipse(x, y, rx, ry, random(0xFFFF)); 43 | } 44 | 45 | delay(2000); 46 | } 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/480 x 320/TFT_Ellipse/TFT_Ellipse.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Ellipse drawing example 3 | 4 | This sketch does not use any fonts. 5 | */ 6 | 7 | #include 8 | 9 | #include // Hardware-specific library 10 | 11 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 12 | 13 | 14 | void setup(void) { 15 | tft.init(); 16 | 17 | tft.setRotation(1); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | tft.fillScreen(TFT_BLACK); 24 | 25 | // Draw some random circles 26 | for (int i = 0; i < 40; i++) 27 | { 28 | int rx = random(60); 29 | int ry = random(60); 30 | int x = rx + random(480 - rx - rx); 31 | int y = ry + random(320 - ry - ry); 32 | tft.fillEllipse(x, y, rx, ry, random(0xFFFF)); 33 | } 34 | 35 | delay(2000); 36 | tft.fillScreen(TFT_BLACK); 37 | 38 | for (int i = 0; i < 40; i++) 39 | { 40 | int rx = random(60); 41 | int ry = random(60); 42 | int x = rx + random(480 - rx - rx); 43 | int y = ry + random(320 - ry - ry); 44 | tft.drawEllipse(x, y, rx, ry, random(0xFFFF)); 45 | } 46 | 47 | delay(2000); 48 | } 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup23_TTGO_TM.h: -------------------------------------------------------------------------------- 1 | // Setup for the TTGO TM (Music) ESP32 board with 2.4" ST7789V display 2 | 3 | // See SetupX_Template.h for all options available 4 | 5 | #define ST7789_DRIVER 6 | 7 | #define TFT_SDA_READ // Read from display, it only provides an SDA pin 8 | 9 | #define TFT_MISO 19 // Must be defined even though it is not used 10 | #define TFT_MOSI 23 // Connected to display SDA line 11 | #define TFT_SCLK 18 12 | 13 | #define TFT_CS 05 14 | #define TFT_DC 16 15 | #define TFT_RST 17 16 | 17 | #define TFT_WIDTH 240 18 | #define TFT_HEIGHT 320 19 | 20 | //#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue 21 | #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red 22 | 23 | #define LOAD_GLCD 24 | #define LOAD_FONT2 25 | #define LOAD_FONT4 26 | #define LOAD_FONT6 27 | #define LOAD_FONT7 28 | #define LOAD_FONT8 29 | #define LOAD_GFXFF 30 | 31 | #define SMOOTH_FONT 32 | 33 | #define SPI_FREQUENCY 40000000 // This display also seems to work reliably at 80MHz 34 | #define SPI_FREQUENCY 80000000 35 | 36 | #define SPI_READ_FREQUENCY 6000000 // 6 MHz is the maximum SPI read speed for the ST7789V 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Xinyuan-LilyGO 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/160 x 128/TFT_Ellipse/TFT_Ellipse.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Ellipse drawing example 3 | 4 | This sketch does not use any fonts. 5 | */ 6 | 7 | #include // Hardware-specific library 8 | #include 9 | 10 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 11 | 12 | void setup(void) { 13 | tft.init(); 14 | 15 | tft.setRotation(1); 16 | 17 | } 18 | 19 | void loop() { 20 | 21 | tft.fillScreen(TFT_BLACK); 22 | 23 | // Draw some random filled elipses 24 | for (int i = 0; i < 20; i++) 25 | { 26 | int rx = random(40); 27 | int ry = random(40); 28 | int x = rx + random(160 - rx - rx); 29 | int y = ry + random(128 - ry - ry); 30 | tft.fillEllipse(x, y, rx, ry, random(0xFFFF)); 31 | } 32 | 33 | delay(2000); 34 | tft.fillScreen(TFT_BLACK); 35 | 36 | // Draw some random outline elipses 37 | for (int i = 0; i < 20; i++) 38 | { 39 | int rx = random(40); 40 | int ry = random(40); 41 | int x = rx + random(160 - rx - rx); 42 | int y = ry + random(128 - ry - ry); 43 | tft.drawEllipse(x, y, rx, ry, random(0xFFFF)); 44 | } 45 | 46 | delay(2000); 47 | } 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9481_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #define TFT_WIDTH 320 4 | #define TFT_HEIGHT 480 5 | 6 | 7 | // Delay between some initialisation commands 8 | #define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked 9 | 10 | 11 | // Generic commands used by TFT_eSPI.cpp 12 | #define TFT_NOP 0x00 13 | #define TFT_SWRST 0x01 14 | 15 | #define TFT_SLPIN 0x10 16 | #define TFT_SLPOUT 0x11 17 | 18 | #define TFT_INVOFF 0x20 19 | #define TFT_INVON 0x21 20 | 21 | #define TFT_DISPOFF 0x28 22 | #define TFT_DISPON 0x29 23 | 24 | #define TFT_CASET 0x2A 25 | #define TFT_PASET 0x2B 26 | #define TFT_RAMWR 0x2C 27 | 28 | #define TFT_RAMRD 0x2E 29 | 30 | #define TFT_MADCTL 0x36 31 | 32 | #define TFT_MAD_MY 0x80 33 | #define TFT_MAD_MX 0x40 34 | #define TFT_MAD_MV 0x20 35 | #define TFT_MAD_ML 0x10 36 | #define TFT_MAD_RGB 0x00 37 | #define TFT_MAD_BGR 0x08 38 | #define TFT_MAD_MH 0x04 39 | #define TFT_MAD_SS 0x02 40 | #define TFT_MAD_GS 0x01 41 | 42 | #define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read 43 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9488_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #define TFT_WIDTH 320 4 | #define TFT_HEIGHT 480 5 | 6 | 7 | // Delay between some initialisation commands 8 | #define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked 9 | 10 | 11 | // Generic commands used by TFT_eSPI.cpp 12 | #define TFT_NOP 0x00 13 | #define TFT_SWRST 0x01 14 | 15 | #define TFT_SLPIN 0x10 16 | #define TFT_SLPOUT 0x11 17 | 18 | #define TFT_INVOFF 0x20 19 | #define TFT_INVON 0x21 20 | 21 | #define TFT_DISPOFF 0x28 22 | #define TFT_DISPON 0x29 23 | 24 | #define TFT_CASET 0x2A 25 | #define TFT_PASET 0x2B 26 | #define TFT_RAMWR 0x2C 27 | 28 | #define TFT_RAMRD 0x2E 29 | 30 | #define TFT_MADCTL 0x36 31 | 32 | #define TFT_MAD_MY 0x80 33 | #define TFT_MAD_MX 0x40 34 | #define TFT_MAD_MV 0x20 35 | #define TFT_MAD_ML 0x10 36 | #define TFT_MAD_RGB 0x00 37 | #define TFT_MAD_BGR 0x08 38 | #define TFT_MAD_MH 0x04 39 | #define TFT_MAD_SS 0x02 40 | #define TFT_MAD_GS 0x01 41 | 42 | #define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read 43 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/R61581_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #define TFT_WIDTH 320 4 | #define TFT_HEIGHT 480 5 | 6 | 7 | // Delay between some initialisation commands 8 | #define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked 9 | 10 | 11 | // Generic commands used by TFT_eSPI.cpp 12 | #define TFT_NOP 0x00 13 | #define TFT_SWRST 0x01 14 | 15 | #define TFT_SLPIN 0x10 16 | #define TFT_SLPOUT 0x11 17 | 18 | #define TFT_INVOFF 0x20 19 | #define TFT_INVON 0x21 20 | 21 | #define TFT_DISPOFF 0x28 22 | #define TFT_DISPON 0x29 23 | 24 | #define TFT_CASET 0x2A 25 | #define TFT_PASET 0x2B 26 | #define TFT_RAMWR 0x2C 27 | 28 | #define TFT_RAMRD 0x2E 29 | 30 | #define TFT_MADCTL 0x36 31 | 32 | #define TFT_MAD_MY 0x80 33 | #define TFT_MAD_MX 0x40 34 | #define TFT_MAD_MV 0x20 35 | #define TFT_MAD_ML 0x10 36 | #define TFT_MAD_RGB 0x00 37 | #define TFT_MAD_BGR 0x08 38 | #define TFT_MAD_MH 0x04 39 | #define TFT_MAD_SS 0x02 40 | #define TFT_MAD_GS 0x01 41 | 42 | #define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read 43 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/RM68140_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #define TFT_WIDTH 320 4 | #define TFT_HEIGHT 480 5 | 6 | 7 | // Delay between some initialisation commands 8 | #define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked 9 | 10 | 11 | // Generic commands used by TFT_eSPI.cpp 12 | #define TFT_NOP 0x00 13 | #define TFT_SWRST 0x01 14 | 15 | #define TFT_SLPIN 0x10 16 | #define TFT_SLPOUT 0x11 17 | 18 | #define TFT_INVOFF 0x20 19 | #define TFT_INVON 0x21 20 | 21 | #define TFT_DISPOFF 0x28 22 | #define TFT_DISPON 0x29 23 | 24 | #define TFT_CASET 0x2A 25 | #define TFT_PASET 0x2B 26 | #define TFT_RAMWR 0x2C 27 | 28 | #define TFT_RAMRD 0x2E 29 | 30 | #define TFT_MADCTL 0x36 31 | 32 | #define TFT_MAD_MY 0x80 33 | #define TFT_MAD_MX 0x40 34 | #define TFT_MAD_MV 0x20 35 | #define TFT_MAD_ML 0x10 36 | #define TFT_MAD_RGB 0x00 37 | #define TFT_MAD_BGR 0x08 38 | #define TFT_MAD_MH 0x04 39 | #define TFT_MAD_SS 0x02 40 | #define TFT_MAD_GS 0x01 41 | 42 | #define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read 43 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9163_Rotation.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that rotates the ILI9163 driver coordinate frame 3 | 4 | rotation = m % 4; 5 | 6 | writecommand(TFT_MADCTL); 7 | switch (rotation) { 8 | case 0: 9 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_BGR); 10 | _width = _init_width; 11 | _height = _init_height; 12 | #ifdef CGRAM_OFFSET 13 | colstart = 0; 14 | rowstart = 0; 15 | #endif 16 | break; 17 | case 1: 18 | writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_BGR); 19 | _width = _init_height; 20 | _height = _init_width; 21 | #ifdef CGRAM_OFFSET 22 | colstart = 0; 23 | rowstart = 0; 24 | #endif 25 | break; 26 | case 2: 27 | writedata(TFT_MAD_BGR); 28 | _width = _init_width; 29 | _height = _init_height; 30 | #ifdef CGRAM_OFFSET 31 | colstart = 0; 32 | rowstart = 32; 33 | #endif 34 | break; 35 | case 3: 36 | writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_BGR); 37 | _width = _init_height; 38 | _height = _init_width; 39 | #ifdef CGRAM_OFFSET 40 | colstart = 32; 41 | rowstart = 0; 42 | #endif 43 | break; 44 | } 45 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/RM68140_Rotation.h: -------------------------------------------------------------------------------- 1 | // This is the command sequence that rotates the RM68140 driver coordinate frame 2 | 3 | 4 | writecommand(TFT_MADCTL); 5 | rotation = m % 4; 6 | switch (rotation) { 7 | case 0: // Portrait 8 | writedata(TFT_MAD_BGR); 9 | writecommand(0xB6); 10 | writedata(0); 11 | writedata(0x22); 12 | writedata(0x3B); 13 | _width = TFT_WIDTH; 14 | _height = TFT_HEIGHT; 15 | break; 16 | case 1: // Landscape (Portrait + 90) 17 | writedata(TFT_MAD_MV | TFT_MAD_BGR); 18 | writecommand(0xB6); 19 | writedata(0); 20 | writedata(0x02); 21 | writedata(0x3B); 22 | _width = TFT_HEIGHT; 23 | _height = TFT_WIDTH; 24 | break; 25 | case 2: // Inverter portrait 26 | writedata(TFT_MAD_BGR); 27 | writecommand(0xB6); 28 | writedata(0); 29 | writedata(0x42); 30 | writedata(0x3B); 31 | _width = TFT_WIDTH; 32 | _height = TFT_HEIGHT; 33 | break; 34 | case 3: // Inverted landscape 35 | writedata(TFT_MAD_MV | TFT_MAD_BGR); 36 | writecommand(0xB6); 37 | writedata(0); 38 | writedata(0x62); 39 | writedata(0x3B); 40 | _width = TFT_HEIGHT; 41 | _height = TFT_WIDTH; 42 | break; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_1/Notes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Information notes only: 4 | ====================== 5 | 6 | //These are the text plotting alignment (reference datum point) 7 | 8 | TL_DATUM = Top left (default) 9 | TC_DATUM = Top centre 10 | TR_DATUM = Top right 11 | 12 | ML_DATUM = Middle left 13 | MC_DATUM = Middle centre 14 | MR_DATUM = Middle right 15 | 16 | BL_DATUM = Bottom left 17 | BC_DATUM = Bottom centre 18 | BR_DATUM = Bottom right 19 | 20 | L_BASELINE = Left character baseline (Line the 'A' character would sit on) 21 | C_BASELINE = Centre character baseline 22 | R_BASELINE = Right character baseline 23 | 24 | // Basic colours already defined: 25 | 26 | TFT_BLACK 0x0000 27 | TFT_NAVY 0x000F 28 | TFT_DARKGREEN 0x03E0 29 | TFT_DARKCYAN 0x03EF 30 | TFT_MAROON 0x7800 31 | TFT_PURPLE 0x780F 32 | TFT_OLIVE 0x7BE0 33 | TFT_LIGHTGREY 0xC618 34 | TFT_DARKGREY 0x7BEF 35 | TFT_BLUE 0x001F 36 | TFT_GREEN 0x07E0 37 | TFT_CYAN 0x07FF 38 | TFT_RED 0xF800 39 | TFT_MAGENTA 0xF81F 40 | TFT_YELLOW 0xFFE0 41 | TFT_WHITE 0xFFFF 42 | TFT_ORANGE 0xFDA0 43 | TFT_GREENYELLOW 0xB7E0 44 | TFT_PINK 0xFC9F 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | */ 57 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_2/Notes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Information notes only: 4 | ====================== 5 | 6 | //These are the text plotting alignment (reference datum point) 7 | 8 | TL_DATUM = Top left (default) 9 | TC_DATUM = Top centre 10 | TR_DATUM = Top right 11 | 12 | ML_DATUM = Middle left 13 | MC_DATUM = Middle centre 14 | MR_DATUM = Middle right 15 | 16 | BL_DATUM = Bottom left 17 | BC_DATUM = Bottom centre 18 | BR_DATUM = Bottom right 19 | 20 | L_BASELINE = Left character baseline (Line the 'A' character would sit on) 21 | C_BASELINE = Centre character baseline 22 | R_BASELINE = Right character baseline 23 | 24 | // Basic colours already defined: 25 | 26 | TFT_BLACK 0x0000 27 | TFT_NAVY 0x000F 28 | TFT_DARKGREEN 0x03E0 29 | TFT_DARKCYAN 0x03EF 30 | TFT_MAROON 0x7800 31 | TFT_PURPLE 0x780F 32 | TFT_OLIVE 0x7BE0 33 | TFT_LIGHTGREY 0xC618 34 | TFT_DARKGREY 0x7BEF 35 | TFT_BLUE 0x001F 36 | TFT_GREEN 0x07E0 37 | TFT_CYAN 0x07FF 38 | TFT_RED 0xF800 39 | TFT_MAGENTA 0xF81F 40 | TFT_YELLOW 0xFFE0 41 | TFT_WHITE 0xFFFF 42 | TFT_ORANGE 0xFDA0 43 | TFT_GREENYELLOW 0xB7E0 44 | TFT_PINK 0xFC9F 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | */ 57 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_4/Notes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Information notes only: 4 | ====================== 5 | 6 | //These are the text plotting alignment (reference datum point) 7 | 8 | TL_DATUM = Top left (default) 9 | TC_DATUM = Top centre 10 | TR_DATUM = Top right 11 | 12 | ML_DATUM = Middle left 13 | MC_DATUM = Middle centre 14 | MR_DATUM = Middle right 15 | 16 | BL_DATUM = Bottom left 17 | BC_DATUM = Bottom centre 18 | BR_DATUM = Bottom right 19 | 20 | L_BASELINE = Left character baseline (Line the 'A' character would sit on) 21 | C_BASELINE = Centre character baseline 22 | R_BASELINE = Right character baseline 23 | 24 | // Basic colours already defined: 25 | 26 | TFT_BLACK 0x0000 27 | TFT_NAVY 0x000F 28 | TFT_DARKGREEN 0x03E0 29 | TFT_DARKCYAN 0x03EF 30 | TFT_MAROON 0x7800 31 | TFT_PURPLE 0x780F 32 | TFT_OLIVE 0x7BE0 33 | TFT_LIGHTGREY 0xC618 34 | TFT_DARKGREY 0x7BEF 35 | TFT_BLUE 0x001F 36 | TFT_GREEN 0x07E0 37 | TFT_CYAN 0x07FF 38 | TFT_RED 0xF800 39 | TFT_MAGENTA 0xF81F 40 | TFT_YELLOW 0xFFE0 41 | TFT_WHITE 0xFFFF 42 | TFT_ORANGE 0xFDA0 43 | TFT_GREENYELLOW 0xB7E0 44 | TFT_PINK 0xFC9F 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | */ 57 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/FLASH_Array/Font_Demo_1_Array/Notes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Information notes only: 4 | ====================== 5 | 6 | //These are the text plotting alignment (reference datum point) 7 | 8 | TL_DATUM = Top left (default) 9 | TC_DATUM = Top centre 10 | TR_DATUM = Top right 11 | 12 | ML_DATUM = Middle left 13 | MC_DATUM = Middle centre 14 | MR_DATUM = Middle right 15 | 16 | BL_DATUM = Bottom left 17 | BC_DATUM = Bottom centre 18 | BR_DATUM = Bottom right 19 | 20 | L_BASELINE = Left character baseline (Line the 'A' character would sit on) 21 | C_BASELINE = Centre character baseline 22 | R_BASELINE = Right character baseline 23 | 24 | // Basic colours already defined: 25 | 26 | TFT_BLACK 0x0000 27 | TFT_NAVY 0x000F 28 | TFT_DARKGREEN 0x03E0 29 | TFT_DARKCYAN 0x03EF 30 | TFT_MAROON 0x7800 31 | TFT_PURPLE 0x780F 32 | TFT_OLIVE 0x7BE0 33 | TFT_LIGHTGREY 0xC618 34 | TFT_DARKGREY 0x7BEF 35 | TFT_BLUE 0x001F 36 | TFT_GREEN 0x07E0 37 | TFT_CYAN 0x07FF 38 | TFT_RED 0xF800 39 | TFT_MAGENTA 0xF81F 40 | TFT_YELLOW 0xFFE0 41 | TFT_WHITE 0xFFFF 42 | TFT_ORANGE 0xFDA0 43 | TFT_GREENYELLOW 0xB7E0 44 | TFT_PINK 0xFC9F 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | */ 57 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/FLASH_Array/Font_Demo_2_Array/Notes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Information notes only: 4 | ====================== 5 | 6 | //These are the text plotting alignment (reference datum point) 7 | 8 | TL_DATUM = Top left (default) 9 | TC_DATUM = Top centre 10 | TR_DATUM = Top right 11 | 12 | ML_DATUM = Middle left 13 | MC_DATUM = Middle centre 14 | MR_DATUM = Middle right 15 | 16 | BL_DATUM = Bottom left 17 | BC_DATUM = Bottom centre 18 | BR_DATUM = Bottom right 19 | 20 | L_BASELINE = Left character baseline (Line the 'A' character would sit on) 21 | C_BASELINE = Centre character baseline 22 | R_BASELINE = Right character baseline 23 | 24 | // Basic colours already defined: 25 | 26 | TFT_BLACK 0x0000 27 | TFT_NAVY 0x000F 28 | TFT_DARKGREEN 0x03E0 29 | TFT_DARKCYAN 0x03EF 30 | TFT_MAROON 0x7800 31 | TFT_PURPLE 0x780F 32 | TFT_OLIVE 0x7BE0 33 | TFT_LIGHTGREY 0xC618 34 | TFT_DARKGREY 0x7BEF 35 | TFT_BLUE 0x001F 36 | TFT_GREEN 0x07E0 37 | TFT_CYAN 0x07FF 38 | TFT_RED 0xF800 39 | TFT_MAGENTA 0xF81F 40 | TFT_YELLOW 0xFFE0 41 | TFT_WHITE 0xFFFF 42 | TFT_ORANGE 0xFDA0 43 | TFT_GREENYELLOW 0xB7E0 44 | TFT_PINK 0xFC9F 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | */ 57 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/FLASH_Array/Font_Demo_4_Array/Notes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Information notes only: 4 | ====================== 5 | 6 | //These are the text plotting alignment (reference datum point) 7 | 8 | TL_DATUM = Top left (default) 9 | TC_DATUM = Top centre 10 | TR_DATUM = Top right 11 | 12 | ML_DATUM = Middle left 13 | MC_DATUM = Middle centre 14 | MR_DATUM = Middle right 15 | 16 | BL_DATUM = Bottom left 17 | BC_DATUM = Bottom centre 18 | BR_DATUM = Bottom right 19 | 20 | L_BASELINE = Left character baseline (Line the 'A' character would sit on) 21 | C_BASELINE = Centre character baseline 22 | R_BASELINE = Right character baseline 23 | 24 | // Basic colours already defined: 25 | 26 | TFT_BLACK 0x0000 27 | TFT_NAVY 0x000F 28 | TFT_DARKGREEN 0x03E0 29 | TFT_DARKCYAN 0x03EF 30 | TFT_MAROON 0x7800 31 | TFT_PURPLE 0x780F 32 | TFT_OLIVE 0x7BE0 33 | TFT_LIGHTGREY 0xC618 34 | TFT_DARKGREY 0x7BEF 35 | TFT_BLUE 0x001F 36 | TFT_GREEN 0x07E0 37 | TFT_CYAN 0x07FF 38 | TFT_RED 0xF800 39 | TFT_MAGENTA 0xF81F 40 | TFT_YELLOW 0xFFE0 41 | TFT_WHITE 0xFFFF 42 | TFT_ORANGE 0xFDA0 43 | TFT_GREENYELLOW 0xB7E0 44 | TFT_PINK 0xFC9F 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | */ 57 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ST7789_2_Rotation.h: -------------------------------------------------------------------------------- 1 | // This is the command sequence that rotates the ST7789 driver coordinate frame 2 | 3 | writecommand(TFT_MADCTL); 4 | rotation = m % 4; 5 | switch (rotation) { 6 | case 0: // Portrait 7 | #ifdef CGRAM_OFFSET 8 | colstart = 0; 9 | rowstart = 0; 10 | #endif 11 | writedata(TFT_MAD_COLOR_ORDER); 12 | 13 | _width = _init_width; 14 | _height = _init_height; 15 | break; 16 | 17 | case 1: // Landscape (Portrait + 90) 18 | #ifdef CGRAM_OFFSET 19 | colstart = 0; 20 | rowstart = 0; 21 | #endif 22 | writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 23 | 24 | _width = _init_height; 25 | _height = _init_width; 26 | break; 27 | 28 | case 2: // Inverter portrait 29 | #ifdef CGRAM_OFFSET 30 | colstart = 0; 31 | rowstart = 80; 32 | #endif 33 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 34 | 35 | _width = _init_width; 36 | _height = _init_height; 37 | break; 38 | case 3: // Inverted landscape 39 | #ifdef CGRAM_OFFSET 40 | colstart = 80; 41 | rowstart = 0; 42 | #endif 43 | writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 44 | 45 | _width = _init_height; 46 | _height = _init_width; 47 | break; 48 | } 49 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup12_M5Stack.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ILI9341_DRIVER 4 | 5 | 6 | #define M5STACK 7 | 8 | 9 | #define TFT_MISO 19 10 | #define TFT_MOSI 23 11 | #define TFT_SCLK 18 12 | #define TFT_CS 14 // Chip select control pin 13 | #define TFT_DC 27 // Data Command control pin 14 | #define TFT_RST 33 // Reset pin (could connect to Arduino RESET pin) 15 | #define TFT_BL 32 // LED back-light 16 | 17 | 18 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 19 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 20 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 21 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 22 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 23 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 24 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 25 | 26 | #define SMOOTH_FONT 27 | 28 | 29 | #define SPI_FREQUENCY 27000000 30 | 31 | // Optional reduced SPI frequency for reading TFT 32 | #define SPI_READ_FREQUENCY 5000000 -------------------------------------------------------------------------------- /TFT_eSPI/Tools/Images/README.md: -------------------------------------------------------------------------------- 1 | ## bmp2array4bit 2 | 3 | bmp2array4bit.py reads a bmp file, and creates C (or C++) code that contains two arrays for adding images to four-bit sprites. See [Sprite_image_4bit](../../examples/Sprite/Sprite_image_4bit) for an example. 4 | 5 | It is loosely based on Spark Fun's bmp2array script, https://github.com/sparkfun/BMPtoArray/blob/master/bmp2array.py. The bmp file format is documented in https://en.wikipedia.org/wiki/BMP_file_format. 6 | 7 | You'll need python 3.6 (the original uses Python 2.7) 8 | 9 | `usage: python bmp2array4bit.py [-v] star.bmp [-o myfile.c]` 10 | 11 | Create the bmp file in Gimp (www.gimp.org) from any image as follows: 12 | 13 | * Remove the alpha channel (if it has one) 14 | Layer -> Transparency -> Remove Alpha Channel 15 | * Set the mode to indexed. 16 | Image -> Mode -> Indexed... 17 | * Select Generate optimum palette with 16 colors (max) 18 | * Export the file with a .bmp extension. Do **NOT** select options: 19 | * Run-Length Encoded 20 | * Compatibility Options: "Do not write color space information" 21 | * There are no Advanced Options available with these settings 22 | 23 | (There are other tools that will produce bmp files, and these should work provided you don't use run-length encoding or other advanced features). 24 | 25 | The first array produced is the palette for the image. 26 | The second is the image itself. 27 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup45_TTGO_T_Watch.h: -------------------------------------------------------------------------------- 1 | #define ST7789_DRIVER 2 | 3 | #define TFT_WIDTH 240 4 | #define TFT_HEIGHT 240 5 | 6 | #define TFT_MISO -1 7 | #define TFT_MOSI 19 8 | #define TFT_SCLK 18 9 | #define TFT_CS 5 10 | #define TFT_DC 27 11 | 12 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 13 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 14 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 15 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 16 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 17 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 18 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 19 | #define SMOOTH_FONT 20 | 21 | // #define SPI_FREQUENCY 1000000 22 | // #define SPI_FREQUENCY 5000000 23 | // #define SPI_FREQUENCY 10000000 24 | // #define SPI_FREQUENCY 20000000 25 | // #define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3 26 | #define SPI_FREQUENCY 40000000 27 | //#define SPI_FREQUENCY 80000000 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup44_TTGO_CameraPlus.h: -------------------------------------------------------------------------------- 1 | 2 | #define ST7789_DRIVER 3 | 4 | #define TFT_WIDTH 240 5 | #define TFT_HEIGHT 240 6 | 7 | #define TFT_MOSI 19 8 | #define TFT_MISO 22 9 | #define TFT_SCLK 21 10 | #define TFT_CS 12 11 | #define TFT_DC 15 12 | #define TFT_RST -1 13 | 14 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 15 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 16 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 17 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 18 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-. 19 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 20 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 21 | 22 | #define SMOOTH_FONT 23 | 24 | // #define SPI_FREQUENCY 1000000 25 | // #define SPI_FREQUENCY 5000000 26 | // #define SPI_FREQUENCY 10000000 27 | // #define SPI_FREQUENCY 20000000 28 | // #define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3 29 | #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS 30 | // #define SUPPORT_TRANSACTIONS 31 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup11_RPi_touch_ILI9486.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | #define RPI_DISPLAY_TYPE 3 | #define ILI9486_DRIVER // 20MHz maximum SPI 4 | 5 | #define TFT_MISO 19 6 | #define TFT_MOSI 23 7 | #define TFT_SCLK 18 8 | #define TFT_CS 15 // Chip select control pin 9 | #define TFT_DC 2 // Data Command control pin 10 | #define TFT_RST 4 // Reset pin (could connect to RST pin) 11 | //#define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST 12 | 13 | #define TOUCH_CS 22 // Chip select pin (T_CS) of touch screen 14 | 15 | 16 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 17 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 18 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 19 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 20 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 21 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 22 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 23 | 24 | #define SMOOTH_FONT 25 | 26 | 27 | #define SPI_FREQUENCY 20000000 28 | 29 | #define SPI_TOUCH_FREQUENCY 2500000 30 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup36_RPi_touch_ILI9341.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define RPI_DISPLAY_TYPE 4 | #define ST7796_DRIVER // 20MHz maximum SPI 5 | 6 | 7 | #define TFT_MISO 19 8 | #define TFT_MOSI 23 9 | #define TFT_SCLK 18 10 | #define TFT_CS 15 // Chip select control pin 11 | #define TFT_DC 2 // Data Command control pin 12 | #define TFT_RST 4 // Reset pin (could connect to RST pin) 13 | //#define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST 14 | 15 | #define TOUCH_CS 22 // Chip select pin (T_CS) of touch screen 16 | 17 | 18 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 19 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 20 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 21 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 22 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 23 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 24 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 25 | 26 | #define SMOOTH_FONT 27 | 28 | 29 | #define SPI_FREQUENCY 40000000 30 | 31 | #define SPI_TOUCH_FREQUENCY 2500000 32 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup5_RPi_ILI9486.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define RPI_ILI9486_DRIVER // 20MHz maximum SPI 4 | 5 | 6 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 7 | #define TFT_CS PIN_D8 // Chip select control pin D8 8 | #define TFT_DC PIN_D3 // Data Command control pin 9 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 10 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 11 | 12 | 13 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 14 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 15 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 16 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 17 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 18 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 19 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 20 | 21 | #define SMOOTH_FONT 22 | 23 | 24 | #define SPI_FREQUENCY 20000000 25 | 26 | #define SPI_TOUCH_FREQUENCY 2500000 27 | 28 | 29 | // #define SUPPORT_TRANSACTIONS 30 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup1_ILI9341.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ILI9341_DRIVER 4 | 5 | 6 | #define TFT_CS PIN_D8 // Chip select control pin D8 7 | #define TFT_DC PIN_D3 // Data Command control pin 8 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 9 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 10 | 11 | 12 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 13 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 14 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 15 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 16 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 17 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 18 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 19 | 20 | 21 | #define SMOOTH_FONT 22 | 23 | 24 | // #define SPI_FREQUENCY 27000000 25 | #define SPI_FREQUENCY 40000000 26 | // #define SPI_FREQUENCY 80000000 27 | 28 | #define SPI_READ_FREQUENCY 20000000 29 | 30 | #define SPI_TOUCH_FREQUENCY 2500000 31 | 32 | 33 | // #define SUPPORT_TRANSACTIONS 34 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup15_HX8357D.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define HX8357D_DRIVER 4 | 5 | 6 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 7 | #define TFT_CS PIN_D8 // Chip select control pin D8 8 | #define TFT_DC PIN_D3 // Data Command control pin 9 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 10 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 11 | 12 | 13 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 14 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 15 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 16 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 17 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 18 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 19 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 20 | 21 | #define SMOOTH_FONT 22 | 23 | 24 | // #define SPI_FREQUENCY 20000000 25 | #define SPI_FREQUENCY 27000000 26 | // #define SPI_FREQUENCY 40000000 27 | 28 | #define SPI_TOUCH_FREQUENCY 2500000 29 | 30 | 31 | // #define SUPPORT_TRANSACTIONS 32 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup20_ILI9488.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ILI9488_DRIVER 4 | 5 | 6 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 7 | #define TFT_CS PIN_D8 // Chip select control pin D8 8 | #define TFT_DC PIN_D3 // Data Command control pin 9 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 10 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 11 | 12 | 13 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 14 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 15 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 16 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 17 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 18 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 19 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 20 | 21 | #define SMOOTH_FONT 22 | 23 | 24 | // #define SPI_FREQUENCY 20000000 25 | #define SPI_FREQUENCY 27000000 26 | // #define SPI_FREQUENCY 40000000 27 | 28 | 29 | #define SPI_TOUCH_FREQUENCY 2500000 30 | 31 | 32 | // #define SUPPORT_TRANSACTIONS 33 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Font_Demo_3/Notes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Information notes only: 4 | ====================== 5 | 6 | Note: it is best to use drawNumber() and drawFloat() for numeric values 7 | this reduces digit position movement when the value changes 8 | drawNumber() and drawFloat() functions behave like drawString() and are 9 | supported by setTextDatum() and setTextPadding() 10 | 11 | //These are the text plotting alignment (reference datum point) 12 | 13 | TL_DATUM = Top left (default) 14 | TC_DATUM = Top centre 15 | TR_DATUM = Top right 16 | 17 | ML_DATUM = Middle left 18 | MC_DATUM = Middle centre 19 | MR_DATUM = Middle right 20 | 21 | BL_DATUM = Bottom left 22 | BC_DATUM = Bottom centre 23 | BR_DATUM = Bottom right 24 | 25 | L_BASELINE = Left character baseline (Line the 'A' character would sit on) 26 | C_BASELINE = Centre character baseline 27 | R_BASELINE = Right character baseline 28 | 29 | // Basic colours already defined: 30 | 31 | TFT_BLACK 0x0000 32 | TFT_NAVY 0x000F 33 | TFT_DARKGREEN 0x03E0 34 | TFT_DARKCYAN 0x03EF 35 | TFT_MAROON 0x7800 36 | TFT_PURPLE 0x780F 37 | TFT_OLIVE 0x7BE0 38 | TFT_LIGHTGREY 0xC618 39 | TFT_DARKGREY 0x7BEF 40 | TFT_BLUE 0x001F 41 | TFT_GREEN 0x07E0 42 | TFT_CYAN 0x07FF 43 | TFT_RED 0xF800 44 | TFT_MAGENTA 0xF81F 45 | TFT_YELLOW 0xFFE0 46 | TFT_WHITE 0xFFFF 47 | TFT_ORANGE 0xFDA0 48 | TFT_GREENYELLOW 0xB7E0 49 | TFT_PINK 0xFC9F 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | */ 62 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup21_ILI9488.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ILI9488_DRIVER 4 | 5 | //#define TFT_INVERSION_OFF 6 | 7 | #define TFT_MISO 19 // (leave TFT SDO disconnected if other SPI devices share MISO) 8 | #define TFT_MOSI 23 9 | #define TFT_SCLK 18 10 | #define TFT_CS 15 // Chip select control pin 11 | #define TFT_DC 2 // Data Command control pin 12 | #define TFT_RST 4 // Reset pin (could connect to RST pin) 13 | 14 | 15 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 16 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 17 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 18 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 19 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 20 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 21 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 22 | 23 | #define SMOOTH_FONT 24 | 25 | 26 | // #define SPI_FREQUENCY 20000000 27 | #define SPI_FREQUENCY 27000000 28 | // #define SPI_FREQUENCY 40000000 29 | // #define SPI_FREQUENCY 80000000 30 | 31 | // Optional reduced SPI frequency for reading TFT 32 | #define SPI_READ_FREQUENCY 16000000 33 | 34 | #define SPI_TOUCH_FREQUENCY 2500000 35 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/FLASH_Array/Font_Demo_3_Array/Notes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Information notes only: 4 | ====================== 5 | 6 | Note: it is best to use drawNumber() and drawFloat() for numeric values 7 | this reduces digit position movement when the value changes 8 | drawNumber() and drawFloat() functions behave like drawString() and are 9 | supported by setTextDatum() and setTextPadding() 10 | 11 | //These are the text plotting alignment (reference datum point) 12 | 13 | TL_DATUM = Top left (default) 14 | TC_DATUM = Top centre 15 | TR_DATUM = Top right 16 | 17 | ML_DATUM = Middle left 18 | MC_DATUM = Middle centre 19 | MR_DATUM = Middle right 20 | 21 | BL_DATUM = Bottom left 22 | BC_DATUM = Bottom centre 23 | BR_DATUM = Bottom right 24 | 25 | L_BASELINE = Left character baseline (Line the 'A' character would sit on) 26 | C_BASELINE = Centre character baseline 27 | R_BASELINE = Right character baseline 28 | 29 | // Basic colours already defined: 30 | 31 | TFT_BLACK 0x0000 32 | TFT_NAVY 0x000F 33 | TFT_DARKGREEN 0x03E0 34 | TFT_DARKCYAN 0x03EF 35 | TFT_MAROON 0x7800 36 | TFT_PURPLE 0x780F 37 | TFT_OLIVE 0x7BE0 38 | TFT_LIGHTGREY 0xC618 39 | TFT_DARKGREY 0x7BEF 40 | TFT_BLUE 0x001F 41 | TFT_GREEN 0x07E0 42 | TFT_CYAN 0x07FF 43 | TFT_RED 0xF800 44 | TFT_MAGENTA 0xF81F 45 | TFT_YELLOW 0xFFE0 46 | TFT_WHITE 0xFFFF 47 | TFT_ORANGE 0xFDA0 48 | TFT_GREENYELLOW 0xB7E0 49 | TFT_PINK 0xFC9F 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | */ 62 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9486_Rotation.h: -------------------------------------------------------------------------------- 1 | // This is the command sequence that rotates the ILI9486 driver coordinate frame 2 | 3 | writecommand(TFT_MADCTL); 4 | rotation = m % 8; 5 | switch (rotation) { 6 | case 0: // Portrait 7 | writedata(TFT_MAD_BGR | TFT_MAD_MX); 8 | _width = _init_width; 9 | _height = _init_height; 10 | break; 11 | case 1: // Landscape (Portrait + 90) 12 | writedata(TFT_MAD_BGR | TFT_MAD_MV); 13 | _width = _init_height; 14 | _height = _init_width; 15 | break; 16 | case 2: // Inverter portrait 17 | writedata( TFT_MAD_BGR | TFT_MAD_MY); 18 | _width = _init_width; 19 | _height = _init_height; 20 | break; 21 | case 3: // Inverted landscape 22 | writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_MY); 23 | _width = _init_height; 24 | _height = _init_width; 25 | break; 26 | case 4: // Portrait 27 | writedata(TFT_MAD_BGR | TFT_MAD_MX | TFT_MAD_MY); 28 | _width = _init_width; 29 | _height = _init_height; 30 | break; 31 | case 5: // Landscape (Portrait + 90) 32 | writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MX); 33 | _width = _init_height; 34 | _height = _init_width; 35 | break; 36 | case 6: // Inverter portrait 37 | writedata( TFT_MAD_BGR); 38 | _width = _init_width; 39 | _height = _init_height; 40 | break; 41 | case 7: // Inverted landscape 42 | writedata(TFT_MAD_BGR | TFT_MAD_MV | TFT_MAD_MY); 43 | _width = _init_height; 44 | _height = _init_width; 45 | break; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup6_RPi_Wr_ILI9486.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define RPI_ILI9486_DRIVER // 20MHz maximum SPI 4 | 5 | 6 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 7 | #define TFT_CS PIN_D8 // Chip select control pin D8 8 | #define TFT_DC PIN_D3 // Data Command control pin 9 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 10 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 11 | 12 | #define TFT_WR PIN_D2 // Write strobe for modified Raspberry Pi TFT only 13 | 14 | 15 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 16 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 17 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 18 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 19 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 20 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 21 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 22 | 23 | #define SMOOTH_FONT 24 | 25 | 26 | #define SPI_FREQUENCY 20000000 27 | 28 | #define SPI_TOUCH_FREQUENCY 2500000 29 | 30 | 31 | // #define SUPPORT_TRANSACTIONS 32 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/SSD1963_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #if defined (SSD1963_480_DRIVER) 4 | #define TFT_WIDTH 272 5 | #define TFT_HEIGHT 480 6 | #elif defined (SSD1963_800_DRIVER) 7 | #define TFT_WIDTH 480 8 | #define TFT_HEIGHT 800 9 | #elif defined (SSD1963_800ALT_DRIVER) 10 | #define TFT_WIDTH 480 11 | #define TFT_HEIGHT 800 12 | #endif 13 | 14 | //Set driver type common to all initialisation options 15 | #ifndef SSD1963_DRIVER 16 | #define SSD1963_DRIVER 17 | #endif 18 | 19 | // Delay between some initialisation commands 20 | #define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked 21 | 22 | // Generic commands used by TFT_eSPI.cpp 23 | #define TFT_NOP 0x00 24 | #define TFT_SWRST 0x01 25 | 26 | #define TFT_CASET 0x2A 27 | #define TFT_PASET 0x2B 28 | #define TFT_RAMWR 0x2C 29 | 30 | #define TFT_RAMRD 0x2E 31 | #define TFT_IDXRD 0xDD // ILI9341 only, indexed control register read 32 | 33 | #define TFT_MADCTL 0x36 34 | #define TFT_MAD_MY 0x80 35 | #define TFT_MAD_MX 0x40 36 | #define TFT_MAD_MV 0x20 37 | #define TFT_MAD_ML 0x10 38 | #define TFT_MAD_BGR 0x08 39 | #define TFT_MAD_MH 0x04 40 | #define TFT_MAD_RGB 0x00 41 | 42 | #ifdef TFT_RGB_ORDER 43 | #if (TFT_RGB_ORDER == 1) 44 | #define TFT_MAD_COLOR_ORDER TFT_MAD_RGB 45 | #else 46 | #define TFT_MAD_COLOR_ORDER TFT_MAD_BGR 47 | #endif 48 | #else 49 | #define TFT_MAD_COLOR_ORDER TFT_MAD_BGR 50 | #endif 51 | 52 | #define TFT_INVOFF 0x20 53 | #define TFT_INVON 0x21 54 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup16_ILI9488_Parallel.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ESP32_PARALLEL 4 | 5 | 6 | #define ILI9488_DRIVER 7 | 8 | 9 | // ESP32 pins used 10 | #define TFT_CS 33 // Chip select control pin 11 | #define TFT_DC 15 // Data Command control pin - must use a pin in the range 0-31 12 | #define TFT_RST 32 // Reset pin 13 | 14 | #define TFT_WR 4 // Write strobe control pin - must use a pin in the range 0-31 15 | #define TFT_RD 2 16 | 17 | #define TFT_D0 12 // Must use pins in the range 0-31 for the data bus 18 | #define TFT_D1 13 // so a single register write sets/clears all bits 19 | #define TFT_D2 26 20 | #define TFT_D3 25 21 | #define TFT_D4 17 22 | #define TFT_D5 16 23 | #define TFT_D6 27 24 | #define TFT_D7 14 25 | 26 | 27 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 28 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 29 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 30 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 31 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 32 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 33 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 34 | 35 | #define SMOOTH_FONT 36 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup10_RPi_touch_ILI9486.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define RPI_DISPLAY_TYPE 4 | #define ILI9486_DRIVER // 20MHz maximum SPI 5 | 6 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 7 | #define TFT_CS PIN_D2 // Chip select control pin D2 8 | #define TFT_DC PIN_D3 // Data Command control pin 9 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 10 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 11 | 12 | #define TOUCH_CS PIN_D1 // Chip select pin (T_CS) of touch screen 13 | 14 | 15 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 16 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 17 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 18 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 19 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 20 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 21 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 22 | 23 | #define SMOOTH_FONT 24 | 25 | 26 | #define SPI_FREQUENCY 16000000 27 | 28 | #define SPI_TOUCH_FREQUENCY 2500000 29 | 30 | 31 | // #define SUPPORT_TRANSACTIONS 32 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup13_ILI9481_Parallel.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ESP32_PARALLEL 4 | 5 | 6 | #define ILI9481_DRIVER 7 | 8 | 9 | // ESP32 pins used for UNO format board 10 | #define TFT_CS 33 // Chip select control pin 11 | #define TFT_DC 15 // Data Command control pin - must use a pin in the range 0-31 12 | #define TFT_RST 32 // Reset pin 13 | 14 | #define TFT_WR 4 // Write strobe control pin - must use a pin in the range 0-31 15 | #define TFT_RD 2 16 | 17 | #define TFT_D0 12 // Must use pins in the range 0-31 for the data bus 18 | #define TFT_D1 13 // so a single register write sets/clears all bits 19 | #define TFT_D2 26 20 | #define TFT_D3 25 21 | #define TFT_D4 17 22 | #define TFT_D5 16 23 | #define TFT_D6 27 24 | #define TFT_D7 14 25 | 26 | 27 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 28 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 29 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 30 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 31 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 32 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 33 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 34 | 35 | #define SMOOTH_FONT 36 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup19_RM68140_Parallel.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ESP32_PARALLEL 4 | 5 | 6 | #define RM68140_DRIVER 7 | 8 | 9 | // ESP32 pins used for UNO format board 10 | #define TFT_CS 33 // Chip select control pin 11 | #define TFT_DC 15 // Data Command control pin - must use a pin in the range 0-31 12 | #define TFT_RST 32 // Reset pin 13 | 14 | #define TFT_WR 4 // Write strobe control pin - must use a pin in the range 0-31 15 | #define TFT_RD 2 16 | 17 | #define TFT_D0 12 // Must use pins in the range 0-31 for the data bus 18 | #define TFT_D1 13 // so a single register write sets/clears all bits 19 | #define TFT_D2 26 20 | #define TFT_D3 25 21 | #define TFT_D4 17 22 | #define TFT_D5 16 23 | #define TFT_D6 27 24 | #define TFT_D7 14 25 | 26 | 27 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 28 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 29 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 30 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 31 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 32 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 33 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 34 | 35 | #define SMOOTH_FONT 36 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Test and diagnostics/Test_Touch_Controller/Test_Touch_Controller.ino: -------------------------------------------------------------------------------- 1 | // This sketch is to test the touch controller, nothing is displayed 2 | // on the TFT. The TFT_eSPI library must be configured to suit your 3 | // pins used. Make sure both the touch chip select and the TFT chip 4 | // select are correctly defined to avoid SPI bus contention. 5 | 6 | // Make sure you have defined a pin for the touch controller chip 7 | // select line in the user setup file or you will see "no member" 8 | // compile errors for the touch functions! 9 | 10 | // It is a support and diagnostic sketch for the TFT_eSPI library: 11 | // https://github.com/Bodmer/TFT_eSPI 12 | 13 | // The "raw" (unprocessed) touch sensor outputs are sent to the 14 | // serial port. Touching the screen should show changes to the x, y 15 | // and z values. x and y are raw ADC readings, not pixel coordinates. 16 | 17 | #include 18 | #include 19 | TFT_eSPI tft = TFT_eSPI(); 20 | 21 | //==================================================================== 22 | 23 | void setup(void) { 24 | Serial.begin(115200); 25 | Serial.println("\n\nStarting..."); 26 | 27 | tft.init(); 28 | } 29 | 30 | //==================================================================== 31 | 32 | void loop() { 33 | 34 | uint16_t x, y; 35 | 36 | tft.getTouchRaw(&x, &y); 37 | 38 | Serial.printf("x: %i ", x); 39 | 40 | Serial.printf("y: %i ", y); 41 | 42 | Serial.printf("z: %i \n", tft.getTouchRawZ()); 43 | 44 | delay(250); 45 | 46 | } 47 | 48 | //==================================================================== 49 | 50 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/SSD1963_Rotation.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that rotates the SSD1963 driver coordinate frame 3 | 4 | rotation = m % 8; // Limit the range of values to 0-7 5 | 6 | writecommand(TFT_MADCTL); 7 | switch (rotation) { 8 | case 0: 9 | writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER); 10 | _width = _init_width; 11 | _height = _init_height; 12 | break; 13 | case 1: 14 | writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 15 | _width = _init_height; 16 | _height = _init_width; 17 | break; 18 | case 2: 19 | writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 20 | _width = _init_width; 21 | _height = _init_height; 22 | break; 23 | case 3: 24 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 25 | _width = _init_height; 26 | _height = _init_width; 27 | break; 28 | // These next rotations are for bottom up BMP drawing 29 | case 4: 30 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 31 | _width = _init_width; 32 | _height = _init_height; 33 | break; 34 | case 5: 35 | writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER); 36 | _width = _init_height; 37 | _height = _init_width; 38 | break; 39 | case 6: 40 | writedata(TFT_MAD_COLOR_ORDER); 41 | _width = _init_width; 42 | _height = _init_height; 43 | break; 44 | case 7: 45 | writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 46 | _width = _init_height; 47 | _height = _init_width; 48 | break; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ST7796_Rotation.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that rotates the ST7796 driver coordinate frame 3 | 4 | rotation = m % 8; // Limit the range of values to 0-7 5 | 6 | writecommand(TFT_MADCTL); 7 | switch (rotation) { 8 | case 0: 9 | writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER); 10 | _width = _init_width; 11 | _height = _init_height; 12 | break; 13 | case 1: 14 | writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 15 | _width = _init_height; 16 | _height = _init_width; 17 | break; 18 | case 2: 19 | writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 20 | _width = _init_width; 21 | _height = _init_height; 22 | break; 23 | case 3: 24 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 25 | _width = _init_height; 26 | _height = _init_width; 27 | break; 28 | // These next rotations are for bottom up BMP drawing 29 | case 4: 30 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 31 | _width = _init_width; 32 | _height = _init_height; 33 | break; 34 | case 5: 35 | writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER); 36 | _width = _init_height; 37 | _height = _init_width; 38 | break; 39 | case 6: 40 | writedata(TFT_MAD_COLOR_ORDER); 41 | _width = _init_width; 42 | _height = _init_height; 43 | break; 44 | case 7: 45 | writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 46 | _width = _init_height; 47 | _height = _init_width; 48 | break; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup14_ILI9341_Parallel.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ESP32_PARALLEL 4 | 5 | 6 | #define ILI9341_DRIVER 7 | 8 | 9 | // ESP32 pins used for the parallel interface TFT 10 | #define TFT_CS 33 // Chip select control pin 11 | #define TFT_DC 15 // Data Command control pin - must use a pin in the range 0-31 12 | #define TFT_RST 32 // Reset pin 13 | 14 | #define TFT_WR 4 // Write strobe control pin - must use a pin in the range 0-31 15 | #define TFT_RD 2 16 | 17 | #define TFT_D0 12 // Must use pins in the range 0-31 for the data bus 18 | #define TFT_D1 13 // so a single register write sets/clears all bits 19 | #define TFT_D2 26 20 | #define TFT_D3 25 21 | #define TFT_D4 17 22 | #define TFT_D5 16 23 | #define TFT_D6 27 24 | #define TFT_D7 14 25 | 26 | 27 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 28 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 29 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 30 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 31 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 32 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 33 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 34 | 35 | #define SMOOTH_FONT 36 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup4_S6D02A1.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define S6D02A1_DRIVER 4 | 5 | 6 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 7 | #define TFT_CS PIN_D8 // Chip select control pin D8 8 | #define TFT_DC PIN_D3 // Data Command control pin 9 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 10 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 11 | 12 | 13 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 14 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 15 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 16 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 17 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 18 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 19 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT 20 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 21 | 22 | #define SMOOTH_FONT 23 | 24 | 25 | // #define SPI_FREQUENCY 20000000 26 | #define SPI_FREQUENCY 27000000 27 | // #define SPI_FREQUENCY 40000000 28 | 29 | #define SPI_TOUCH_FREQUENCY 2500000 30 | 31 | 32 | // #define SUPPORT_TRANSACTIONS 33 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9163_Init.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that initialises the ILI9163 driver 3 | // 4 | // This setup information is in a format accecpted by the commandList() function 5 | // which reduces FLASH space, but on an ESP8266 there is plenty available! 6 | // 7 | // See ILI9341_Setup.h file for an alternative simpler format 8 | 9 | { 10 | // Initialization commands for ILI9163 screens 11 | static const uint8_t ILI9163_cmds[] PROGMEM = 12 | { 13 | 17, // 17 commands follow 14 | 0x01, 0 + TFT_INIT_DELAY, 120, // Software reset 15 | 0x11, 0 + TFT_INIT_DELAY, 5, // Exit sleep mode 16 | 0x3A, 1, 0x05, // Set pixel format 17 | 0x26, 1, 0x04, // Set Gamma curve 3 18 | 0xF2, 1, 0x01, // Gamma adjustment enabled 19 | 0xE0, 15, 0x3F, 0x25, 0x1C, 0x1E, 0x20, 0x12, 0x2A, 0x90, 20 | 0x24, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, // Positive Gamma 21 | 0xE1, 15, 0x20, 0x20, 0x20, 0x20, 0x05, 0x00, 0x15,0xA7, 22 | 0x3D, 0x18, 0x25, 0x2A, 0x2B, 0x2B, 0x3A, // Negative Gamma 23 | 0xB1, 2, 0x08, 0x08, // Frame rate control 1 24 | 0xB4, 1, 0x07, // Display inversion 25 | 0xC0, 2, 0x0A, 0x02, // Power control 1 26 | 0xC1, 1, 0x02, // Power control 2 27 | 0xC5, 2, 0x50, 0x5B, // Vcom control 1 28 | 0xC7, 1, 0x40, // Vcom offset 29 | 0x2A, 4, 0x00, 0x00, 0x00, 0x7F, // Set column address 30 | 0x2B, 4 + TFT_INIT_DELAY, 0x00, 0x00, 0x00, 0x9F, 250, // Set page address 31 | 0x36, 1, 0xC8, // Set address mode 32 | 0x29, 0, // Set display on 33 | }; 34 | 35 | commandList(ILI9163_cmds); 36 | 37 | #ifdef CGRAM_OFFSET 38 | colstart = 0; 39 | rowstart = 0; 40 | #endif 41 | } -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup3_ILI9163.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ILI9163_DRIVER 4 | 5 | 6 | #define TFT_WIDTH 128 7 | #define TFT_HEIGHT 160 8 | 9 | 10 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 11 | #define TFT_CS PIN_D8 // Chip select control pin D8 12 | #define TFT_DC PIN_D3 // Data Command control pin 13 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 14 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 15 | 16 | 17 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 18 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 19 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 20 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 21 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 22 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 23 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT 24 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 25 | 26 | #define SMOOTH_FONT 27 | 28 | 29 | // #define SPI_FREQUENCY 20000000 30 | #define SPI_FREQUENCY 27000000 31 | // #define SPI_FREQUENCY 40000000 32 | 33 | #define SPI_TOUCH_FREQUENCY 2500000 34 | 35 | 36 | // #define SUPPORT_TRANSACTIONS 37 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup8_ILI9163_128x128.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ILI9163_DRIVER 4 | 5 | 6 | #define TFT_WIDTH 128 7 | #define TFT_HEIGHT 128 8 | 9 | 10 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 11 | #define TFT_CS PIN_D8 // Chip select control pin D8 12 | #define TFT_DC PIN_D3 // Data Command control pin 13 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 14 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 15 | 16 | 17 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 18 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 19 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 20 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 21 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 22 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 23 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT 24 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 25 | 26 | #define SMOOTH_FONT 27 | 28 | 29 | // #define SPI_FREQUENCY 20000000 30 | #define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3 31 | 32 | #define SPI_TOUCH_FREQUENCY 2500000 33 | 34 | 35 | // #define SUPPORT_TRANSACTIONS 36 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup2_ST7735.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ST7735_DRIVER 4 | 5 | 6 | #define TFT_WIDTH 128 7 | #define TFT_HEIGHT 160 8 | 9 | 10 | #define ST7735_REDTAB 11 | 12 | 13 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 14 | #define TFT_CS PIN_D8 // Chip select control pin D8 15 | #define TFT_DC PIN_D3 // Data Command control pin 16 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 17 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 18 | 19 | 20 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 21 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 22 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 23 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 24 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 25 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 26 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT 27 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 28 | 29 | #define SMOOTH_FONT 30 | 31 | 32 | // #define SPI_FREQUENCY 20000000 33 | #define SPI_FREQUENCY 27000000 34 | // #define SPI_FREQUENCY 40000000 35 | 36 | #define SPI_TOUCH_FREQUENCY 2500000 37 | 38 | 39 | // #define SUPPORT_TRANSACTIONS 40 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup7_ST7735_128x128.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ST7735_DRIVER 4 | 5 | 6 | #define TFT_WIDTH 128 7 | #define TFT_HEIGHT 128 8 | 9 | 10 | #define ST7735_GREENTAB128 // For 128 x 128 display 11 | 12 | 13 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 14 | #define TFT_CS PIN_D8 // Chip select control pin D8 15 | #define TFT_DC PIN_D3 // Data Command control pin 16 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 17 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 18 | 19 | 20 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 21 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 22 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 23 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 24 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 25 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 26 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT 27 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 28 | 29 | 30 | #define SMOOTH_FONT 31 | 32 | 33 | // #define SPI_FREQUENCY 20000000 34 | #define SPI_FREQUENCY 27000000 35 | 36 | #define SPI_TOUCH_FREQUENCY 2500000 37 | 38 | 39 | // #define SUPPORT_TRANSACTIONS 40 | -------------------------------------------------------------------------------- /TFT_eSPI/Fonts/GFXFF/license.txt: -------------------------------------------------------------------------------- 1 | This TFT_eSPI library has been developed from the Adafruit_GFX library: 2 | 3 | https://github.com/adafruit/Adafruit-GFX-Library 4 | 5 | It has been modified extensively to improve rendering speed on 6 | ESP8266 processors. There follows the original library license text. 7 | 8 | 9 | Original text follows: 10 | 11 | Software License Agreement (BSD License) 12 | 13 | Copyright (c) 2012 Adafruit Industries. All rights reserved. 14 | 15 | Redistribution and use in source and binary forms, with or without 16 | modification, are permitted provided that the following conditions are met: 17 | 18 | - Redistributions of source code must retain the above copyright notice, 19 | this list of conditions and the following disclaimer. 20 | - Redistributions in binary form must reproduce the above copyright notice, 21 | this list of conditions and the following disclaimer in the documentation 22 | and/or other materials provided with the distribution. 23 | 24 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 25 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 28 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 | POSSIBILITY OF SUCH DAMAGE. 35 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9481_Init.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that initialises the ILI9481 driver 3 | // 4 | // This setup information uses simple 8 bit SPI writecommand() and writedata() functions 5 | // 6 | // See ST7735_Setup.h file for an alternative format 7 | 8 | 9 | // Configure ILI9481 display 10 | 11 | writecommand(TFT_SLPOUT); 12 | delay(20); 13 | 14 | writecommand(0xD0); 15 | writedata(0x07); 16 | writedata(0x42); 17 | writedata(0x18); 18 | 19 | writecommand(0xD1); 20 | writedata(0x00); 21 | writedata(0x07); 22 | writedata(0x10); 23 | 24 | writecommand(0xD2); 25 | writedata(0x01); 26 | writedata(0x02); 27 | 28 | writecommand(0xC0); 29 | writedata(0x10); 30 | writedata(0x3B); 31 | writedata(0x00); 32 | writedata(0x02); 33 | writedata(0x11); 34 | 35 | writecommand(0xC5); 36 | writedata(0x03); 37 | 38 | writecommand(0xC8); 39 | writedata(0x00); 40 | writedata(0x32); 41 | writedata(0x36); 42 | writedata(0x45); 43 | writedata(0x06); 44 | writedata(0x16); 45 | writedata(0x37); 46 | writedata(0x75); 47 | writedata(0x77); 48 | writedata(0x54); 49 | writedata(0x0C); 50 | writedata(0x00); 51 | 52 | writecommand(TFT_MADCTL); 53 | writedata(0x0A); 54 | 55 | writecommand(0x3A); 56 | writedata(0x55); 57 | 58 | writecommand(TFT_CASET); 59 | writedata(0x00); 60 | writedata(0x00); 61 | writedata(0x01); 62 | writedata(0x3F); 63 | 64 | writecommand(TFT_PASET); 65 | writedata(0x00); 66 | writedata(0x00); 67 | writedata(0x01); 68 | writedata(0xDF); 69 | 70 | delay(120); 71 | writecommand(TFT_DISPON); 72 | 73 | delay(25); 74 | // End of ILI9481 display configuration 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/RM68140_Init.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that initialises the RM68140 driver 3 | // 4 | // This setup information uses simple 8 bit SPI writecommand() and writedata() functions 5 | // 6 | // See ST7735_Setup.h file for an alternative format 7 | 8 | 9 | // Configure RM68140 display 10 | 11 | writecommand(TFT_SLPOUT); 12 | delay(20); 13 | 14 | writecommand(0xD0); 15 | writedata(0x07); 16 | writedata(0x42); 17 | writedata(0x18); 18 | 19 | writecommand(0xD1); 20 | writedata(0x00); 21 | writedata(0x07); 22 | writedata(0x10); 23 | 24 | writecommand(0xD2); 25 | writedata(0x01); 26 | writedata(0x02); 27 | 28 | writecommand(0xC0); 29 | writedata(0x10); 30 | writedata(0x3B); 31 | writedata(0x00); 32 | writedata(0x02); 33 | writedata(0x11); 34 | 35 | writecommand(0xC5); 36 | writedata(0x03); 37 | 38 | writecommand(0xC8); 39 | writedata(0x00); 40 | writedata(0x32); 41 | writedata(0x36); 42 | writedata(0x45); 43 | writedata(0x06); 44 | writedata(0x16); 45 | writedata(0x37); 46 | writedata(0x75); 47 | writedata(0x77); 48 | writedata(0x54); 49 | writedata(0x0C); 50 | writedata(0x00); 51 | 52 | writecommand(TFT_MADCTL); 53 | writedata(0x0A); 54 | 55 | writecommand(0x3A); 56 | writedata(0x55); 57 | 58 | writecommand(TFT_CASET); 59 | writedata(0x00); 60 | writedata(0x00); 61 | writedata(0x01); 62 | writedata(0x3F); 63 | 64 | writecommand(TFT_PASET); 65 | writedata(0x00); 66 | writedata(0x00); 67 | writedata(0x01); 68 | writedata(0xDF); 69 | 70 | delay(120); 71 | writecommand(TFT_DISPON); 72 | 73 | delay(25); 74 | // End of RM68140 display configuration 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9486_Init.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that initialises the ILI9486 driver 3 | // 4 | // This setup information uses simple 8 bit SPI writecommand() and writedata() functions 5 | // 6 | // See ST7735_Setup.h file for an alternative format 7 | 8 | { 9 | // From https://github.com/notro/fbtft/blob/master/fb_ili9486.c 10 | 11 | //writecommand(0x01); // SW reset 12 | //delay(120); 13 | 14 | writecommand(0x11); // Sleep out, also SW reset 15 | delay(120); 16 | 17 | writecommand(0x3A); 18 | writedata(0x55); 19 | 20 | writecommand(0xC2); 21 | writedata(0x44); 22 | 23 | writecommand(0xC5); 24 | writedata(0x00); 25 | writedata(0x00); 26 | writedata(0x00); 27 | writedata(0x00); 28 | 29 | writecommand(0xE0); 30 | writedata(0x0F); 31 | writedata(0x1F); 32 | writedata(0x1C); 33 | writedata(0x0C); 34 | writedata(0x0F); 35 | writedata(0x08); 36 | writedata(0x48); 37 | writedata(0x98); 38 | writedata(0x37); 39 | writedata(0x0A); 40 | writedata(0x13); 41 | writedata(0x04); 42 | writedata(0x11); 43 | writedata(0x0D); 44 | writedata(0x00); 45 | 46 | writecommand(0xE1); 47 | writedata(0x0F); 48 | writedata(0x32); 49 | writedata(0x2E); 50 | writedata(0x0B); 51 | writedata(0x0D); 52 | writedata(0x05); 53 | writedata(0x47); 54 | writedata(0x75); 55 | writedata(0x37); 56 | writedata(0x06); 57 | writedata(0x10); 58 | writedata(0x03); 59 | writedata(0x24); 60 | writedata(0x20); 61 | writedata(0x00); 62 | 63 | writecommand(0x20); // display inversion OFF 64 | 65 | writecommand(0x36); 66 | writedata(0x48); 67 | 68 | writecommand(0x29); // display on 69 | delay(150); 70 | } 71 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/R61581_Init.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that initialises the R61581 driver 3 | // 4 | // This setup information uses simple 8 bit SPI writecommand() and writedata() functions 5 | // 6 | // See ST7735_Setup.h file for an alternative format 7 | 8 | 9 | // Configure R61581 display 10 | 11 | writecommand(TFT_SLPOUT); 12 | delay(20); 13 | 14 | writecommand(0xB0); 15 | writedata(0x00); 16 | 17 | writecommand(0xD0); 18 | writedata(0x07); 19 | writedata(0x42); 20 | writedata(0x18); 21 | 22 | writecommand(0xD1); 23 | writedata(0x00); 24 | writedata(0x07); 25 | writedata(0x10); 26 | 27 | writecommand(0xD2); 28 | writedata(0x01); 29 | writedata(0x02); 30 | 31 | writecommand(0xC0); 32 | writedata(0x12); 33 | writedata(0x3B); 34 | writedata(0x00); 35 | writedata(0x02); 36 | writedata(0x11); 37 | 38 | writecommand(0xC5); 39 | writedata(0x03); 40 | 41 | writecommand(0xC8); 42 | writedata(0x00); 43 | writedata(0x32); 44 | writedata(0x36); 45 | writedata(0x45); 46 | writedata(0x06); 47 | writedata(0x16); 48 | writedata(0x37); 49 | writedata(0x75); 50 | writedata(0x77); 51 | writedata(0x54); 52 | writedata(0x0C); 53 | writedata(0x00); 54 | 55 | writecommand(TFT_MADCTL); 56 | writedata(0x0A); 57 | 58 | writecommand(0x3A); 59 | writedata(0x55); 60 | 61 | writecommand(TFT_CASET); 62 | writedata(0x00); 63 | writedata(0x00); 64 | writedata(0x01); 65 | writedata(0x3F); 66 | 67 | writecommand(TFT_PASET); 68 | writedata(0x00); 69 | writedata(0x00); 70 | writedata(0x01); 71 | writedata(0xDF); 72 | 73 | delay(120); 74 | writecommand(TFT_DISPON); 75 | 76 | delay(25); 77 | // End of R61581 display configuration 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup26_TTGO_T_Wristband.h: -------------------------------------------------------------------------------- 1 | #define ST7735_DRIVER 2 | 3 | #define TFT_WIDTH 80 4 | #define TFT_HEIGHT 160 5 | 6 | 7 | #define TFT_RST 26 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 8 | #define TFT_MISO -1 9 | #define TFT_MOSI 19 10 | #define TFT_SCLK 18 11 | #define TFT_CS 5 12 | #define TFT_DC 23 13 | #define TFT_BL 27 // Dispaly backlight control pin 14 | 15 | #define TFT_BACKLIGHT_ON HIGH // HIGH or LOW are options 16 | 17 | #define ST7735_GREENTAB160x80 // For 160 x 80 display (BGR, inverted, 26 offset) 18 | 19 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 20 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 21 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 22 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 23 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 24 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 25 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT 26 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 27 | 28 | // Comment out the #define below to stop the SPIFFS filing system and smooth font code being loaded 29 | // this will save ~20kbytes of FLASH 30 | #define SMOOTH_FONT 31 | 32 | #define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3 33 | 34 | // #define SPI_FREQUENCY 40000000 // Maximum to use SPIFFS 35 | // #define SPI_FREQUENCY 80000000 36 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/480 x 320/Touch_Controller_Demo/Touch_Controller_Demo.ino: -------------------------------------------------------------------------------- 1 | #include "FS.h" 2 | #include 3 | #include 4 | TFT_eSPI tft = TFT_eSPI(); 5 | 6 | #define CALIBRATION_FILE "/calibrationData" 7 | 8 | void setup(void) { 9 | uint16_t calibrationData[5]; 10 | uint8_t calDataOK = 0; 11 | 12 | Serial.begin(115200); 13 | Serial.println("starting"); 14 | 15 | tft.init(); 16 | 17 | tft.setRotation(3); 18 | tft.fillScreen((0xFFFF)); 19 | 20 | tft.setCursor(20, 0, 2); 21 | tft.setTextColor(TFT_BLACK, TFT_WHITE); tft.setTextSize(1); 22 | tft.println("calibration run"); 23 | 24 | // check file system 25 | if (!SPIFFS.begin()) { 26 | Serial.println("formating file system"); 27 | 28 | SPIFFS.format(); 29 | SPIFFS.begin(); 30 | } 31 | 32 | // check if calibration file exists 33 | if (SPIFFS.exists(CALIBRATION_FILE)) { 34 | File f = SPIFFS.open(CALIBRATION_FILE, "r"); 35 | if (f) { 36 | if (f.readBytes((char *)calibrationData, 14) == 14) 37 | calDataOK = 1; 38 | f.close(); 39 | } 40 | } 41 | if (calDataOK) { 42 | // calibration data valid 43 | tft.setTouch(calibrationData); 44 | } else { 45 | // data not valid. recalibrate 46 | tft.calibrateTouch(calibrationData, TFT_WHITE, TFT_RED, 15); 47 | // store data 48 | File f = SPIFFS.open(CALIBRATION_FILE, "w"); 49 | if (f) { 50 | f.write((const unsigned char *)calibrationData, 14); 51 | f.close(); 52 | } 53 | } 54 | 55 | tft.fillScreen((0xFFFF)); 56 | 57 | } 58 | 59 | void loop() { 60 | uint16_t x, y; 61 | static uint16_t color; 62 | 63 | if (tft.getTouch(&x, &y)) { 64 | 65 | tft.setCursor(5, 5, 2); 66 | tft.printf("x: %i ", x); 67 | tft.setCursor(5, 20, 2); 68 | tft.printf("y: %i ", y); 69 | 70 | tft.drawPixel(x, y, color); 71 | color += 155; 72 | } 73 | } 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /TFT_eSPI/Fonts/GFXFF/print.txt: -------------------------------------------------------------------------------- 1 | #define TT1 TomThumb 2 | 3 | #define FF1 FreeMono9pt7b 4 | #define FF2 FreeMono12pt7b 5 | #define FF3 FreeMono18pt7b 6 | #define FF4 FreeMono24pt7b 7 | 8 | #define FF5 FreeMonoBold9pt7b 9 | #define FF6 FreeMonoBold12pt7b 10 | #define FF7 FreeMonoBold18pt7b 11 | #define FF8 FreeMonoBold24pt7b 12 | 13 | #define FF9 FreeMonoBoldOblique9pt7b 14 | #define FF10 FreeMonoBoldOblique12pt7b 15 | #define FF11 FreeMonoBoldOblique18pt7b 16 | #define FF12 FreeMonoBoldOblique24pt7b 17 | 18 | #define FF13 FreeMonoOblique9pt7b 19 | #define FF14 FreeMonoOblique12pt7b 20 | #define FF15 FreeMonoOblique18pt7b 21 | #define FF16 FreeMonoOblique24pt7b 22 | 23 | #define FF17 FreeSans9pt7b 24 | #define FF18 FreeSans12pt7b 25 | #define FF19 FreeSans18pt7b 26 | #define FF20 FreeSans24pt7b 27 | 28 | #define FF21 FreeSansBold9pt7b 29 | #define FF22 FreeSansBold12pt7b 30 | #define FF23 FreeSansBold18pt7b 31 | #define FF24 FreeSansBold24pt7b 32 | 33 | #define FF25 FreeSansBoldOblique9pt7b 34 | #define FF26 FreeSansBoldOblique12pt7b 35 | #define FF27 FreeSansBoldOblique18pt7b 36 | #define FF28 FreeSansBoldOblique24pt7b 37 | 38 | #define FF29 FreeSansOblique9pt7b 39 | #define FF30 FreeSansOblique12pt7b 40 | #define FF31 FreeSansOblique18pt7b 41 | #define FF32 FreeSansOblique24pt7b 42 | 43 | #define FF33 FreeSerif9pt7b 44 | #define FF34 FreeSerif12pt7b 45 | #define FF35 FreeSerif18pt7b 46 | #define FF36 FreeSerif24pt7b 47 | 48 | #define FF37 FreeSerifBold9pt7b 49 | #define FF38 FreeSerifBold12pt7b 50 | #define FF39 FreeSerifBold18pt7b 51 | #define FF40 FreeSerifBold24pt7b 52 | 53 | #define FF41 FreeSerifBoldItalic9pt7b 54 | #define FF42 FreeSerifBoldItalic12pt7b 55 | #define FF43 FreeSerifBoldItalic18pt7b 56 | #define FF44 FreeSerifBoldItalic24pt7b 57 | 58 | #define FF45 FreeSerifItalic9pt7b 59 | #define FF46 FreeSerifItalic12pt7b 60 | #define FF47 FreeSerifItalic18pt7b 61 | #define FF48 FreeSerifItalic24pt7b 62 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/User_Custom_Fonts.h: -------------------------------------------------------------------------------- 1 | 2 | // Custom "Adafruit" compatible font files can be added to the "TFT_eSPI/Fonts/Custom" folder 3 | // Fonts in a suitable format can be created using a Squix blog web based tool here: 4 | /* 5 | https://blog.squix.org/2016/10/font-creator-now-creates-adafruit-gfx-fonts.html 6 | */ 7 | 8 | // Note: At the time of writing there is a last character code definition bug in the 9 | // Squix font file format so do NOT try and print the tilda (~) symbol (ASCII 0x7E) 10 | // Alternatively look at the end of the font header file and edit: 0x7E to read 0x7D 11 | /* e.g. vvvv 12 | (uint8_t *)Orbitron_Light_32Bitmaps,(GFXglyph *)Orbitron_Light_32Glyphs,0x20, 0x7D, 32}; 13 | ^^^^ 14 | */ 15 | 16 | // When font files are placed in the Custom folder (TFT_eSPI\Fonts\Custom) then they must 17 | // also be #included here: 18 | 19 | // The CF_OL24 etc are a shorthand reference, but this is not essential to use the fonts 20 | 21 | #ifdef LOAD_GFXFF 22 | 23 | // New custom font file #includes 24 | #include // CF_OL24 25 | #include // CF_OL32 26 | #include // CF_RT24 27 | #include // CF_S24 28 | #include // CF_Y32 29 | 30 | #endif 31 | 32 | // Shorthand references - any coding scheme can be used, here CF_ = Custom Font 33 | // The #defines below MUST be added to sketches to use shorthand references, so 34 | // they are only put here for reference and copy+paste purposes! 35 | /* 36 | #define CF_OL24 &Orbitron_Light_24 37 | #define CF_OL32 &Orbitron_Light_32 38 | #define CF_RT24 &Roboto_Thin_24 39 | #define CF_S24 &Satisfy_24 40 | #define CF_Y32 &Yellowtail_32 41 | */ 42 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ST7789_Rotation.h: -------------------------------------------------------------------------------- 1 | // This is the command sequence that rotates the ST7789 driver coordinate frame 2 | 3 | writecommand(TFT_MADCTL); 4 | rotation = m % 4; 5 | switch (rotation) { 6 | case 0: // Portrait 7 | #ifdef CGRAM_OFFSET 8 | if (_init_width == 135) 9 | { 10 | colstart = 52; 11 | rowstart = 40; 12 | } 13 | else 14 | { 15 | colstart = 0; 16 | rowstart = 0; 17 | } 18 | #endif 19 | writedata(TFT_MAD_COLOR_ORDER); 20 | 21 | _width = _init_width; 22 | _height = _init_height; 23 | break; 24 | 25 | case 1: // Landscape (Portrait + 90) 26 | #ifdef CGRAM_OFFSET 27 | if (_init_width == 135) 28 | { 29 | colstart = 40; 30 | rowstart = 53; 31 | } 32 | else 33 | { 34 | colstart = 0; 35 | rowstart = 0; 36 | } 37 | #endif 38 | writedata(TFT_MAD_MX | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 39 | 40 | _width = _init_height; 41 | _height = _init_width; 42 | break; 43 | 44 | case 2: // Inverter portrait 45 | #ifdef CGRAM_OFFSET 46 | if (_init_width == 135) 47 | { 48 | colstart = 53; 49 | rowstart = 40; 50 | } 51 | else 52 | { 53 | colstart = 0; 54 | rowstart = 80; 55 | } 56 | #endif 57 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 58 | 59 | _width = _init_width; 60 | _height = _init_height; 61 | break; 62 | case 3: // Inverted landscape 63 | #ifdef CGRAM_OFFSET 64 | if (_init_width == 135) 65 | { 66 | colstart = 40; 67 | rowstart = 52; 68 | } 69 | else 70 | { 71 | colstart = 80; 72 | rowstart = 0; 73 | } 74 | #endif 75 | writedata(TFT_MAD_MV | TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 76 | 77 | _width = _init_height; 78 | _height = _init_width; 79 | break; 80 | } 81 | -------------------------------------------------------------------------------- /TFT_eSPI/Extensions/Button.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************************** 2 | // The following button class has been ported over from the Adafruit_GFX library so 3 | // should be compatible. 4 | // A slightly different implementation in this TFT_eSPI library allows the button 5 | // legends to be in any font, allow longer labels and to adjust text positioning 6 | // within button 7 | ***************************************************************************************/ 8 | 9 | class TFT_eSPI_Button { 10 | 11 | public: 12 | TFT_eSPI_Button(void); 13 | // "Classic" initButton() uses center & size 14 | void initButton(TFT_eSPI *gfx, int16_t x, int16_t y, 15 | uint16_t w, uint16_t h, uint16_t outline, uint16_t fill, 16 | uint16_t textcolor, char *label, uint8_t textsize); 17 | 18 | // New/alt initButton() uses upper-left corner & size 19 | void initButtonUL(TFT_eSPI *gfx, int16_t x1, int16_t y1, 20 | uint16_t w, uint16_t h, uint16_t outline, uint16_t fill, 21 | uint16_t textcolor, char *label, uint8_t textsize); 22 | 23 | // Adjust text datum and x, y deltas 24 | void setLabelDatum(int16_t x_delta, int16_t y_delta, uint8_t datum = MC_DATUM); 25 | 26 | void drawButton(bool inverted = false, String long_name = ""); 27 | bool contains(int16_t x, int16_t y); 28 | 29 | void press(bool p); 30 | bool isPressed(); 31 | bool justPressed(); 32 | bool justReleased(); 33 | 34 | private: 35 | TFT_eSPI *_gfx; 36 | int16_t _x1, _y1; // Coordinates of top-left corner of button 37 | int16_t _xd, _yd; // Button text datum offsets (wrt center of button) 38 | uint16_t _w, _h; // Width and height of button 39 | uint8_t _textsize, _textdatum; // Text size multiplier and text datum for button 40 | uint16_t _outlinecolor, _fillcolor, _textcolor; 41 | char _label[10]; // Button text is 9 chars maximum unless long_name used 42 | 43 | bool currstate, laststate; // Button states 44 | }; 45 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/drawXBitmap/drawXBitmap.ino: -------------------------------------------------------------------------------- 1 | // Example sketch to demonstrate the drawing of X BitMap (XBM) 2 | // format image onto the display. 3 | 4 | // Information on the X BitMap (XBM) format can be found here: 5 | // https://en.wikipedia.org/wiki/X_BitMap 6 | 7 | // This example is part of the TFT_eSPI library: 8 | // https://github.com/Bodmer/TFT_eSPI 9 | 10 | // Created by Bodmer 23/04/18 11 | 12 | #include "xbm.h" // Sketch tab header for xbm images 13 | 14 | #include // Hardware-specific library 15 | 16 | TFT_eSPI tft = TFT_eSPI(); // Invoke library 17 | 18 | 19 | void setup() 20 | { 21 | tft.begin(); // Initialise the display 22 | tft.fillScreen(TFT_BLACK); // Black screen fill 23 | } 24 | 25 | void loop() 26 | { 27 | 28 | // Example 1 29 | // ========= 30 | // Random x and y coordinates 31 | int x = random(tft.width() - logoWidth); 32 | int y = random(tft.height() - logoHeight); 33 | 34 | // Draw bitmap with top left corner at x,y with foreground only color 35 | // Bits set to 1 plot as the defined color, bits set to 0 are not plotted 36 | // x y xbm xbm width xbm height color 37 | tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_WHITE); 38 | 39 | delay(500); 40 | 41 | // Erase old one by drawing over with background colour 42 | tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_BLACK); 43 | 44 | 45 | // Example 2 46 | // ========= 47 | // New random x and y coordinates 48 | x = random(tft.width() - logoWidth); 49 | y = random(tft.height() - logoHeight); 50 | 51 | // Draw bitmap with top left corner at x,y with foreground and background colors 52 | // Bits set to 1 plot as the defined fg color, bits set to 0 are plotted as bg color 53 | // x y xbm xbm width xbm height fg color bg color 54 | tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_WHITE, TFT_RED); 55 | 56 | delay(500); 57 | 58 | // Erase old one by drawing over with background colour 59 | tft.drawXBitmap(x, y, logo, logoWidth, logoHeight, TFT_BLACK, TFT_BLACK); 60 | 61 | } 62 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup43_ST7735.h: -------------------------------------------------------------------------------- 1 | // Setup for ESP32 and ST7735 80 x 160 TFT 2 | 3 | // See SetupX_Template.h for all options available 4 | 5 | #define ST7735_DRIVER 6 | 7 | 8 | #define TFT_WIDTH 80 9 | #define TFT_HEIGHT 160 10 | 11 | 12 | #define ST7735_GREENTAB160x80 13 | 14 | #ifdef ESP32 15 | #define TFT_MISO 19 16 | #define TFT_MOSI 23 17 | #define TFT_SCLK 18 18 | #define TFT_CS 15 // Chip select control pin 19 | #define TFT_DC 2 // Data Command control pin 20 | #define TFT_RST 4 // Reset pin (could connect to RST pin) 21 | //#define TFT_RST -1 // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST 22 | #else 23 | // Display GND to NodeMCU pin GND (0V) 24 | // Display VCC to NodeMCU 5V or 3.3V 25 | // Display SCK to NodeMCU pin D5 26 | // Display SDI/MOSI to NodeMCU pin D7 27 | // Display BLK to NodeMCU pin VIN 28 | #define TFT_CS PIN_D8 // Chip select control pin D8 29 | #define TFT_DC PIN_D3 // Data Command control pin 30 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 31 | #endif 32 | 33 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 34 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 35 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 36 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 37 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 38 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 39 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT 40 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 41 | 42 | #define SMOOTH_FONT 43 | 44 | 45 | //#define SPI_FREQUENCY 20000000 46 | #define SPI_FREQUENCY 27000000 // Actually sets it to 26.67MHz = 80/3 47 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup9_ST7735_Overlap.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ST7735_DRIVER 4 | 5 | 6 | #define TFT_WIDTH 128 7 | #define TFT_HEIGHT 160 8 | 9 | 10 | #define ST7735_REDTAB 11 | 12 | // Overlap mode shares the ESP8266 FLASH SPI bus with the TFT so has a performance impact 13 | // but saves pins for other functions. It is best not to connect MISO as some displays 14 | // do not tristate that line wjen chip select is high! 15 | // On NodeMCU 1.0 SD0=MISO, SD1=MOSI, CLK=SCLK to connect to TFT in overlap mode 16 | // On NodeMCU V3 S0 =MISO, S1 =MOSI, S2 =SCLK 17 | // In ESP8266 overlap mode the following must be defined 18 | #define TFT_SPI_OVERLAP 19 | 20 | // In ESP8266 overlap mode the TFT chip select MUST connect to pin D3 21 | #define TFT_CS PIN_D3 22 | #define TFT_DC PIN_D5 // Data Command control pin 23 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 24 | //#define TFT_RST -1 // Set TFT_RST to -1 if the display RESET is connected to NodeMCU RST or 3.3V 25 | 26 | 27 | 28 | 29 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 30 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 31 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 32 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 33 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 34 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 35 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT 36 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 37 | 38 | #define SMOOTH_FONT 39 | 40 | 41 | // #define SPI_FREQUENCY 20000000 42 | #define SPI_FREQUENCY 27000000 43 | 44 | #define SPI_TOUCH_FREQUENCY 2500000 45 | 46 | 47 | // #define SUPPORT_TRANSACTIONS 48 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup18_ST7789.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define ST7789_DRIVER 4 | 5 | // #define TFT_SDA_READ // This option is for ESP32 ONLY, tested with ST7789 display only 6 | 7 | // If colours are inverted (white shows as black) then uncomment one of the next 8 | // 2 lines try both options, one of the options should correct the inversion. 9 | // #define TFT_INVERSION_ON 10 | // #define TFT_INVERSION_OFF 11 | 12 | // For ST7789 ONLY, define the colour order IF the blue and red are swapped on your display 13 | // Try ONE option at a time to find the correct colour order for your display 14 | // #define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue 15 | // #define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red 16 | 17 | 18 | // My ST7789 display has TCT_CS wired permananently low so the pin is not defined here 19 | 20 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 21 | #define TFT_DC PIN_D3 // Data Command control pin 22 | #define TFT_RST PIN_D4 // Reset pin (could connect to NodeMCU RST, see next line) 23 | 24 | 25 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 26 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 27 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 28 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 29 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-. 30 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 31 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 32 | 33 | #define SMOOTH_FONT 34 | 35 | 36 | // #define SPI_FREQUENCY 20000000 37 | #define SPI_FREQUENCY 27000000 38 | // #define SPI_FREQUENCY 40000000 39 | // #define SPI_FREQUENCY 80000000 40 | 41 | #define SPI_TOUCH_FREQUENCY 2500000 42 | 43 | 44 | //#define SUPPORT_TRANSACTIONS 45 | -------------------------------------------------------------------------------- /TFT_eSPI/Extensions/Touch.h: -------------------------------------------------------------------------------- 1 | // Coded by Bodmer 10/2/18, see license in root directory. 2 | // This is part of the TFT_eSPI class and is associated with the Touch Screen handlers 3 | 4 | public: 5 | // Get raw x,y ADC values from touch controller 6 | uint8_t getTouchRaw(uint16_t *x, uint16_t *y); 7 | // Get raw z (i.e. pressure) ADC value from touch controller 8 | uint16_t getTouchRawZ(void); 9 | // Convert raw x,y values to calibrated and correctly rotated screen coordinates 10 | void convertRawXY(uint16_t *x, uint16_t *y); 11 | // Get the screen touch coordinates, returns true if screen has been touched 12 | // if the touch cordinates are off screen then x and y are not updated 13 | uint8_t getTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600); 14 | 15 | // Run screen calibration and test, report calibration values to the serial port 16 | void calibrateTouch(uint16_t *data, uint32_t color_fg, uint32_t color_bg, uint8_t size); 17 | // Set the screen calibration values 18 | void setTouch(uint16_t *data); 19 | 20 | private: 21 | // Legacy support only - deprecated TODO: delete 22 | void spi_begin_touch(); 23 | void spi_end_touch(); 24 | 25 | // Handlers for the touch controller bus settings 26 | inline void begin_touch_read_write() __attribute__((always_inline)); 27 | inline void end_touch_read_write() __attribute__((always_inline)); 28 | 29 | // Private function to validate a touch, allow settle time and reduce spurious coordinates 30 | uint8_t validTouch(uint16_t *x, uint16_t *y, uint16_t threshold = 600); 31 | 32 | // Initialise with example calibration values so processor does not crash if setTouch() not called in setup() 33 | uint16_t touchCalibration_x0 = 300, touchCalibration_x1 = 3600, touchCalibration_y0 = 300, touchCalibration_y1 = 3600; 34 | uint8_t touchCalibration_rotate = 1, touchCalibration_invert_x = 2, touchCalibration_invert_y = 0; 35 | 36 | uint32_t _pressTime; // Press and hold time-out 37 | uint16_t _pressX, _pressY; // For future use (last sampled calibrated coordinates) 38 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/S6D02A1_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #define TFT_WIDTH 128 4 | #define TFT_HEIGHT 160 5 | 6 | 7 | // Color definitions for backwards compatibility with old sketches 8 | // use colour definitions like TFT_BLACK to make sketches more portable 9 | #define S6D02A1_BLACK 0x0000 /* 0, 0, 0 */ 10 | #define S6D02A1_NAVY 0x000F /* 0, 0, 128 */ 11 | #define S6D02A1_DARKGREEN 0x03E0 /* 0, 128, 0 */ 12 | #define S6D02A1_DARKCYAN 0x03EF /* 0, 128, 128 */ 13 | #define S6D02A1_MAROON 0x7800 /* 128, 0, 0 */ 14 | #define S6D02A1_PURPLE 0x780F /* 128, 0, 128 */ 15 | #define S6D02A1_OLIVE 0x7BE0 /* 128, 128, 0 */ 16 | #define S6D02A1_LIGHTGREY 0xC618 /* 192, 192, 192 */ 17 | #define S6D02A1_DARKGREY 0x7BEF /* 128, 128, 128 */ 18 | #define S6D02A1_BLUE 0x001F /* 0, 0, 255 */ 19 | #define S6D02A1_GREEN 0x07E0 /* 0, 255, 0 */ 20 | #define S6D02A1_CYAN 0x07FF /* 0, 255, 255 */ 21 | #define S6D02A1_RED 0xF800 /* 255, 0, 0 */ 22 | #define S6D02A1_MAGENTA 0xF81F /* 255, 0, 255 */ 23 | #define S6D02A1_YELLOW 0xFFE0 /* 255, 255, 0 */ 24 | #define S6D02A1_WHITE 0xFFFF /* 255, 255, 255 */ 25 | #define S6D02A1_ORANGE 0xFD20 /* 255, 165, 0 */ 26 | #define S6D02A1_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ 27 | #define S6D02A1_PINK 0xF81F 28 | 29 | 30 | // Delay between some initialisation commands 31 | #define TFT_INIT_DELAY 0x80 32 | 33 | 34 | // Generic commands used by TFT_eSPI.cpp 35 | #define TFT_NOP 0x00 36 | #define TFT_SWRST 0x01 37 | 38 | #define TFT_CASET 0x2A 39 | #define TFT_PASET 0x2B 40 | #define TFT_RAMWR 0x2C 41 | 42 | #define TFT_RAMRD 0x2E 43 | #define TFT_IDXRD 0x00 //0xDD // ILI9341 only, indexed control register read 44 | 45 | #define TFT_MADCTL 0x36 46 | #define TFT_MAD_MY 0x80 47 | #define TFT_MAD_MX 0x40 48 | #define TFT_MAD_MV 0x20 49 | #define TFT_MAD_ML 0x10 50 | #define TFT_MAD_BGR 0x08 51 | #define TFT_MAD_MH 0x04 52 | #define TFT_MAD_RGB 0x00 53 | 54 | #define TFT_INVOFF 0x20 55 | #define TFT_INVON 0x21 56 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/HX8357D_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #define TFT_WIDTH 320 4 | #define TFT_HEIGHT 480 5 | 6 | 7 | // Delay between some initialisation commands 8 | #define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked 9 | 10 | 11 | // Generic commands used by TFT_eSPar.cpp 12 | #define TFT_NOP 0x00 13 | #define TFT_SWRST 0x01 14 | 15 | #define TFT_SLPIN 0x10 16 | #define TFT_SLPOUT 0x11 17 | 18 | #define TFT_INVOFF 0x20 19 | #define TFT_INVON 0x21 20 | 21 | #define TFT_DISPOFF 0x28 22 | #define TFT_DISPON 0x29 23 | 24 | #define TFT_CASET 0x2A 25 | #define TFT_PASET 0x2B 26 | #define TFT_RAMWR 0x2C 27 | 28 | #define TFT_RAMRD 0x2E 29 | 30 | #define TFT_MADCTL 0x36 31 | 32 | #define TFT_MAD_MY 0x80 33 | #define TFT_MAD_MX 0x40 34 | #define TFT_MAD_MV 0x20 35 | #define TFT_MAD_ML 0x10 36 | #define TFT_MAD_RGB 0x00 37 | #define TFT_MAD_BGR 0x08 38 | #define TFT_MAD_MH 0x04 39 | #define TFT_MAD_SS 0x02 40 | #define TFT_MAD_GS 0x01 41 | 42 | #define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read 43 | 44 | 45 | #define HX8357_NOP 0x00 46 | #define HX8357_SWRESET 0x01 47 | #define HX8357_RDDID 0x04 48 | #define HX8357_RDDST 0x09 49 | 50 | #define HX8357_RDPOWMODE 0x0A 51 | #define HX8357_RDMADCTL 0x0B 52 | #define HX8357_RDCOLMOD 0x0C 53 | #define HX8357_RDDIM 0x0D 54 | #define HX8357_RDDSDR 0x0F 55 | 56 | #define HX8357_SLPIN 0x10 57 | #define HX8357_SLPOUT 0x11 58 | 59 | #define HX8357_INVOFF 0x20 60 | #define HX8357_INVON 0x21 61 | #define HX8357_DISPOFF 0x28 62 | #define HX8357_DISPON 0x29 63 | 64 | #define HX8357_CASET 0x2A 65 | #define HX8357_PASET 0x2B 66 | #define HX8357_RAMWR 0x2C 67 | #define HX8357_RAMRD 0x2E 68 | 69 | #define HX8357_TEON 0x35 70 | #define HX8357_TEARLINE 0x44 71 | #define HX8357_MADCTL 0x36 72 | #define HX8357_COLMOD 0x3A 73 | 74 | #define HX8357_SETOSC 0xB0 75 | #define HX8357_SETPWR1 0xB1 76 | #define HX8357_SETRGB 0xB3 77 | #define HX8357D_SETCOM 0xB6 78 | 79 | #define HX8357D_SETCYC 0xB4 80 | #define HX8357D_SETC 0xB9 81 | 82 | #define HX8357D_SETSTBA 0xC0 83 | 84 | #define HX8357_SETPANEL 0xCC 85 | 86 | #define HX8357D_SETGAMMA 0xE0 87 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup30_ILI9341_Parallel_STM32.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Setup for Nucleo 64 or 144 and ILI9341 display // 3 | //////////////////////////////////////////////////// 4 | 5 | // See SetupX_Template.h for all options available 6 | 7 | // Define STM32 to invoke optimised processor support 8 | #define STM32 9 | 10 | // Defining the board allows the library to optimise the performance 11 | // for UNO compatible "MCUfriend" style shields 12 | #define NUCLEO_64_TFT 13 | //#define NUCLEO_144_TFT 14 | 15 | // Tell the library to use 8 bit parallel mode (otherwise SPI is assumed) 16 | #define TFT_PARALLEL_8_BIT 17 | 18 | // Define the display driver chip type 19 | #define ILI9341_DRIVER 20 | //#define ILI9481_DRIVER 21 | 22 | // Define the Nucleo 64/144 pins used for the parallel interface TFT 23 | // The pins can be changed here but these are the ones used by the 24 | // common "MCUfriend" shields 25 | #define TFT_CS A3 // Chip select control pin 26 | #define TFT_DC A2 // Data Command control pin 27 | #define TFT_RST A4 // Reset pin 28 | 29 | #define TFT_WR A1 // Write strobe control pin 30 | #define TFT_RD A0 // Read pin 31 | 32 | #define TFT_D0 D8 // 8 bit parallel bus to TFT 33 | #define TFT_D1 D9 34 | #define TFT_D2 D2 35 | #define TFT_D3 D3 36 | #define TFT_D4 D4 37 | #define TFT_D5 D5 38 | #define TFT_D6 D6 39 | #define TFT_D7 D7 40 | 41 | // Fonts to be available 42 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 43 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 44 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 45 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 46 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 47 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 48 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 49 | 50 | // STM32 support for smooth fonts via program memory (FLASH) arrays 51 | #define SMOOTH_FONT 52 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup31_ST7796_Parallel_STM32.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Setup for Nucleo 64 or 144 and ILI9341 display // 3 | //////////////////////////////////////////////////// 4 | 5 | 6 | // See SetupX_Template.h for all options available 7 | 8 | // Define STM32 to invoke optimised processor support 9 | #define STM32 10 | 11 | // Defining the board allows the library to optimise the performance 12 | // for UNO compatible "MCUfriend" style shields 13 | #define NUCLEO_64_TFT 14 | //#define NUCLEO_144_TFT 15 | 16 | // Tell the library to use 8 bit parallel mode(otherwise SPI is assumed) 17 | #define TFT_PARALLEL_8_BIT 18 | 19 | // Define the display driver chip type 20 | #define ST7796_DRIVER 21 | //#define ILI9481_DRIVER 22 | 23 | // Define the Nucleo 64/144 pins used for the parallel interface TFT 24 | // The pins can be changed here but these are the ones used by the 25 | // common "MCUfriend" shields 26 | #define TFT_CS A3 // Chip select control pin 27 | #define TFT_DC A2 // Data Command control pin 28 | #define TFT_RST A4 // Reset pin 29 | 30 | #define TFT_WR A1 // Write strobe control pin 31 | #define TFT_RD A0 // Read pin 32 | 33 | #define TFT_D0 D8 // 8 bit parallel bus to TFT 34 | #define TFT_D1 D9 35 | #define TFT_D2 D2 36 | #define TFT_D3 D3 37 | #define TFT_D4 D4 38 | #define TFT_D5 D5 39 | #define TFT_D6 D6 40 | #define TFT_D7 D7 41 | 42 | // Fonts to be available 43 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 44 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 45 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 46 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 47 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 48 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 49 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 50 | 51 | // STM32 support for smooth fonts via program memory (FLASH) arrays 52 | #define SMOOTH_FONT 53 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup34_ILI9481_Parallel_STM32.h: -------------------------------------------------------------------------------- 1 | //////////////////////////////////////////////////// 2 | // Setup for Nucleo 64 or 144 and ILI9341 display // 3 | //////////////////////////////////////////////////// 4 | 5 | // See SetupX_Template.h for all options available 6 | 7 | // Define STM32 to invoke optimised processor support 8 | #define STM32 9 | 10 | // Defining the board allows the library to optimise the performance 11 | // for UNO compatible "MCUfriend" style shields 12 | #define NUCLEO_64_TFT 13 | //#define NUCLEO_144_TFT 14 | 15 | // Tell the library to use 8 bit parallel mode (otherwise SPI is assumed) 16 | #define TFT_PARALLEL_8_BIT 17 | 18 | // Define the display driver chip type 19 | //#define ILI9341_DRIVER 20 | #define ILI9481_DRIVER 21 | 22 | // Define the Nucleo 64/144 pins used for the parallel interface TFT 23 | // The pins can be changed here but these are the ones used by the 24 | // common "MCUfriend" shields 25 | #define TFT_CS A3 // Chip select control pin 26 | #define TFT_DC A2 // Data Command control pin 27 | #define TFT_RST A4 // Reset pin 28 | 29 | #define TFT_WR A1 // Write strobe control pin 30 | #define TFT_RD A0 // Read pin 31 | 32 | #define TFT_D0 D8 // 8 bit parallel bus to TFT 33 | #define TFT_D1 D9 34 | #define TFT_D2 D2 35 | #define TFT_D3 D3 36 | #define TFT_D4 D4 37 | #define TFT_D5 D5 38 | #define TFT_D6 D6 39 | #define TFT_D7 D7 40 | 41 | // Fonts to be available 42 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 43 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 44 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 45 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 46 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 47 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 48 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 49 | 50 | // STM32 support for smooth fonts via program memory (FLASH) arrays 51 | #define SMOOTH_FONT 52 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup24_ST7789.h: -------------------------------------------------------------------------------- 1 | // ST7789 240 x 240 display with no chip select line 2 | 3 | #define ST7789_DRIVER // Configure all registers 4 | 5 | #define TFT_WIDTH 240 6 | #define TFT_HEIGHT 240 7 | 8 | //#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue 9 | //#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red 10 | 11 | //#define TFT_INVERSION_ON 12 | //#define TFT_INVERSION_OFF 13 | 14 | // DSTIKE stepup 15 | //#define TFT_DC 23 16 | //#define TFT_RST 32 17 | //#define TFT_MOSI 26 18 | //#define TFT_SCLK 27 19 | 20 | // Generic ESP32 setup 21 | //#define TFT_MISO 19 22 | //#define TFT_MOSI 23 23 | //#define TFT_SCLK 18 24 | //#define TFT_CS -1 // Not connected 25 | //#define TFT_DC 2 26 | //#define TFT_RST 4 // Connect reset to ensure display initialises 27 | 28 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 29 | #define TFT_CS -1 // Define as not used 30 | #define TFT_DC PIN_D1 // Data Command control pin 31 | #define TFT_RST PIN_D4 // TFT reset pin (could connect to NodeMCU RST, see next line) 32 | //#define TFT_RST -1 // TFT reset pin connect to NodeMCU RST, must also then add 10K pull down to TFT SCK 33 | 34 | 35 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 36 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 37 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 38 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 39 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 40 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 41 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT 42 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 43 | 44 | #define SMOOTH_FONT 45 | 46 | 47 | // #define SPI_FREQUENCY 27000000 48 | #define SPI_FREQUENCY 40000000 49 | 50 | #define SPI_READ_FREQUENCY 20000000 51 | 52 | #define SPI_TOUCH_FREQUENCY 2500000 53 | 54 | // #define SUPPORT_TRANSACTIONS -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup17_ePaper.h: -------------------------------------------------------------------------------- 1 | // See SetupX_Template.h for all options available 2 | 3 | #define EPD_DRIVER // ePaper driver 4 | 5 | 6 | // READ THIS READ THIS READ THIS READ THIS READ THIS READ THIS 7 | // Install the ePaper library for your own display size and type 8 | // from here: 9 | // https://github.com/Bodmer/EPD_Libraries 10 | 11 | // Note: Pin allocations for the ePaper signals are defined in 12 | // the ePaper library's epdif.h file. There follows the default 13 | // pins already included in epdif.h file for the ESP8266: 14 | 15 | /////////////////////////////////////////////////////////////////// 16 | // For ESP8266 connect as follows: // 17 | // Display 3.3V to NodeMCU 3V3 // 18 | // Display GND to NodeMCU GND // 19 | // // 20 | // Display GPIO NodeMCU pin // 21 | // BUSY 5 D1 // 22 | // RESET 4 D2 // 23 | // DC 0 D3 // 24 | // CS 2 D4 // 25 | // CLK 14 D5 // 26 | // D6 (MISO not connected to display) // 27 | // DIN 13 D7 // 28 | // // 29 | /////////////////////////////////////////////////////////////////// 30 | 31 | 32 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 33 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 34 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 35 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 36 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-. 37 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 38 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 39 | 40 | #define SMOOTH_FONT 41 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup135_ST7789.h: -------------------------------------------------------------------------------- 1 | // ST7789 135 x 240 display with no chip select line 2 | 3 | #define ST7789_DRIVER // Configure all registers 4 | 5 | #define TFT_WIDTH 135 6 | #define TFT_HEIGHT 240 7 | 8 | #define CGRAM_OFFSET // Library will add offsets required 9 | 10 | //#define TFT_RGB_ORDER TFT_RGB // Colour order Red-Green-Blue 11 | //#define TFT_RGB_ORDER TFT_BGR // Colour order Blue-Green-Red 12 | 13 | //#define TFT_INVERSION_ON 14 | //#define TFT_INVERSION_OFF 15 | 16 | // DSTIKE stepup 17 | //#define TFT_DC 23 18 | //#define TFT_RST 32 19 | //#define TFT_MOSI 26 20 | //#define TFT_SCLK 27 21 | 22 | // Generic ESP32 setup 23 | //#define TFT_MISO 19 24 | //#define TFT_MOSI 23 25 | //#define TFT_SCLK 18 26 | //#define TFT_CS -1 // Not connected 27 | //#define TFT_DC 2 28 | //#define TFT_RST 4 // Connect reset to ensure display initialises 29 | 30 | // For NodeMCU - use pin numbers in the form PIN_Dx where Dx is the NodeMCU pin designation 31 | #define TFT_CS -1 // Define as not used 32 | #define TFT_DC PIN_D1 // Data Command control pin 33 | //#define TFT_RST PIN_D4 // TFT reset pin (could connect to NodeMCU RST, see next line) 34 | #define TFT_RST -1 // TFT reset pin connect to NodeMCU RST, must also then add 10K pull down to TFT SCK 35 | 36 | 37 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 38 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 39 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 40 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 41 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:. 42 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 43 | //#define LOAD_FONT8N // Font 8. Alternative to Font 8 above, slightly narrower, so 3 digits fit a 160 pixel TFT 44 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 45 | 46 | #define SMOOTH_FONT 47 | 48 | 49 | // #define SPI_FREQUENCY 27000000 50 | #define SPI_FREQUENCY 40000000 51 | 52 | #define SPI_READ_FREQUENCY 20000000 53 | 54 | #define SPI_TOUCH_FREQUENCY 2500000 55 | 56 | // #define SUPPORT_TRANSACTIONS -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9163_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #ifndef TFT_WIDTH 4 | #define TFT_WIDTH 128 5 | #endif 6 | #ifndef TFT_HEIGHT 7 | #define TFT_HEIGHT 160 8 | #endif 9 | 10 | #if (TFT_HEIGHT == 128) && (TFT_WIDTH == 128) 11 | #define CGRAM_OFFSET 12 | #endif 13 | 14 | // Color definitions for backwards compatibility with old sketches 15 | // use colour definitions like TFT_BLACK to make sketches more portable 16 | #define ILI9163_BLACK 0x0000 /* 0, 0, 0 */ 17 | #define ILI9163_NAVY 0x000F /* 0, 0, 128 */ 18 | #define ILI9163_DARKGREEN 0x03E0 /* 0, 128, 0 */ 19 | #define ILI9163_DARKCYAN 0x03EF /* 0, 128, 128 */ 20 | #define ILI9163_MAROON 0x7800 /* 128, 0, 0 */ 21 | #define ILI9163_PURPLE 0x780F /* 128, 0, 128 */ 22 | #define ILI9163_OLIVE 0x7BE0 /* 128, 128, 0 */ 23 | #define ILI9163_LIGHTGREY 0xC618 /* 192, 192, 192 */ 24 | #define ILI9163_DARKGREY 0x7BEF /* 128, 128, 128 */ 25 | #define ILI9163_BLUE 0x001F /* 0, 0, 255 */ 26 | #define ILI9163_GREEN 0x07E0 /* 0, 255, 0 */ 27 | #define ILI9163_CYAN 0x07FF /* 0, 255, 255 */ 28 | #define ILI9163_RED 0xF800 /* 255, 0, 0 */ 29 | #define ILI9163_MAGENTA 0xF81F /* 255, 0, 255 */ 30 | #define ILI9163_YELLOW 0xFFE0 /* 255, 255, 0 */ 31 | #define ILI9163_WHITE 0xFFFF /* 255, 255, 255 */ 32 | #define ILI9163_ORANGE 0xFD20 /* 255, 165, 0 */ 33 | #define ILI9163_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ 34 | #define ILI9163_PINK 0xF81F 35 | 36 | 37 | // Delay between some initialisation commands 38 | #define TFT_INIT_DELAY 0x80 39 | 40 | 41 | // Generic commands used by TFT_eSPI.cpp 42 | #define TFT_NOP 0x00 43 | #define TFT_SWRST 0x01 44 | 45 | #define TFT_CASET 0x2A 46 | #define TFT_PASET 0x2B 47 | #define TFT_RAMWR 0x2C 48 | 49 | #define TFT_RAMRD 0x2E 50 | #define TFT_IDXRD 0x00 //0xDD // ILI9341 only, indexed control register read 51 | 52 | #define TFT_MADCTL 0x36 53 | #define TFT_MAD_MY 0x80 54 | #define TFT_MAD_MX 0x40 55 | #define TFT_MAD_MV 0x20 56 | #define TFT_MAD_ML 0x10 57 | #define TFT_MAD_BGR 0x08 58 | #define TFT_MAD_MH 0x04 59 | #define TFT_MAD_RGB 0x00 60 | 61 | #define TFT_INVOFF 0x20 62 | #define TFT_INVON 0x21 63 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9341_Rotation.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that rotates the ILI9341 driver coordinate frame 3 | 4 | rotation = m % 8; // Limit the range of values to 0-7 5 | 6 | writecommand(TFT_MADCTL); 7 | switch (rotation) { 8 | case 0: 9 | #ifdef M5STACK 10 | writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 11 | #else 12 | writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER); 13 | #endif 14 | _width = _init_width; 15 | _height = _init_height; 16 | break; 17 | case 1: 18 | #ifdef M5STACK 19 | writedata(TFT_MAD_COLOR_ORDER); 20 | #else 21 | writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 22 | #endif 23 | _width = _init_height; 24 | _height = _init_width; 25 | break; 26 | case 2: 27 | #ifdef M5STACK 28 | writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER); 29 | #else 30 | writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 31 | #endif 32 | _width = _init_width; 33 | _height = _init_height; 34 | break; 35 | case 3: 36 | #ifdef M5STACK 37 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 38 | #else 39 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 40 | #endif 41 | _width = _init_height; 42 | _height = _init_width; 43 | break; 44 | // These next rotations are for bottom up BMP drawing 45 | case 4: 46 | #ifdef M5STACK 47 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 48 | #else 49 | writedata(TFT_MAD_MX | TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 50 | #endif 51 | _width = _init_width; 52 | _height = _init_height; 53 | break; 54 | case 5: 55 | #ifdef M5STACK 56 | writedata(TFT_MAD_MY | TFT_MAD_COLOR_ORDER); 57 | #else 58 | writedata(TFT_MAD_MV | TFT_MAD_MX | TFT_MAD_COLOR_ORDER); 59 | #endif 60 | _width = _init_height; 61 | _height = _init_width; 62 | break; 63 | case 6: 64 | #ifdef M5STACK 65 | writedata(TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 66 | #else 67 | writedata(TFT_MAD_COLOR_ORDER); 68 | #endif 69 | _width = _init_width; 70 | _height = _init_height; 71 | break; 72 | case 7: 73 | #ifdef M5STACK 74 | writedata(TFT_MAD_MX | TFT_MAD_COLOR_ORDER); 75 | #else 76 | writedata(TFT_MAD_MY | TFT_MAD_MV | TFT_MAD_COLOR_ORDER); 77 | #endif 78 | _width = _init_height; 79 | _height = _init_width; 80 | break; 81 | 82 | } 83 | -------------------------------------------------------------------------------- /TFT_eSPI/Extensions/Smooth_font.h: -------------------------------------------------------------------------------- 1 | // Coded by Bodmer 10/2/18, see license in root directory. 2 | // This is part of the TFT_eSPI class and is associated with anti-aliased font functions 3 | 4 | public: 5 | 6 | // These are for the new antialiased fonts 7 | void loadFont(const uint8_t array[]); 8 | #ifdef FONT_FS_AVAILABLE 9 | void loadFont(String fontName, fs::FS &ffs); 10 | #endif 11 | void loadFont(String fontName, bool flash = true); 12 | void unloadFont( void ); 13 | bool getUnicodeIndex(uint16_t unicode, uint16_t *index); 14 | 15 | virtual void drawGlyph(uint16_t code); 16 | 17 | void showFont(uint32_t td); 18 | 19 | // This is for the whole font 20 | typedef struct 21 | { 22 | const uint8_t* gArray; //array start pointer 23 | uint16_t gCount; // Total number of characters 24 | uint16_t yAdvance; // Line advance 25 | uint16_t spaceWidth; // Width of a space character 26 | int16_t ascent; // Height of top of 'd' above baseline, other characters may be taller 27 | int16_t descent; // Offset to bottom of 'p', other characters may have a larger descent 28 | uint16_t maxAscent; // Maximum ascent found in font 29 | uint16_t maxDescent; // Maximum descent found in font 30 | } fontMetrics; 31 | 32 | fontMetrics gFont = { nullptr, 0, 0, 0, 0, 0, 0, 0 }; 33 | 34 | // These are for the metrics for each individual glyph (so we don't need to seek this in file and waste time) 35 | uint16_t* gUnicode = NULL; //UTF-16 code, the codes are searched so do not need to be sequential 36 | uint8_t* gHeight = NULL; //cheight 37 | uint8_t* gWidth = NULL; //cwidth 38 | uint8_t* gxAdvance = NULL; //setWidth 39 | int16_t* gdY = NULL; //topExtent 40 | int8_t* gdX = NULL; //leftExtent 41 | uint32_t* gBitmap = NULL; //file pointer to greyscale bitmap 42 | 43 | bool fontLoaded = false; // Flags when a anti-aliased font is loaded 44 | 45 | #ifdef FONT_FS_AVAILABLE 46 | fs::File fontFile; 47 | fs::FS &fontFS = SPIFFS; 48 | bool spiffs = true; 49 | bool fs_font = false; // For ESP32/8266 use smooth font file or FLASH (PROGMEM) array 50 | 51 | #else 52 | bool fontFile = true; 53 | #endif 54 | 55 | private: 56 | 57 | void loadMetrics(void); 58 | uint32_t readInt32(void); 59 | 60 | uint8_t* fontPtr = nullptr; 61 | 62 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/TFT_SPIFFS_BMP/TFT_SPIFFS_BMP.ino: -------------------------------------------------------------------------------- 1 | // This sketch draws BMP images pulled from SPIFFS onto the TFT. It is an 2 | // an example from this library: https://github.com/Bodmer/TFT_eSPI 3 | 4 | // Images in SPIFFS must be put in the root folder (top level) to be found 5 | // Use the SPIFFS library example to verify SPIFFS works! 6 | 7 | // The example image used to test this sketch can be found in the sketch 8 | // Data folder, press Ctrl+K to see this folder. Use the IDE "Tools" menu 9 | // option to upload the sketches data folder to the SPIFFS 10 | 11 | // This sketch has been tested on the ESP32 and ESP8266 12 | 13 | //---------------------------------------------------------------------------------------------------- 14 | 15 | //==================================================================================== 16 | // Libraries 17 | //==================================================================================== 18 | // Call up the SPIFFS FLASH filing system this is part of the ESP Core 19 | #define FS_NO_GLOBALS 20 | #include 21 | 22 | #ifdef ESP32 23 | #include "SPIFFS.h" // For ESP32 only 24 | #endif 25 | 26 | // Call up the TFT library 27 | #include // Hardware-specific library for ESP8266 28 | 29 | // Invoke TFT library 30 | TFT_eSPI tft = TFT_eSPI(); 31 | 32 | //==================================================================================== 33 | // Setup 34 | //==================================================================================== 35 | void setup() 36 | { 37 | Serial.begin(115200); 38 | 39 | if (!SPIFFS.begin()) { 40 | Serial.println("SPIFFS initialisation failed!"); 41 | while (1) yield(); // Stay here twiddling thumbs waiting 42 | } 43 | Serial.println("\r\nSPIFFS initialised."); 44 | 45 | // Now initialise the TFT 46 | tft.begin(); 47 | tft.setRotation(0); // 0 & 2 Portrait. 1 & 3 landscape 48 | tft.fillScreen(TFT_BLACK); 49 | } 50 | 51 | //==================================================================================== 52 | // Loop 53 | //==================================================================================== 54 | void loop() 55 | { 56 | int x = random(tft.width() - 128); 57 | int y = random(tft.height() - 160); 58 | 59 | drawBmp("/parrot.bmp", x, y); 60 | 61 | delay(1000); 62 | } 63 | //==================================================================================== 64 | 65 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9486_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #define TFT_WIDTH 320 4 | #define TFT_HEIGHT 480 5 | 6 | // For Raspberry Pi ILI9486 only with a modified board to add a write strobe: 7 | #if defined (TFT_WR) && defined (RPI_ILI9486_DRIVER) 8 | #define RPI_WRITE_STROBE 9 | #endif 10 | 11 | // Color definitions for backwards compatibility with old sketches 12 | // use colour definitions like TFT_BLACK to make sketches more portable 13 | #define ILI9486_BLACK 0x0000 /* 0, 0, 0 */ 14 | #define ILI9486_NAVY 0x000F /* 0, 0, 128 */ 15 | #define ILI9486_DARKGREEN 0x03E0 /* 0, 128, 0 */ 16 | #define ILI9486_DARKCYAN 0x03EF /* 0, 128, 128 */ 17 | #define ILI9486_MAROON 0x7800 /* 128, 0, 0 */ 18 | #define ILI9486_PURPLE 0x780F /* 128, 0, 128 */ 19 | #define ILI9486_OLIVE 0x7BE0 /* 128, 128, 0 */ 20 | #define ILI9486_LIGHTGREY 0xC618 /* 192, 192, 192 */ 21 | #define ILI9486_DARKGREY 0x7BEF /* 128, 128, 128 */ 22 | #define ILI9486_BLUE 0x001F /* 0, 0, 255 */ 23 | #define ILI9486_GREEN 0x07E0 /* 0, 255, 0 */ 24 | #define ILI9486_CYAN 0x07FF /* 0, 255, 255 */ 25 | #define ILI9486_RED 0xF800 /* 255, 0, 0 */ 26 | #define ILI9486_MAGENTA 0xF81F /* 255, 0, 255 */ 27 | #define ILI9486_YELLOW 0xFFE0 /* 255, 255, 0 */ 28 | #define ILI9486_WHITE 0xFFFF /* 255, 255, 255 */ 29 | #define ILI9486_ORANGE 0xFD20 /* 255, 165, 0 */ 30 | #define ILI9486_GREENYELLOW 0xAFE5 /* 173, 255, 47 */ 31 | #define ILI9486_PINK 0xF81F 32 | 33 | 34 | // Delay between some initialisation commands 35 | #define TFT_INIT_DELAY 0x80 // Not used unless commandlist invoked 36 | 37 | 38 | // Generic commands used by TFT_eSPI.cpp 39 | #define TFT_NOP 0x00 40 | #define TFT_SWRST 0x01 41 | 42 | #define TFT_CASET 0x2A 43 | #define TFT_PASET 0x2B 44 | #define TFT_RAMWR 0x2C 45 | 46 | #define TFT_RAMRD 0x2E 47 | #define TFT_IDXRD 0x00 // ILI9341 only, indexed control register read 48 | 49 | #define TFT_MADCTL 0x36 50 | #define TFT_MAD_MY 0x80 51 | #define TFT_MAD_MX 0x40 52 | #define TFT_MAD_MV 0x20 53 | #define TFT_MAD_ML 0x10 54 | #define TFT_MAD_BGR 0x08 55 | #define TFT_MAD_MH 0x04 56 | #define TFT_MAD_SS 0x02 57 | #define TFT_MAD_GS 0x01 58 | #define TFT_MAD_RGB 0x00 59 | 60 | #define TFT_INVOFF 0x20 61 | #define TFT_INVON 0x21 62 | -------------------------------------------------------------------------------- /TFT_eSPI/User_Setups/Setup35_ILI9341_STM32_Port_Bus.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////// 2 | // Setup for STM32 and ILI9341 display // 3 | ////////////////////////////////////////////////////////////// 4 | 5 | // Last update by Bodmer: 28/3/20 6 | 7 | // Define STM32 to invoke STM32 optimised driver 8 | #define STM32 9 | 10 | // Define if Port A (or B) pins 0-7 are used for data bus bits 0-7 11 | // this will improve rendering performance by a factor of ~8x 12 | #define STM_PORTA_DATA_BUS 13 | //#define STM_PORTB_DATA_BUS // Pins below must re re-allocated to use this option 14 | 15 | // Tell the library to use 8 bit parallel mode (otherwise SPI is assumed) 16 | #define TFT_PARALLEL_8_BIT 17 | 18 | // Define ONE of the the TFT display drivers 19 | #define ILI9341_DRIVER 20 | //#define ILI9481_DRIVER 21 | //#define ILI9486_DRIVER 22 | //#define ILI9488_DRIVER 23 | //#define ST7796_DRIVER 24 | 25 | #define TFT_CS PB7 // Chip select control pin 26 | #define TFT_DC PB8 // Data Command control pin 27 | #define TFT_RST PB0 // Reset pin 28 | #define TFT_WR PB9 // Write strobe control pin 29 | #define TFT_RD PB1 // Read pin 30 | 31 | #define TFT_D0 PA0 // 8 bit Port A parallel bus to TFT 32 | #define TFT_D1 PA1 33 | #define TFT_D2 PA2 34 | #define TFT_D3 PA3 35 | #define TFT_D4 PA4 36 | #define TFT_D5 PA5 37 | #define TFT_D6 PA6 38 | #define TFT_D7 PA7 39 | 40 | #define LOAD_GLCD // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH 41 | #define LOAD_FONT2 // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters 42 | #define LOAD_FONT4 // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters 43 | #define LOAD_FONT6 // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm 44 | #define LOAD_FONT7 // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-. 45 | #define LOAD_FONT8 // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-. 46 | #define LOAD_GFXFF // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts 47 | 48 | // STM32 support for smooth fonts via program memory (FLASH) arrays 49 | #define SMOOTH_FONT 50 | 51 | // Assuming the processor clock is 72MHz: 52 | #define SPI_FREQUENCY 36000000 // 36MHz SPI clock 53 | //#define SPI_FREQUENCY 18000000 // 18MHz SPI clock 54 | 55 | #define SPI_READ_FREQUENCY 12000000 // Reads need a slower SPI clock 56 | 57 | #define SPI_TOUCH_FREQUENCY 2500000 // Must be very slow 58 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/320 x 240/TFT_Starfield/TFT_Starfield.ino: -------------------------------------------------------------------------------- 1 | // Animates white pixels to simulate flying through a star field 2 | 3 | #include 4 | #include 5 | 6 | // Use hardware SPI 7 | TFT_eSPI tft = TFT_eSPI(); 8 | 9 | // With 1024 stars the update rate is ~65 frames per second 10 | #define NSTARS 1024 11 | uint8_t sx[NSTARS] = {}; 12 | uint8_t sy[NSTARS] = {}; 13 | uint8_t sz[NSTARS] = {}; 14 | 15 | uint8_t za, zb, zc, zx; 16 | 17 | // Fast 0-255 random number generator from http://eternityforest.com/Projects/rng.php: 18 | uint8_t __attribute__((always_inline)) rng() 19 | { 20 | zx++; 21 | za = (za^zc^zx); 22 | zb = (zb+za); 23 | zc = (zc+(zb>>1)^za); 24 | return zc; 25 | } 26 | 27 | void setup() { 28 | za = random(256); 29 | zb = random(256); 30 | zc = random(256); 31 | zx = random(256); 32 | 33 | Serial.begin(115200); 34 | tft.init(); 35 | tft.setRotation(1); 36 | tft.fillScreen(TFT_BLACK); 37 | 38 | // fastSetup() must be used immediately before fastPixel() to prepare screen 39 | // It must be called after any other graphics drawing function call if fastPixel() 40 | // is to be called again 41 | //tft.fastSetup(); // Prepare plot window range for fast pixel plotting 42 | } 43 | 44 | void loop() 45 | { 46 | unsigned long t0 = micros(); 47 | uint8_t spawnDepthVariation = 255; 48 | 49 | for(int i = 0; i < NSTARS; ++i) 50 | { 51 | if (sz[i] <= 1) 52 | { 53 | sx[i] = 160 - 120 + rng(); 54 | sy[i] = rng(); 55 | sz[i] = spawnDepthVariation--; 56 | } 57 | else 58 | { 59 | int old_screen_x = ((int)sx[i] - 160) * 256 / sz[i] + 160; 60 | int old_screen_y = ((int)sy[i] - 120) * 256 / sz[i] + 120; 61 | 62 | // This is a faster pixel drawing function for occassions where many single pixels must be drawn 63 | tft.drawPixel(old_screen_x, old_screen_y,TFT_BLACK); 64 | 65 | sz[i] -= 2; 66 | if (sz[i] > 1) 67 | { 68 | int screen_x = ((int)sx[i] - 160) * 256 / sz[i] + 160; 69 | int screen_y = ((int)sy[i] - 120) * 256 / sz[i] + 120; 70 | 71 | if (screen_x >= 0 && screen_y >= 0 && screen_x < 320 && screen_y < 240) 72 | { 73 | uint8_t r, g, b; 74 | r = g = b = 255 - sz[i]; 75 | tft.drawPixel(screen_x, screen_y, tft.color565(r,g,b)); 76 | } 77 | else 78 | sz[i] = 0; // Out of screen, die. 79 | } 80 | } 81 | } 82 | unsigned long t1 = micros(); 83 | //static char timeMicros[8] = {}; 84 | 85 | // Calcualte frames per second 86 | Serial.println(1.0/((t1 - t0)/1000000.0)); 87 | } 88 | 89 | 90 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/TFT_Flash_Bitmap/TFT_Flash_Bitmap.ino: -------------------------------------------------------------------------------- 1 | // Icon images are stored in tabs ^ e.g. Alert.h etc above this line 2 | // more than one icon can be in a header file 3 | 4 | // Arrays containing FLASH images can be created with UTFT library tool: 5 | // (libraries\UTFT\Tools\ImageConverter565.exe) 6 | // Convert to .c format then copy into a new tab 7 | 8 | /* 9 | This sketch demonstrates loading images from arrays stored in program (FLASH) memory. 10 | 11 | Works with TFT_eSPI library here: 12 | https://github.com/Bodmer/TFT_eSPI 13 | 14 | This sketch does not use/need any fonts at all... 15 | 16 | Code derived from ILI9341_due library example 17 | 18 | Make sure all the display driver and pin comnenctions are correct by 19 | editting the User_Setup.h file in the TFT_eSPI library folder. 20 | 21 | ######################################################################### 22 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 23 | ######################################################################### 24 | */ 25 | 26 | #include // Hardware-specific library 27 | 28 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 29 | 30 | // Include the header files that contain the icons 31 | #include "Alert.h" 32 | #include "Close.h" 33 | #include "Info.h" 34 | 35 | long count = 0; // Loop count 36 | 37 | void setup() 38 | { 39 | Serial.begin(115200); 40 | tft.begin(); 41 | tft.setRotation(1); // landscape 42 | 43 | tft.fillScreen(TFT_BLACK); 44 | 45 | // Swap the colour byte order when rendering 46 | tft.setSwapBytes(true); 47 | 48 | // Draw the icons 49 | tft.pushImage(100, 100, infoWidth, infoHeight, info); 50 | tft.pushImage(140, 100, alertWidth, alertHeight, alert); 51 | tft.pushImage(180, 100, closeWidth, closeHeight, closeX); 52 | 53 | // Pause here to admire the icons! 54 | delay(2000); 55 | 56 | } 57 | 58 | void loop() 59 | { 60 | // Loop filling and clearing screen 61 | tft.pushImage(random(tft.width() - infoWidth), random(tft.height() - infoHeight), infoWidth, infoHeight, info); 62 | tft.pushImage(random(tft.width() - alertWidth), random(tft.height() - alertHeight), alertWidth, alertHeight, alert); 63 | tft.pushImage(random(tft.width() - closeWidth), random(tft.height() - closeHeight), alertWidth, closeHeight, closeX); 64 | 65 | // Clear screen after 100 x 3 = 300 icons drawn 66 | if (1000 == count++) { 67 | count = 1; 68 | tft.setRotation(2 * random(2)); // Rotate randomly to clear display left>right or right>left to reduce monotony! 69 | tft.fillScreen(TFT_BLACK); 70 | tft.setRotation(1); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/320 x 240/TFT_Mandlebrot/TFT_Mandlebrot.ino: -------------------------------------------------------------------------------- 1 | // Mandlebrot 2 | 3 | // This will run quite slowly due to the large number of floating point calculations per pixel 4 | 5 | #include // Hardware-specific library 6 | #include 7 | 8 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 9 | 10 | #define TFT_GREY 0x7BEF 11 | 12 | unsigned long runTime = 0; 13 | 14 | float sx = 0, sy = 0; 15 | uint16_t x0 = 0, x1 = 0, yy0 = 0, yy1 = 0; 16 | 17 | void setup() 18 | { 19 | Serial.begin(250000); 20 | //randomSeed(analogRead(A0)); 21 | Serial.println(); 22 | // Setup the LCD 23 | tft.init(); 24 | tft.setRotation(3); 25 | } 26 | 27 | void loop() 28 | { 29 | runTime = millis(); 30 | 31 | tft.fillScreen(TFT_BLACK); 32 | tft.startWrite(); 33 | for (int px = 1; px < 320; px++) 34 | { 35 | for (int py = 0; py < 240; py++) 36 | { 37 | float x0 = (map(px, 0, 320, -250000/2, -242500/2)) / 100000.0; //scaled x coordinate of pixel (scaled to lie in the Mandelbrot X scale (-2.5, 1)) 38 | float yy0 = (map(py, 0, 240, -75000/4, -61000/4)) / 100000.0; //scaled y coordinate of pixel (scaled to lie in the Mandelbrot Y scale (-1, 1)) 39 | float xx = 0.0; 40 | float yy = 0.0; 41 | int iteration = 0; 42 | int max_iteration = 128; 43 | while ( ((xx * xx + yy * yy) < 4) && (iteration < max_iteration) ) 44 | { 45 | float xtemp = xx * xx - yy * yy + x0; 46 | yy = 2 * xx * yy + yy0; 47 | xx = xtemp; 48 | iteration++; 49 | } 50 | int color = rainbow((3*iteration+64)%128); 51 | yield();tft.drawPixel(px, py, color); 52 | } 53 | } 54 | tft.endWrite(); 55 | 56 | Serial.println(millis()-runTime); 57 | while(1) yield(); 58 | } 59 | 60 | unsigned int rainbow(int value) 61 | { 62 | // Value is expected to be in range 0-127 63 | // The value is converted to a spectrum colour from 0 = blue through to red = blue 64 | 65 | byte red = 0; // Red is the top 5 bits of a 16 bit colour value 66 | byte green = 0;// Green is the middle 6 bits 67 | byte blue = 0; // Blue is the bottom 5 bits 68 | 69 | byte quadrant = value / 32; 70 | 71 | if (quadrant == 0) { 72 | blue = 31; 73 | green = 2 * (value % 32); 74 | red = 0; 75 | } 76 | if (quadrant == 1) { 77 | blue = 31 - (value % 32); 78 | green = 63; 79 | red = 0; 80 | } 81 | if (quadrant == 2) { 82 | blue = 0; 83 | green = 63; 84 | red = value % 32; 85 | } 86 | if (quadrant == 3) { 87 | blue = 0; 88 | green = 63 - 2 * (value % 32); 89 | red = 31; 90 | } 91 | return (red << 11) + (green << 5) + blue; 92 | } 93 | 94 | 95 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/320 x 240/TFT_Pie_Chart/TFT_Pie_Chart.ino: -------------------------------------------------------------------------------- 1 | // This sketch includes a function to draw circle segments 2 | // for pie charts in 1 degree increments 3 | 4 | #include // Hardware-specific library 5 | #include 6 | 7 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 8 | 9 | #define DEG2RAD 0.0174532925 10 | 11 | byte inc = 0; 12 | unsigned int col = 0; 13 | 14 | 15 | void setup(void) 16 | { 17 | tft.begin(); 18 | 19 | tft.setRotation(1); 20 | 21 | tft.fillScreen(TFT_BLACK); 22 | } 23 | 24 | void loop() { 25 | 26 | // Draw 4 pie chart segments 27 | fillSegment(160, 120, 0, 60, 100, TFT_RED); 28 | fillSegment(160, 120, 60, 30, 100, TFT_GREEN); 29 | fillSegment(160, 120, 60 + 30, 120, 100, TFT_BLUE); 30 | fillSegment(160, 120, 60 + 30 + 120, 150, 100, TFT_YELLOW); 31 | 32 | delay(4000); 33 | 34 | // Erase old chart with 360 degree black plot 35 | fillSegment(160, 120, 0, 360, 100, TFT_BLACK); 36 | } 37 | 38 | 39 | // ######################################################################### 40 | // Draw circle segments 41 | // ######################################################################### 42 | 43 | // x,y == coords of centre of circle 44 | // start_angle = 0 - 359 45 | // sub_angle = 0 - 360 = subtended angle 46 | // r = radius 47 | // colour = 16 bit colour value 48 | 49 | int fillSegment(int x, int y, int start_angle, int sub_angle, int r, unsigned int colour) 50 | { 51 | // Calculate first pair of coordinates for segment start 52 | float sx = cos((start_angle - 90) * DEG2RAD); 53 | float sy = sin((start_angle - 90) * DEG2RAD); 54 | uint16_t x1 = sx * r + x; 55 | uint16_t y1 = sy * r + y; 56 | 57 | // Draw colour blocks every inc degrees 58 | for (int i = start_angle; i < start_angle + sub_angle; i++) { 59 | 60 | // Calculate pair of coordinates for segment end 61 | int x2 = cos((i + 1 - 90) * DEG2RAD) * r + x; 62 | int y2 = sin((i + 1 - 90) * DEG2RAD) * r + y; 63 | 64 | tft.fillTriangle(x1, y1, x2, y2, x, y, colour); 65 | 66 | // Copy segment end to sgement start for next segment 67 | x1 = x2; 68 | y1 = y2; 69 | } 70 | } 71 | 72 | 73 | // ######################################################################### 74 | // Return the 16 bit colour with brightness 0-100% 75 | // ######################################################################### 76 | unsigned int brightness(unsigned int colour, int brightness) 77 | { 78 | byte red = colour >> 11; 79 | byte green = (colour & 0x7E0) >> 5; 80 | byte blue = colour & 0x1F; 81 | 82 | blue = (blue * brightness)/100; 83 | green = (green * brightness)/100; 84 | red = (red * brightness)/100; 85 | 86 | return (red << 11) + (green << 5) + blue; 87 | } 88 | 89 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/FactoryTest/Button2.h: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////// 2 | /* 3 | Button2.cpp - Arduino Library to simplify working with buttons. 4 | Created by Lennart Hennigs, October 28, 2017. 5 | */ 6 | ///////////////////////////////////////////////////////////////// 7 | #pragma once 8 | 9 | #ifndef Button2_h 10 | #define Button2_h 11 | 12 | ///////////////////////////////////////////////////////////////// 13 | 14 | #include "Arduino.h" 15 | 16 | ///////////////////////////////////////////////////////////////// 17 | 18 | #define DEBOUNCE_MS 50 19 | #define LONGCLICK_MS 250 20 | #define DOUBLECLICK_MS 400 21 | 22 | #define SINGLE_CLICK 1 23 | #define DOUBLE_CLICK 2 24 | #define TRIPLE_CLICK 3 25 | #define LONG_CLICK 4 26 | 27 | ///////////////////////////////////////////////////////////////// 28 | 29 | class Button2 { 30 | private: 31 | byte pin; 32 | int prev_state; 33 | int state = HIGH; 34 | byte click_count = 0; 35 | unsigned int last_click_type = 0; 36 | unsigned long click_ms; 37 | unsigned long down_ms; 38 | unsigned int debounce_time_ms; 39 | unsigned int down_time_ms = 0; 40 | bool pressed_triggered = false; 41 | bool longclick_detected = false; 42 | 43 | typedef void (*CallbackFunction) (Button2&); 44 | 45 | CallbackFunction pressed_cb = NULL; 46 | CallbackFunction released_cb = NULL; 47 | CallbackFunction change_cb = NULL; 48 | CallbackFunction tap_cb = NULL; 49 | CallbackFunction click_cb = NULL; 50 | CallbackFunction long_cb = NULL; 51 | CallbackFunction double_cb = NULL; 52 | CallbackFunction triple_cb = NULL; 53 | 54 | public: 55 | Button2(){pin = -1;} 56 | Button2(byte attachTo, byte buttonMode = INPUT_PULLUP, unsigned int debounceTimeout = DEBOUNCE_MS); 57 | void setDebounceTime(unsigned int ms); 58 | 59 | void setChangedHandler(CallbackFunction f); 60 | void setPressedHandler(CallbackFunction f); 61 | void setReleasedHandler(CallbackFunction f); 62 | void setClickHandler(CallbackFunction f); 63 | void setTapHandler(CallbackFunction f); 64 | void setLongClickHandler(CallbackFunction f); 65 | void setDoubleClickHandler(CallbackFunction f); 66 | void setTripleClickHandler(CallbackFunction f); 67 | 68 | unsigned int wasPressedFor(); 69 | boolean isPressed(); 70 | 71 | unsigned int getNumberOfClicks(); 72 | unsigned int getClickType(); 73 | uint8_t getAttachPin(){return pin;} 74 | bool operator==(Button2 &rhs); 75 | 76 | void loop(); 77 | }; 78 | ///////////////////////////////////////////////////////////////// 79 | #endif 80 | ///////////////////////////////////////////////////////////////// 81 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/320 x 240/TFT_Spiro/TFT_Spiro.ino: -------------------------------------------------------------------------------- 1 | // Spiro 2 | // Rainbow patern generator 3 | 4 | #include // Hardware-specific library 5 | #include 6 | 7 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 8 | 9 | #define DEG2RAD 0.0174532925 // Convert angles in degrees to radians 10 | 11 | unsigned long runTime = 0; 12 | 13 | float sx = 0, sy = 0; 14 | uint16_t x0 = 0, x1 = 0, yy0 = 0, yy1 = 0; 15 | 16 | void setup() 17 | { 18 | //randomSeed(analogRead(A0)); 19 | 20 | // Setup the LCD 21 | tft.init(); 22 | tft.setRotation(3); 23 | } 24 | 25 | void loop() 26 | { 27 | runTime = millis(); 28 | 29 | tft.fillScreen(TFT_BLACK); 30 | int n = random(2, 23), r = random(20, 100), colour = 0; //rainbow(); 31 | 32 | for (long i = 0; i < (360 * n); i++) { 33 | sx = cos((i / n - 90) * DEG2RAD); 34 | sy = sin((i / n - 90) * DEG2RAD); 35 | x0 = sx * (120 - r) + 159; 36 | yy0 = sy * (120 - r) + 119; 37 | 38 | 39 | sy = cos(((i % 360) - 90) * DEG2RAD); 40 | sx = sin(((i % 360) - 90) * DEG2RAD); 41 | x1 = sx * r + x0; 42 | yy1 = sy * r + yy0; 43 | tft.drawPixel(x1, yy1, rainbow(map(i%360,0,360,0,127))); //colour); 44 | } 45 | 46 | r = random(20, 100);//r = r / random(2,4); 47 | for (long i = 0; i < (360 * n); i++) { 48 | sx = cos((i / n - 90) * DEG2RAD); 49 | sy = sin((i / n - 90) * DEG2RAD); 50 | x0 = sx * (120 - r) + 159; 51 | yy0 = sy * (120 - r) + 119; 52 | 53 | 54 | sy = cos(((i % 360) - 90) * DEG2RAD); 55 | sx = sin(((i % 360) - 90) * DEG2RAD); 56 | x1 = sx * r + x0; 57 | yy1 = sy * r + yy0; 58 | tft.drawPixel(x1, yy1, rainbow(map(i%360,0,360,0,127))); //colour); 59 | } 60 | 61 | 62 | delay(2000); 63 | } 64 | 65 | unsigned int rainbow(int value) 66 | { 67 | // Value is expected to be in range 0-127 68 | // The value is converted to a spectrum colour from 0 = blue through to red = blue 69 | //int value = random (128); 70 | byte red = 0; // Red is the top 5 bits of a 16 bit colour value 71 | byte green = 0;// Green is the middle 6 bits 72 | byte blue = 0; // Blue is the bottom 5 bits 73 | 74 | byte quadrant = value / 32; 75 | 76 | if (quadrant == 0) { 77 | blue = 31; 78 | green = 2 * (value % 32); 79 | red = 0; 80 | } 81 | if (quadrant == 1) { 82 | blue = 31 - (value % 32); 83 | green = 63; 84 | red = 0; 85 | } 86 | if (quadrant == 2) { 87 | blue = 0; 88 | green = 63; 89 | red = value % 32; 90 | } 91 | if (quadrant == 3) { 92 | blue = 0; 93 | green = 63 - 2 * (value % 32); 94 | red = 31; 95 | } 96 | return (red << 11) + (green << 5) + blue; 97 | } 98 | 99 | 100 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ILI9488_Init.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that initialises the ILI9488 driver 3 | // 4 | // This setup information uses simple 8 bit SPI writecommand() and writedata() functions 5 | // 6 | // See ST7735_Setup.h file for an alternative format 7 | 8 | 9 | // Configure ILI9488 display 10 | 11 | writecommand(0xE0); // Positive Gamma Control 12 | writedata(0x00); 13 | writedata(0x03); 14 | writedata(0x09); 15 | writedata(0x08); 16 | writedata(0x16); 17 | writedata(0x0A); 18 | writedata(0x3F); 19 | writedata(0x78); 20 | writedata(0x4C); 21 | writedata(0x09); 22 | writedata(0x0A); 23 | writedata(0x08); 24 | writedata(0x16); 25 | writedata(0x1A); 26 | writedata(0x0F); 27 | 28 | writecommand(0XE1); // Negative Gamma Control 29 | writedata(0x00); 30 | writedata(0x16); 31 | writedata(0x19); 32 | writedata(0x03); 33 | writedata(0x0F); 34 | writedata(0x05); 35 | writedata(0x32); 36 | writedata(0x45); 37 | writedata(0x46); 38 | writedata(0x04); 39 | writedata(0x0E); 40 | writedata(0x0D); 41 | writedata(0x35); 42 | writedata(0x37); 43 | writedata(0x0F); 44 | 45 | writecommand(0XC0); // Power Control 1 46 | writedata(0x17); 47 | writedata(0x15); 48 | 49 | writecommand(0xC1); // Power Control 2 50 | writedata(0x41); 51 | 52 | writecommand(0xC5); // VCOM Control 53 | writedata(0x00); 54 | writedata(0x12); 55 | writedata(0x80); 56 | 57 | writecommand(TFT_MADCTL); // Memory Access Control 58 | writedata(0x48); // MX, BGR 59 | 60 | writecommand(0x3A); // Pixel Interface Format 61 | #if defined (TFT_PARALLEL_8_BIT) 62 | writedata(0x55); // 16 bit colour for parallel 63 | #else 64 | writedata(0x66); // 18 bit colour for SPI 65 | #endif 66 | 67 | writecommand(0xB0); // Interface Mode Control 68 | writedata(0x00); 69 | 70 | writecommand(0xB1); // Frame Rate Control 71 | writedata(0xA0); 72 | 73 | writecommand(0xB4); // Display Inversion Control 74 | writedata(0x02); 75 | 76 | writecommand(0xB6); // Display Function Control 77 | writedata(0x02); 78 | writedata(0x02); 79 | writedata(0x3B); 80 | 81 | writecommand(0xB7); // Entry Mode Set 82 | writedata(0xC6); 83 | 84 | writecommand(0xF7); // Adjust Control 3 85 | writedata(0xA9); 86 | writedata(0x51); 87 | writedata(0x2C); 88 | writedata(0x82); 89 | 90 | writecommand(TFT_SLPOUT); //Exit Sleep 91 | delay(120); 92 | 93 | writecommand(TFT_DISPON); //Display on 94 | delay(25); 95 | 96 | // End of ILI9488 display configuration 97 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/TFT_SPIFFS_BMP/BMP_functions.ino: -------------------------------------------------------------------------------- 1 | // Bodmers BMP image rendering function 2 | 3 | void drawBmp(const char *filename, int16_t x, int16_t y) { 4 | 5 | if ((x >= tft.width()) || (y >= tft.height())) return; 6 | 7 | fs::File bmpFS; 8 | 9 | // Open requested file on SD card 10 | bmpFS = SPIFFS.open(filename, "r"); 11 | 12 | if (!bmpFS) 13 | { 14 | Serial.print("File not found"); 15 | return; 16 | } 17 | 18 | uint32_t seekOffset; 19 | uint16_t w, h, row, col; 20 | uint8_t r, g, b; 21 | 22 | uint32_t startTime = millis(); 23 | 24 | if (read16(bmpFS) == 0x4D42) 25 | { 26 | read32(bmpFS); 27 | read32(bmpFS); 28 | seekOffset = read32(bmpFS); 29 | read32(bmpFS); 30 | w = read32(bmpFS); 31 | h = read32(bmpFS); 32 | 33 | if ((read16(bmpFS) == 1) && (read16(bmpFS) == 24) && (read32(bmpFS) == 0)) 34 | { 35 | y += h - 1; 36 | 37 | bool oldSwapBytes = tft.getSwapBytes(); 38 | tft.setSwapBytes(true); 39 | bmpFS.seek(seekOffset); 40 | 41 | uint16_t padding = (4 - ((w * 3) & 3)) & 3; 42 | uint8_t lineBuffer[w * 3 + padding]; 43 | 44 | for (row = 0; row < h; row++) { 45 | 46 | bmpFS.read(lineBuffer, sizeof(lineBuffer)); 47 | uint8_t* bptr = lineBuffer; 48 | uint16_t* tptr = (uint16_t*)lineBuffer; 49 | // Convert 24 to 16 bit colours 50 | for (uint16_t col = 0; col < w; col++) 51 | { 52 | b = *bptr++; 53 | g = *bptr++; 54 | r = *bptr++; 55 | *tptr++ = ((r & 0xF8) << 8) | ((g & 0xFC) << 3) | (b >> 3); 56 | } 57 | 58 | // Push the pixel row to screen, pushImage will crop the line if needed 59 | // y is decremented as the BMP image is drawn bottom up 60 | tft.pushImage(x, y--, w, 1, (uint16_t*)lineBuffer); 61 | } 62 | tft.setSwapBytes(oldSwapBytes); 63 | Serial.print("Loaded in "); Serial.print(millis() - startTime); 64 | Serial.println(" ms"); 65 | } 66 | else Serial.println("BMP format not recognized."); 67 | } 68 | bmpFS.close(); 69 | } 70 | 71 | // These read 16- and 32-bit types from the SD card file. 72 | // BMP data is stored little-endian, Arduino is little-endian too. 73 | // May need to reverse subscript order if porting elsewhere. 74 | 75 | uint16_t read16(fs::File &f) { 76 | uint16_t result; 77 | ((uint8_t *)&result)[0] = f.read(); // LSB 78 | ((uint8_t *)&result)[1] = f.read(); // MSB 79 | return result; 80 | } 81 | 82 | uint32_t read32(fs::File &f) { 83 | uint32_t result; 84 | ((uint8_t *)&result)[0] = f.read(); // LSB 85 | ((uint8_t *)&result)[1] = f.read(); 86 | ((uint8_t *)&result)[2] = f.read(); 87 | ((uint8_t *)&result)[3] = f.read(); // MSB 88 | return result; 89 | } 90 | 91 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/S6D02A1_Init.h: -------------------------------------------------------------------------------- 1 | 2 | // This is the command sequence that initialises the S6D02A1 driver 3 | // 4 | // This setup information is in a format accecpted by the commandList() function 5 | // which reduces FLASH space, but on an ESP8266 there is plenty available! 6 | // 7 | // See ILI9341_Setup.h file for an alternative simpler format 8 | 9 | { 10 | // Initialization commands for S6D02A1 screens 11 | static const uint8_t S6D02A1_cmds[] PROGMEM = 12 | { 13 | 29, 14 | 0xf0, 2, 0x5a, 0x5a, // Excommand2 15 | 0xfc, 2, 0x5a, 0x5a, // Excommand3 16 | 0x26, 1, 0x01, // Gamma set 17 | 0xfa, 15, 0x02, 0x1f, 0x00, 0x10, 0x22, 0x30, 0x38, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3d, 0x02, 0x01, // Positive gamma control 18 | 0xfb, 15, 0x21, 0x00, 0x02, 0x04, 0x07, 0x0a, 0x0b, 0x0c, 0x0c, 0x16, 0x1e, 0x30, 0x3f, 0x01, 0x02, // Negative gamma control 19 | 0xfd, 11, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x01, 0x01, 0x00, 0x1f, 0x1f, // Analog parameter control 20 | 0xf4, 15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, // Power control 21 | 0xf5, 13, 0x00, 0x70, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6d, 0x66, 0x06, // VCOM control 22 | 0xf6, 11, 0x02, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x06, 0x01, 0x00, // Source control 23 | 0xf2, 17, 0x00, 0x01, 0x03, 0x08, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x08, 0x08, //Display control 24 | 0xf8, 1, 0x11, // Gate control 25 | 0xf7, 4, 0xc8, 0x20, 0x00, 0x00, // Interface control 26 | 0xf3, 2, 0x00, 0x00, // Power sequence control 27 | 0x11, TFT_INIT_DELAY, 50, // Wake 28 | 0xf3, 2+TFT_INIT_DELAY, 0x00, 0x01, 50, // Power sequence control 29 | 0xf3, 2+TFT_INIT_DELAY, 0x00, 0x03, 50, // Power sequence control 30 | 0xf3, 2+TFT_INIT_DELAY, 0x00, 0x07, 50, // Power sequence control 31 | 0xf3, 2+TFT_INIT_DELAY, 0x00, 0x0f, 50, // Power sequence control 32 | 0xf4, 15+TFT_INIT_DELAY, 0x00, 0x04, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, 50, // Power control 33 | 0xf3, 2+TFT_INIT_DELAY, 0x00, 0x1f, 50, // Power sequence control 34 | 0xf3, 2+TFT_INIT_DELAY, 0x00, 0x7f, 50, // Power sequence control 35 | 0xf3, 2+TFT_INIT_DELAY, 0x00, 0xff, 50, // Power sequence control 36 | 0xfd, 11, 0x00, 0x00, 0x00, 0x17, 0x10, 0x00, 0x00, 0x01, 0x00, 0x16, 0x16, // Analog parameter control 37 | 0xf4, 15, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3f, 0x3f, 0x07, 0x00, 0x3C, 0x36, 0x00, 0x3C, 0x36, 0x00, // Power control 38 | 0x36, 1, 0xC8, // Memory access data control 39 | 0x35, 1, 0x00, // Tearing effect line on 40 | 0x3a, 1+TFT_INIT_DELAY, 0x05, 150, // Interface pixel control 41 | 0x29, 0, // Display on 42 | 0x2c, 0 // Memory write 43 | }; 44 | 45 | commandList(S6D02A1_cmds); 46 | 47 | } 48 | -------------------------------------------------------------------------------- /TFT_eSPI/TFT_Drivers/ST7796_Defines.h: -------------------------------------------------------------------------------- 1 | // Change the width and height if required (defined in portrait mode) 2 | // or use the constructor to over-ride defaults 3 | #define TFT_WIDTH 320 4 | #define TFT_HEIGHT 480 5 | 6 | // Generic commands used by TFT_eSPI.cpp 7 | #define TFT_NOP 0x00 8 | #define TFT_SWRST 0x01 9 | 10 | #define TFT_CASET 0x2A 11 | #define TFT_PASET 0x2B 12 | #define TFT_RAMWR 0x2C 13 | #define TFT_RAMRD 0x2E 14 | 15 | #define TFT_MADCTL 0x36 16 | #define TFT_MAD_MY 0x80 17 | #define TFT_MAD_MX 0x40 18 | #define TFT_MAD_MV 0x20 19 | #define TFT_MAD_ML 0x10 20 | #define TFT_MAD_BGR 0x08 21 | #define TFT_MAD_MH 0x04 22 | #define TFT_MAD_RGB 0x00 23 | 24 | #ifdef TFT_RGB_ORDER 25 | #if (TFT_RGB_ORDER == 1) 26 | #define TFT_MAD_COLOR_ORDER TFT_MAD_RGB 27 | #else 28 | #define TFT_MAD_COLOR_ORDER TFT_MAD_BGR 29 | #endif 30 | #else 31 | #define TFT_MAD_COLOR_ORDER TFT_MAD_BGR 32 | #endif 33 | 34 | #define TFT_INVOFF 0x20 35 | #define TFT_INVON 0x21 36 | 37 | 38 | // ST7796 specific commands 39 | #define ST7796_NOP 0x00 40 | #define ST7796_SWRESET 0x01 41 | #define ST7796_RDDID 0x04 42 | #define ST7796_RDDST 0x09 43 | 44 | #define ST7796_SLPIN 0x10 45 | #define ST7796_SLPOUT 0x11 46 | #define ST7796_PTLON 0x12 47 | #define ST7796_NORON 0x13 48 | 49 | #define ST7796_RDMODE 0x0A 50 | #define ST7796_RDMADCTL 0x0B 51 | #define ST7796_RDPIXFMT 0x0C 52 | #define ST7796_RDIMGFMT 0x0A 53 | #define ST7796_RDSELFDIAG 0x0F 54 | 55 | #define ST7796_INVOFF 0x20 56 | #define ST7796_INVON 0x21 57 | 58 | #define ST7796_DISPOFF 0x28 59 | #define ST7796_DISPON 0x29 60 | 61 | #define ST7796_CASET 0x2A 62 | #define ST7796_PASET 0x2B 63 | #define ST7796_RAMWR 0x2C 64 | #define ST7796_RAMRD 0x2E 65 | 66 | #define ST7796_PTLAR 0x30 67 | #define ST7796_VSCRDEF 0x33 68 | #define ST7796_MADCTL 0x36 69 | #define ST7796_VSCRSADD 0x37 70 | #define ST7796_PIXFMT 0x3A 71 | 72 | #define ST7796_WRDISBV 0x51 73 | #define ST7796_RDDISBV 0x52 74 | #define ST7796_WRCTRLD 0x53 75 | 76 | #define ST7796_FRMCTR1 0xB1 77 | #define ST7796_FRMCTR2 0xB2 78 | #define ST7796_FRMCTR3 0xB3 79 | #define ST7796_INVCTR 0xB4 80 | #define ST7796_DFUNCTR 0xB6 81 | 82 | #define ST7796_PWCTR1 0xC0 83 | #define ST7796_PWCTR2 0xC1 84 | #define ST7796_PWCTR3 0xC2 85 | 86 | #define ST7796_VMCTR1 0xC5 87 | #define ST7796_VMCOFF 0xC6 88 | 89 | #define ST7796_RDID4 0xD3 90 | 91 | #define ST7796_GMCTRP1 0xE0 92 | #define ST7796_GMCTRN1 0xE1 93 | 94 | #define ST7796_MADCTL_MY 0x80 95 | #define ST7796_MADCTL_MX 0x40 96 | #define ST7796_MADCTL_MV 0x20 97 | #define ST7796_MADCTL_ML 0x10 98 | #define ST7796_MADCTL_RGB 0x00 99 | #define ST7796_MADCTL_BGR 0x08 100 | #define ST7796_MADCTL_MH 0x04 101 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Smooth Fonts/SPIFFS/Unicode_test/SPIFFS_functions.ino: -------------------------------------------------------------------------------- 1 | /*==================================================================================== 2 | This sketch supports for the ESP6266 and ESP32 SPIFFS filing system 3 | 4 | Created by Bodmer 15th Jan 2017 5 | ==================================================================================*/ 6 | 7 | //==================================================================================== 8 | // Print a SPIFFS directory list (root directory) 9 | //==================================================================================== 10 | 11 | void listFiles(void) { 12 | Serial.println(); 13 | Serial.println("SPIFFS files found:"); 14 | 15 | #ifdef ESP32 16 | listDir(SPIFFS, "/", true); 17 | #else 18 | fs::Dir dir = SPIFFS.openDir("/"); // Root directory 19 | String line = "====================================="; 20 | 21 | Serial.println(line); 22 | Serial.println(" File name Size"); 23 | Serial.println(line); 24 | 25 | while (dir.next()) { 26 | String fileName = dir.fileName(); 27 | Serial.print(fileName); 28 | int spaces = 25 - fileName.length(); // Tabulate nicely 29 | if (spaces < 0) spaces = 1; 30 | while (spaces--) Serial.print(" "); 31 | fs::File f = dir.openFile("r"); 32 | Serial.print(f.size()); Serial.println(" bytes"); 33 | yield(); 34 | } 35 | 36 | Serial.println(line); 37 | #endif 38 | Serial.println(); 39 | delay(1000); 40 | } 41 | //==================================================================================== 42 | 43 | #ifdef ESP32 44 | void listDir(fs::FS &fs, const char * dirname, uint8_t levels) { 45 | Serial.printf("Listing directory: %s\n", dirname); 46 | 47 | fs::File root = fs.open(dirname); 48 | if (!root) { 49 | Serial.println("Failed to open directory"); 50 | return; 51 | } 52 | if (!root.isDirectory()) { 53 | Serial.println("Not a directory"); 54 | return; 55 | } 56 | 57 | fs::File file = root.openNextFile(); 58 | while (file) { 59 | 60 | if (file.isDirectory()) { 61 | Serial.print("DIR : "); 62 | String fileName = file.name(); 63 | Serial.print(fileName); 64 | if (levels) { 65 | listDir(fs, file.name(), levels - 1); 66 | } 67 | } else { 68 | String fileName = file.name(); 69 | Serial.print(" " + fileName); 70 | int spaces = 32 - fileName.length(); // Tabulate nicely 71 | if (spaces < 1) spaces = 1; 72 | while (spaces--) Serial.print(" "); 73 | String fileSize = (String) file.size(); 74 | spaces = 8 - fileSize.length(); // Tabulate nicely 75 | if (spaces < 1) spaces = 1; 76 | while (spaces--) Serial.print(" "); 77 | Serial.println(fileSize + " bytes"); 78 | } 79 | 80 | file = root.openNextFile(); 81 | } 82 | } 83 | #endif 84 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/160 x 128/TFT_Print_Test/TFT_Print_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Test the tft.print() viz embedded tft.write() function 3 | 4 | This sketch used font 2, 4, 7 5 | 6 | Make sure all the display driver and pin comnenctions are correct by 7 | editting the User_Setup.h file in the TFT_eSPI library folder. 8 | 9 | Note that yield() or delay(0) must be called in long duration for/while 10 | loops to stop the ESP8266 watchdog triggering. 11 | 12 | ######################################################################### 13 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 14 | ######################################################################### 15 | */ 16 | 17 | 18 | #include // Graphics and font library for ST7735 driver chip 19 | #include 20 | 21 | TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.h 22 | 23 | #define TFT_GREY 0x5AEB // New colour 24 | 25 | void setup(void) { 26 | tft.init(); 27 | tft.setRotation(1); 28 | } 29 | 30 | void loop() { 31 | 32 | // Fill screen with grey so we can see the effect of printing with and without 33 | // a background colour defined 34 | tft.fillScreen(TFT_GREY); 35 | 36 | // Set "cursor" at top left corner of display (0,0) and select font 2 37 | // (cursor will move to next line automatically during printing with 'tft.println' 38 | // or stay on the line is there is room for the text with tft.print) 39 | tft.setCursor(0, 0, 2); 40 | // Set the font colour to be white with a black background, set text size multiplier to 1 41 | tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1); 42 | // We can now plot text on screen using the "print" class 43 | tft.println("Hello World!"); 44 | 45 | // Set the font colour to be yellow with no background, set to font 7 46 | tft.setTextColor(TFT_YELLOW); tft.setTextFont(2); 47 | tft.println(1234.56); 48 | 49 | // Set the font colour to be red with black background, set to font 4 50 | tft.setTextColor(TFT_RED,TFT_BLACK); tft.setTextFont(4); 51 | tft.println((long)3735928559, HEX); // Should print DEADBEEF 52 | 53 | // Set the font colour to be green with black background, set to font 2 54 | tft.setTextColor(TFT_GREEN,TFT_BLACK); 55 | tft.setTextFont(2); 56 | tft.println("Groop"); 57 | 58 | // Test some print formatting functions 59 | float fnumber = 123.45; 60 | // Set the font colour to be blue with no background, set to font 2 61 | tft.setTextColor(TFT_BLUE); tft.setTextFont(2); 62 | tft.print("Float = "); tft.println(fnumber); // Print floating point number 63 | tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary 64 | tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal 65 | 66 | while(1) yield(); // We must yield() to stop a watchdog timeout. 67 | } 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/320 x 240/TFT_Float_Test/TFT_Float_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Tests the updated floating point plot function 3 | The datum is set to the centre of the 320 x 240 screen 4 | so numbers are printed the middle. 5 | 6 | The last test shows the datum point as a red dot. 7 | 8 | Normally strings are printed relative to the top left corner but this can be 9 | changed with the setTextDatum() function. The library has #defines for: 10 | 11 | TL_DATUM 0 //Top left 12 | TC_DATUM 1 //Top centre 13 | TR_DATUM 2 //Top right 14 | ML_DATUM 3 //Middle left 15 | MC_DATUM 4 //Middle centre 16 | MR_DATUM 5 //Middle right 17 | BL_DATUM 6 //Bottom left 18 | BC_DATUM 7 //Bottom centre 19 | BR_DATUM 8 //Bottom right 20 | 21 | 22 | Needs fonts 2 and 6 23 | 24 | Make sure all the display driver and pin comnenctions are correct by 25 | editting the User_Setup.h file in the TFT_eSPI library folder. 26 | 27 | ######################################################################### 28 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 29 | ######################################################################### 30 | */ 31 | 32 | 33 | #include // Hardware-specific library 34 | #include 35 | 36 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 37 | 38 | unsigned long drawTime = 0; 39 | 40 | void setup(void) { 41 | Serial.begin(115200); 42 | tft.init(); 43 | tft.setRotation(1); 44 | 45 | } 46 | 47 | void loop() { 48 | 49 | char tmp[12]; 50 | 51 | tft.fillScreen(TFT_BLACK); 52 | tft.setTextColor(TFT_WHITE, TFT_BLACK); 53 | 54 | // Datum is middle centre 55 | tft.setTextDatum(MC_DATUM); 56 | 57 | // Test floating point drawing function: 58 | // drawFloat(value, precision, x, y, font); 59 | 60 | float test = 67.125; 61 | tft.drawFloat(test, 4, 160, 120, 6); 62 | tft.drawString(dtostrf(test,4,4,tmp), 100, 200, 6); 63 | 64 | delay(1000); 65 | tft.fillScreen(TFT_BLACK); 66 | 67 | test = -0.555555; 68 | tft.drawFloat(test, 3, 160, 120, 6); 69 | tft.drawString(dtostrf(test,2,2,tmp), 100, 200, 6); 70 | 71 | delay(1000); 72 | tft.fillScreen(TFT_BLACK); 73 | 74 | test = 0.123; 75 | tft.drawFloat(test, 4, 160, 120, 6); 76 | 77 | tft.drawString(dtostrf(test,4,4,tmp), 100, 200, 6); 78 | 79 | delay(1000); 80 | tft.fillScreen(TFT_BLACK); 81 | 82 | // This does not work at the moment.... 83 | test = 9999999; 84 | tft.drawFloat(test, 0, 160, 120, 6); 85 | tft.drawString(dtostrf(test,4,4,tmp), 100, 200, 6); 86 | delay(1000); 87 | 88 | //Plot the datum for the last number 89 | tft.fillCircle(160,120,5,TFT_RED); 90 | tft.setTextDatum(MC_DATUM); 91 | tft.setTextColor(TFT_BLACK); 92 | tft.drawString("X", 160, 120, 2); 93 | 94 | delay(4000); 95 | } 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /README.MD: -------------------------------------------------------------------------------- 1 | # TTGO T-Display 2 | 3 | ## Quick start 4 | 5 | 1. **Install USB driver**, [CHxxx Series MAC driver](http://www.wch-ic.com/downloads/CH34XSER_MAC_ZIP.html) , [CHxxx Series Windows driver](http://www.wch-ic.com/downloads/CH343SER_ZIP.html),[CP21xx Series driver](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=downloads) 6 | 2. Copy **TFT_eSPI** to the **** directory 7 | 3. Open **Arduino IDE,** find **TFT_eSPI** in the file and example, the **T-Display** factory test program is located at **TFT_eSPI -> FactoryTest**, you can also use other sample programs provided by TFT_eSPI 8 | 4. In the **Arduino IDE** tool options, select the development board **ESP32 Dev Module**, **select Disable in the PSRAM option**, **select 4MB in the Flash Size option**, Other keep the default 9 | 5. Select the corresponding serial port. If you are not sure, please remove all the serial ports, leaving the board in the USB connection state, just select that one 10 | 6. Finally, click upload, the right arrow next to the tick 11 | 7. Please note that the highest version currently supported by TFT_eSPI is 2.0.14. Compiling with a version higher than 2.0.14 will result in an error. Please pay attention to the selection of esp32 version. `Tools -> Board -> Boards Manage -> Search esp32 -> 2.0.14 -> Install` 12 | 13 | ------------------------- 14 | 1. **安装 USB 驱动**, [CHxxx Series MAC driver](http://www.wch-ic.com/downloads/CH34XSER_MAC_ZIP.html) , [CHxxx Series Windows driver](http://www.wch-ic.com/downloads/CH343SER_ZIP.html), [CP21xx Series driver](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers?tab=downloads) 15 | 2. 拷贝 **TFT_eSPI** 到 **** 目录内 16 | 3. 打开**ArduinoIDE** , 在文件,示例中找到**TFT_eSPI**, T-Display出厂测试程序位于**TFT_eSPI -> FactoryTest**,你也可以使用其他TFT_eSPI提供的示例程序 17 | 4. 在**Arduino IDE** 工具选项中 , 开发板选择 **ESP32 Dev Module**,**在PSRAM选项中选择Disable**, **Flash Size 选项中选择4MB** ,其它保持默认 18 | 5. 选择对应的串行端口,如果不清楚请移除所有串行端口,之保留板子处于USB连接状态,选择那一个即可 19 | 6. 最后可点击上传即可,勾号旁边的向右箭头 20 | 7. 请注意,TFT_eSPI 目前支持最高版本为2.0.14 ,高于 2.0.14 编译则会报错,请注意esp32 版本的选择:`Tools -> Board -> Boards Manage ->Search esp32 -> 2.0.14 -> Install` 21 | 22 | ------------------------- 23 | ## SD card connection 24 | - Demonstrate how to use the second SPI device, using the SD card as a demonstration device 25 | - 使用SD卡作为演示设备,演示如何使用第二个SPI设备 26 | ![](image/SD.jpg) 27 | 28 | ## Pinout 29 | | Name | V18 | 30 | | ---------- | ------ | 31 | | TFT Driver | ST7789 | 32 | | TFT_MISO | N/A | 33 | | TFT_MOSI | 19 | 34 | | TFT_SCLK | 18 | 35 | | TFT_CS | 5 | 36 | | TFT_DC | 16 | 37 | | TFT_RST | 23 | 38 | | TFT_BL | 4 | 39 | | I2C_SDA | 21 | 40 | | I2C_SCL | 22 | 41 | | ADC_IN | 34 | 42 | | BUTTON1 | 35 | 43 | | BUTTON2 | 0 | 44 | | ADC Power | 14 | 45 | 46 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/ePaper/Floyd_Steinberg/SPIFFS.ino: -------------------------------------------------------------------------------- 1 | 2 | // Call up the SPIFFS FLASH filing system 3 | #define FS_NO_GLOBALS 4 | #include 5 | 6 | #ifdef ESP32 7 | #include "SPIFFS.h" 8 | #endif 9 | 10 | /*==================================================================================== 11 | This sketch supports the ESP6266 and ESP32 SPIFFS filing system 12 | 13 | Created by Bodmer 15th Jan 2017 14 | ==================================================================================*/ 15 | 16 | //==================================================================================== 17 | // Print a SPIFFS directory list (root directory) 18 | //==================================================================================== 19 | 20 | void listFiles(void) { 21 | Serial.println(); 22 | Serial.println("SPIFFS files found:"); 23 | 24 | #ifdef ESP32 25 | listDir(SPIFFS, "/", true); 26 | #else 27 | fs::Dir dir = SPIFFS.openDir("/"); // Root directory 28 | String line = "====================================="; 29 | 30 | Serial.println(line); 31 | Serial.println(" File name Size"); 32 | Serial.println(line); 33 | 34 | while (dir.next()) { 35 | String fileName = dir.fileName(); 36 | Serial.print(fileName); 37 | int spaces = 25 - fileName.length(); // Tabulate nicely 38 | if (spaces < 0) spaces = 1; 39 | while (spaces--) Serial.print(" "); 40 | fs::File f = dir.openFile("r"); 41 | Serial.print(f.size()); Serial.println(" bytes"); 42 | yield(); 43 | } 44 | 45 | Serial.println(line); 46 | #endif 47 | Serial.println(); 48 | delay(1000); 49 | } 50 | //==================================================================================== 51 | 52 | #ifdef ESP32 53 | void listDir(fs::FS &fs, const char * dirname, uint8_t levels) { 54 | Serial.printf("Listing directory: %s\n", dirname); 55 | 56 | fs::File root = fs.open(dirname); 57 | if (!root) { 58 | Serial.println("Failed to open directory"); 59 | return; 60 | } 61 | if (!root.isDirectory()) { 62 | Serial.println("Not a directory"); 63 | return; 64 | } 65 | 66 | fs::File file = root.openNextFile(); 67 | while (file) { 68 | 69 | if (file.isDirectory()) { 70 | Serial.print("DIR : "); 71 | String fileName = file.name(); 72 | Serial.print(fileName); 73 | if (levels) { 74 | listDir(fs, file.name(), levels - 1); 75 | } 76 | } else { 77 | String fileName = file.name(); 78 | Serial.print(" " + fileName); 79 | int spaces = 32 - fileName.length(); // Tabulate nicely 80 | if (spaces < 1) spaces = 1; 81 | while (spaces--) Serial.print(" "); 82 | String fileSize = (String) file.size(); 83 | spaces = 8 - fileSize.length(); // Tabulate nicely 84 | if (spaces < 1) spaces = 1; 85 | while (spaces--) Serial.print(" "); 86 | Serial.println(fileSize + " bytes"); 87 | } 88 | 89 | file = root.openNextFile(); 90 | } 91 | } 92 | #endif 93 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/320 x 240/TFT_Print_Test/TFT_Print_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Test the tft.print() viz embedded tft.write() function 3 | 4 | This sketch used font 2, 4, 7 5 | 6 | Make sure all the display driver and pin comnenctions are correct by 7 | editting the User_Setup.h file in the TFT_eSPI library folder. 8 | 9 | ######################################################################### 10 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 11 | ######################################################################### 12 | */ 13 | 14 | 15 | #include // Graphics and font library for ILI9341 driver chip 16 | #include 17 | 18 | #define TFT_GREY 0x5AEB // New colour 19 | 20 | TFT_eSPI tft = TFT_eSPI(); // Invoke library 21 | 22 | 23 | void setup(void) { 24 | tft.init(); 25 | tft.setRotation(2); 26 | } 27 | 28 | void loop() { 29 | 30 | // Fill screen with grey so we can see the effect of printing with and without 31 | // a background colour defined 32 | tft.fillScreen(TFT_GREY); 33 | 34 | // Set "cursor" at top left corner of display (0,0) and select font 2 35 | // (cursor will move to next line automatically during printing with 'tft.println' 36 | // or stay on the line is there is room for the text with tft.print) 37 | tft.setCursor(0, 0, 2); 38 | // Set the font colour to be white with a black background, set text size multiplier to 1 39 | tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1); 40 | // We can now plot text on screen using the "print" class 41 | tft.println("Hello World!"); 42 | 43 | // Set the font colour to be yellow with no background, set to font 7 44 | tft.setTextColor(TFT_YELLOW); tft.setTextFont(7); 45 | tft.println(1234.56); 46 | 47 | // Set the font colour to be red with black background, set to font 4 48 | tft.setTextColor(TFT_RED,TFT_BLACK); tft.setTextFont(4); 49 | //tft.println(3735928559L, HEX); // Should print DEADBEEF 50 | 51 | // Set the font colour to be green with black background, set to font 4 52 | tft.setTextColor(TFT_GREEN,TFT_BLACK); 53 | tft.setTextFont(4); 54 | tft.println("Groop"); 55 | tft.println("I implore thee,"); 56 | 57 | // Change to font 2 58 | tft.setTextFont(2); 59 | tft.println("my foonting turlingdromes."); 60 | tft.println("And hooptiously drangle me"); 61 | tft.println("with crinkly bindlewurdles,"); 62 | // This next line is deliberately made too long for the display width to test 63 | // automatic text wrapping onto the next line 64 | tft.println("Or I will rend thee in the gobberwarts with my blurglecruncheon, see if I don't!"); 65 | 66 | // Test some print formatting functions 67 | float fnumber = 123.45; 68 | // Set the font colour to be blue with no background, set to font 4 69 | tft.setTextColor(TFT_BLUE); tft.setTextFont(4); 70 | tft.print("Float = "); tft.println(fnumber); // Print floating point number 71 | tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary 72 | tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal 73 | delay(10000); 74 | } 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/Touch_calibrate/Touch_calibrate.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Sketch to generate the setup() calibration values, these are reported 3 | to the Serial Monitor. 4 | 5 | The sketch has been tested on the ESP8266 and screen with XPT2046 driver. 6 | */ 7 | 8 | #include 9 | #include // Hardware-specific library 10 | 11 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 12 | 13 | //------------------------------------------------------------------------------------------ 14 | 15 | void setup() { 16 | // Use serial port 17 | Serial.begin(115200); 18 | 19 | // Initialise the TFT screen 20 | tft.init(); 21 | 22 | // Set the rotation before we calibrate 23 | tft.setRotation(1); 24 | 25 | // Calibrate the touch screen and retrieve the scaling factors 26 | touch_calibrate(); 27 | 28 | /* 29 | // Replace above line with the code sent to Serial Monitor 30 | // once calibration is complete, e.g.: 31 | uint16_t calData[5] = { 286, 3534, 283, 3600, 6 }; 32 | tft.setTouch(calData); 33 | */ 34 | 35 | // Clear the screen 36 | tft.fillScreen(TFT_BLACK); 37 | tft.drawCentreString("Touch screen to test!",tft.width()/2, tft.height()/2, 2); 38 | } 39 | 40 | //------------------------------------------------------------------------------------------ 41 | 42 | void loop(void) { 43 | uint16_t x = 0, y = 0; // To store the touch coordinates 44 | 45 | // Pressed will be set true is there is a valid touch on the screen 46 | boolean pressed = tft.getTouch(&x, &y); 47 | 48 | // Draw a white spot at the detected coordinates 49 | if (pressed) { 50 | tft.fillCircle(x, y, 2, TFT_WHITE); 51 | //Serial.print("x,y = "); 52 | //Serial.print(x); 53 | //Serial.print(","); 54 | //Serial.println(y); 55 | } 56 | } 57 | 58 | //------------------------------------------------------------------------------------------ 59 | 60 | // Code to run a screen calibration, not needed when calibration values set in setup() 61 | void touch_calibrate() 62 | { 63 | uint16_t calData[5]; 64 | uint8_t calDataOK = 0; 65 | 66 | // Calibrate 67 | tft.fillScreen(TFT_BLACK); 68 | tft.setCursor(20, 0); 69 | tft.setTextFont(2); 70 | tft.setTextSize(1); 71 | tft.setTextColor(TFT_WHITE, TFT_BLACK); 72 | 73 | tft.println("Touch corners as indicated"); 74 | 75 | tft.setTextFont(1); 76 | tft.println(); 77 | 78 | tft.calibrateTouch(calData, TFT_MAGENTA, TFT_BLACK, 15); 79 | 80 | Serial.println(); Serial.println(); 81 | Serial.println("// Use this calibration code in setup():"); 82 | Serial.print(" uint16_t calData[5] = "); 83 | Serial.print("{ "); 84 | 85 | for (uint8_t i = 0; i < 5; i++) 86 | { 87 | Serial.print(calData[i]); 88 | if (i < 4) Serial.print(", "); 89 | } 90 | 91 | Serial.println(" };"); 92 | Serial.print(" tft.setTouch(calData);"); 93 | Serial.println(); Serial.println(); 94 | 95 | tft.fillScreen(TFT_BLACK); 96 | 97 | tft.setTextColor(TFT_GREEN, TFT_BLACK); 98 | tft.println("Calibration complete!"); 99 | tft.println("Calibration code sent to Serial port."); 100 | 101 | delay(4000); 102 | } 103 | 104 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/480 x 320/TFT_Print_Test/TFT_Print_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Test the tft.print() viz the libraries embedded write() function 3 | 4 | This sketch used font 2, 4, 7 5 | 6 | Make sure all the required fonts are loaded by editting the 7 | User_Setup.h file in the TFT_eSPI library folder. 8 | 9 | ######################################################################### 10 | ###### DON'T FORGET TO UPDATE THE User_Setup.h FILE IN THE LIBRARY ###### 11 | ######################################################################### 12 | */ 13 | 14 | #include 15 | 16 | #include // Hardware-specific library 17 | 18 | TFT_eSPI tft = TFT_eSPI(); // Invoke custom library 19 | 20 | #define TFT_GREY 0x5AEB // New colour 21 | 22 | 23 | void setup(void) { 24 | tft.init(); 25 | tft.setRotation(2); 26 | } 27 | 28 | void loop() { 29 | 30 | // Fill screen with random colour so we can see the effect of printing with and without 31 | // a background colour defined 32 | tft.fillScreen(random(0xFFFF)); 33 | 34 | // Set "cursor" at top left corner of display (0,0) and select font 2 35 | // (cursor will move to next line automatically during printing with 'tft.println' 36 | // or stay on the line is there is room for the text with tft.print) 37 | tft.setCursor(0, 0, 2); 38 | // Set the font colour to be white with a black background, set text size multiplier to 1 39 | tft.setTextColor(TFT_WHITE,TFT_BLACK); tft.setTextSize(1); 40 | // We can now plot text on screen using the "print" class 41 | tft.println("Hello World!"); 42 | 43 | // Set the font colour to be yellow with no background, set to font 7 44 | tft.setTextColor(TFT_YELLOW); tft.setTextFont(7); 45 | tft.println(1234.56); 46 | 47 | // Set the font colour to be red with black background, set to font 4 48 | tft.setTextColor(TFT_RED,TFT_BLACK); tft.setTextFont(4); 49 | tft.println((long)3735928559, HEX); // Should print DEADBEEF 50 | 51 | // Set the font colour to be green with black background, set to font 4 52 | tft.setTextColor(TFT_GREEN,TFT_BLACK); 53 | tft.setTextFont(4); 54 | tft.println("Groop"); 55 | tft.println("I implore thee,"); 56 | 57 | // Change to font 2 58 | tft.setTextFont(2); 59 | tft.println(F("my foonting turlingdromes.")); // Can store strings in FLASH to save RAM 60 | tft.println("And hooptiously drangle me"); 61 | tft.println("with crinkly bindlewurdles,"); 62 | // This next line is deliberately made too long for the display width to test 63 | // automatic text wrapping onto the next line 64 | tft.println("Or I will rend thee in the gobberwarts with my blurglecruncheon, see if I don't!"); 65 | 66 | // Test some print formatting functions 67 | float fnumber = 123.45; 68 | // Set the font colour to be blue with no background, set to font 4 69 | tft.setTextColor(TFT_BLUE); tft.setTextFont(4); 70 | tft.print("Float = "); tft.println(fnumber); // Print floating point number 71 | tft.print("Binary = "); tft.println((int)fnumber, BIN); // Print as integer value in binary 72 | tft.print("Hexadecimal = "); tft.println((int)fnumber, HEX); // Print as integer number in Hexadecimal 73 | delay(10000); 74 | } 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /TFT_eSPI/examples/Generic/drawXBitmap/xbm.h: -------------------------------------------------------------------------------- 1 | // Images can be converted to XBM format by using the online converter here: 2 | // https://www.online-utility.org/image/convert/to/XBM 3 | 4 | // The output must be pasted in a header file, renamed and adjusted to appear 5 | // as as a const unsigned char array in PROGMEM (FLASH program memory). 6 | 7 | // The xbm format adds padding to pixel rows so they are a whole number of bytes 8 | // In this example 50 pixel width means 56 bits = 7 bytes 9 | // the 50 height then means array uses 50 x 7 = 350 bytes of FLASH 10 | // The library ignores the padding bits when drawing the image on the display. 11 | 12 | // Example of the correct format is shown below 13 | 14 | #include // PROGMEM support header 15 | 16 | // Espressif logo 50 x 50 pixel array in XBM format 17 | #define logoWidth 50 // logo width 18 | #define logoHeight 50 // logo height 19 | 20 | // Image is stored in this array 21 | PROGMEM const unsigned char logo[] = { 22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x00, 0x00, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x01, 0x00, 26 | 0x00, 0x00, 0x00, 0x07, 0xFC, 0x07, 0x00, 0x00, 0x00, 0x82, 0x7F, 0xF0, 27 | 0x1F, 0x00, 0x00, 0x00, 0xC6, 0xFF, 0xC3, 0x3F, 0x00, 0x00, 0x00, 0xE7, 28 | 0xFF, 0x8F, 0x7F, 0x00, 0x00, 0x80, 0xE3, 0xFF, 0x1F, 0xFE, 0x00, 0x00, 29 | 0x80, 0xE1, 0xFF, 0x7F, 0xFC, 0x01, 0x00, 0xC0, 0x00, 0xFF, 0xFF, 0xF8, 30 | 0x03, 0x00, 0xE0, 0x00, 0xE0, 0xFF, 0xF1, 0x03, 0x00, 0x60, 0xF0, 0x81, 31 | 0xFF, 0xE3, 0x07, 0x00, 0x60, 0xFC, 0x1F, 0xFE, 0xC7, 0x07, 0x00, 0x30, 32 | 0xFE, 0x7F, 0xF8, 0x8F, 0x0F, 0x00, 0x30, 0xFF, 0xFF, 0xF1, 0x9F, 0x0F, 33 | 0x00, 0xB0, 0xFF, 0xFF, 0xE3, 0x3F, 0x0F, 0x00, 0xB0, 0xFF, 0xFF, 0xC7, 34 | 0x3F, 0x1E, 0x00, 0xB8, 0xFF, 0xFF, 0x8F, 0x7F, 0x1E, 0x00, 0x98, 0x1F, 35 | 0xFC, 0x3F, 0xFF, 0x1C, 0x00, 0xB8, 0x3F, 0xE0, 0x3F, 0xFE, 0x1C, 0x00, 36 | 0x98, 0xFF, 0xC3, 0x7F, 0xFE, 0x19, 0x00, 0x98, 0xFF, 0x0F, 0xFF, 0xFC, 37 | 0x19, 0x00, 0x38, 0xFF, 0x3F, 0xFF, 0xFC, 0x01, 0x00, 0x30, 0xFE, 0x7F, 38 | 0xFE, 0xF9, 0x03, 0x00, 0x30, 0xFC, 0xFF, 0xFC, 0xF9, 0x03, 0x00, 0x30, 39 | 0xF8, 0xFF, 0xF8, 0xF3, 0x03, 0x00, 0x30, 0x00, 0xFF, 0xF9, 0xF3, 0x03, 40 | 0x00, 0x70, 0x00, 0xFC, 0xF9, 0xF3, 0x07, 0x00, 0x60, 0x00, 0xF8, 0xF3, 41 | 0xF3, 0x07, 0x00, 0xE0, 0xF8, 0xF8, 0xF3, 0xF7, 0x03, 0x00, 0xC0, 0xF8, 42 | 0xF1, 0xF3, 0xE3, 0x03, 0x00, 0xC0, 0xFD, 0xF1, 0xF3, 0xF7, 0x01, 0x00, 43 | 0x80, 0xFD, 0xF1, 0xF3, 0xE7, 0x00, 0x00, 0x00, 0xFF, 0xF1, 0xF3, 0x07, 44 | 0x00, 0x00, 0x00, 0xFF, 0xF8, 0xF3, 0x07, 0x00, 0x00, 0x00, 0x7E, 0xF8, 45 | 0xF3, 0x83, 0x03, 0x00, 0x00, 0x3C, 0xF8, 0xF3, 0xC3, 0x01, 0x00, 0x00, 46 | 0x70, 0xF8, 0xF9, 0xE3, 0x00, 0x00, 0x00, 0xE0, 0xE1, 0x41, 0x78, 0x00, 47 | 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFD, 48 | 0x07, 0x00, 0x00, 0x00, 0x00, 0xF8, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x00, 49 | 0x80, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 50 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 51 | 0x00, 0x00, }; 52 | 53 | --------------------------------------------------------------------------------