1. static const uint8_t name[] PROGMEM =
    2. { //Add image code here.
    3. }
    4. tft.drawBitmapx y name sx sy 0x0000);
    5. 首先你应将您的图像转换为十六进制代码。从以下链接下载该软件。如果您不想更改软件的设置,则必须反转图像的颜色并使图像水平镜像并逆时针旋转 90 度。现在将其添加到软件并进行转换。打开导出的文件并将十六进制代码复制到 Arduino IDE x y 是图像的位置。 sx sy 是图像的大小。您可以在最后一个输入中更改图像的颜色。
    6. RGB 彩色图像显示
    7. const uint16_t name[] PROGMEM = {
    8. //Add image code here.
    9. }
    10. tft.drawRGBBitmapx y name sx sy);
    11. 首先,您应该将图像转换为代码。使用此链接转换图像:
    12. http://www.rinkydinkelectronics.com/t_imageconverter565.php
    13. 上传图像并下载 UTFT 库可以处理的转换文件。现在将十六进制代码复制到 Arduino IDE x y 是图像的位置。 sx sy 是图像的大小。
    14. 预先设计的模板
    15. 载入
    16. 在这个模板中,我们只使用了一个字符串和 8 个实心圆圈按顺序改变颜色。要在静态点周围绘制圆圈,可以使用 sin(); cos(); 功能。您应该定义 PI 编号。要更改颜色,可以使用 color565(); 功能并替换您的 RGB 代码。
    17. #include Adafruit_GFX.h
    18. #include MCUFRIEND_kbv.h
    19. MCUFRIEND_kbv tft;
    20. #include Fonts/FreeSans9pt7b.h
    21. #include Fonts/FreeSans12pt7b.h
    22. #include Fonts/FreeSerif12pt7b.h
    23. #include FreeDefaultFonts.h
    24. #define PI 3.1415926535897932384626433832795
    25. int col8];
    26. void showmsgXYint x int y int sz const GFXfont f const char msg
    27. {
    28. int16_t x1 y1;
    29. uint16_t wid ht;
    30. tft.setFontf);
    31. tft.setCursorx y);
    32. tft.setTextColor0x0000);
    33. tft.setTextSizesz);
    34. tft.printmsg);
    35. }
    36. void setup() {
    37. tft.reset();
    38. Serial.begin9600);
    39. uint16_t ID = tft.readID();
    40. tft.beginID);
    41. tft.setRotation1);
    42. tft.invertDisplaytrue);
    43. tft.fillScreen0xffff);
    44. showmsgXY170 250 2 &FreeSans9pt7b Loading.。.”);
    45. col0 = tft.color565155 0 50);
    46. col1 = tft.color565170 30 80);
    47. col2 = tft.color565195 60 110);
    48. col3 = tft.color565215 90 140);
    49. col4 = tft.color565230 120 170);
    50. col5 = tft.color565250 150 200);
    51. col6 = tft.color565255 180 220);
    52. col7 = tft.color565255 210 240);
    53. }
    54. void loop() {
    55. for int i = 8; i 0; i--) {
    56. tft.fillCircle240 + 40 cos(-i PI / 4)), 120 + 40 sin(-i PI / 4)), 10 col0]); delay15);
    57. tft.fillCircle240 + 40 cos(-(i + 1PI / 4)), 120 + 40 sin(-(i + 1PI / 4)), 10 col1]); delay15);
    58. tft.fillCircle240 + 40 cos(-(i + 2PI / 4)), 120 + 40 sin(-(i + 2PI / 4)), 10 col2]); delay15);
    59. tft.fillCircle240 + 40 cos(-(i + 3PI / 4)), 120 + 40 sin(-(i + 3PI / 4)), 10 col3]); delay15);
    60. tft.fillCircle240 + 40 cos(-(i + 4PI / 4)), 120 + 40 sin(-(i + 4PI / 4)), 10 col4]); delay15);
    61. tft.fillCircle240 + 40 cos(-(i + 5PI / 4)), 120 + 40 sin(-(i + 5PI / 4)), 10 col5]); delay15);
    62. tft.fillCircle240 + 40 cos(-(i + 6PI / 4)), 120 + 40 sin(-(i + 6PI / 4)), 10 col6]); delay15);
    63. tft.fillCircle240 + 40 cos(-(i + 7PI / 4)), 120 + 40 sin(-(i + 7PI / 4)), 10 col7]); delay15);
    64. }
    65. }
    66. 徽标演示
    67. 在此模板中,我们将 a.jpg 图像转换为. c 文件并添加到代码中,写了一个字符串并使用淡入淡出代码进行显示。然后我们使用滚动代码向左移动屏幕。下载. h 文件并将其添加到 Arduino sketch 的文件夹中。
    68. #include Adafruit_GFX.h // Core graphics library
    69. #include MCUFRIEND_kbv.h // Hardware-specific library
    70. MCUFRIEND_kbv tft;
    71. #include Ard_Logo.h
    72. #define BLACK 0x0000
    73. #define RED 0xF800
    74. #define GREEN 0x07E0
    75. #define WHITE 0xFFFF
    76. #define GREY 0x8410
    77. #include Fonts/FreeSans9pt7b.h
    78. #include Fonts/FreeSans12pt7b.h
    79. #include Fonts/FreeSerif12pt7b.h
    80. #include FreeDefaultFonts.h
    81. void showmsgXYint x int y int sz const GFXfont f const char msg
    82. {
    83. int16_t x1 y1;
    84. uint16_t wid ht;
    85. tft.setFontf);
    86. tft.setCursorx y);
    87. tft.setTextSizesz);
    88. tft.printlnmsg);
    89. }
    90. uint8_t r = 255 g = 255 b = 255;
    91. uint16_t color;
    92. void setup()
    93. {
    94. Serial.begin9600);
    95. uint16_t ID = tft.readID();
    96. tft.beginID);
    97. tft.invertDisplaytrue);
    98. tft.setRotation1);
    99. }
    100. void loopvoid
    101. {
    102. tft.invertDisplaytrue);
    103. tft.fillScreenWHITE);
    104. tft.drawRGBBitmap100 50 Logo 350 200);
    105. delay1000);
    106. tft.setTextSize2);
    107. for int j = 0; j 20; j++) {
    108. color = tft.color565r -= 12 g -= 12 b -= 12);
    109. tft.setTextColorcolor);
    110. showmsgXY95 280 1 &FreeSans12pt7b ELECTROPEAK PRESENTS”);
    111. delay20);
    112. }
    113. delay1000);
    114. for int i = 0; i 480; i++) {
    115. tft.vertScroll0 480 i);
    116. tft.drawFastVLinei 0 320 0xffff); // vertical line
    117. delay5);}
    118. while 1);
    119. }