1. 在这个模板中,我们添加了将转换后的图像转换为代码,然后使用两个黑色和白色弧来创建卷的指针。下载. h 文件并将其添加到 Arduino 草图的文件夹中。
    2. #include Adafruit_GFX.h
    3. #include MCUFRIEND_kbv.h
    4. MCUFRIEND_kbv tft;
    5. #include Volume.h
    6. #define BLACK 0x0000
    7. int a = 0b = 4000c = 1000d = 3000;
    8. int s=2000;
    9. int j j2;
    10. int i i2;
    11. int White;
    12. void setup()
    13. {
    14. Serial.begin9600);
    15. uint16_t ID = tft.readID();
    16. tft.beginID);
    17. tft.invertDisplaytrue);
    18. tft.setRotation1);
    19. }
    20. void loopvoid
    21. {
    22. tft.invertDisplaytrue);
    23. tft.fillScreenBLACK);
    24. tft.drawRGBBitmap0 0 test 480 320);
    25. White = tft.color565255 255 255);
    26. while1){
    27. if a s {
    28. j = 14 sinPI a / 2000));
    29. i = 14 cosPI a / 2000));
    30. j2 = 1 sinPI a / 2000));
    31. i2 = 1 cosPI a / 2000));
    32. tft.drawLinei2 + 62 j2 + 240 i + 62 j + 240 White);
    33. j = 14 sinPI a-300 / 2000));
    34. i = 14 cosPI a-300 / 2000));
    35. j2 = 1 sinPI a-300 / 2000));
    36. i2 = 1 cosPI a-300 / 2000));
    37. tft.drawLinei2 + 62 j2 + 240 i + 62 j + 240 0x0000);
    38. tft.fillRect50 285 30 30 0x0000);
    39. tft.setTextSize2);
    40. tft.setTextColor0xffff);
    41. tft.setCursor50 285);
    42. tft.printa / 40); tft.print(“%”);
    43. a++;
    44. }
    45. if b s {
    46. j = 14 sinPI b / 2000));
    47. i = 14 cosPI b / 2000));
    48. j2 = 1 sinPI b / 2000));
    49. i2 = 1 cosPI b / 2000));
    50. tft.drawLinei2 + 180 j2 + 240 i + 180 j + 240 White);
    51. j = 14 sinPI b-300 / 2000));
    52. i = 14 cosPI b-300 / 2000));
    53. j2 = 1 sinPI b-300 / 2000));
    54. i2 = 1 cosPI b-300 / 2000));
    55. tft.drawLinei2 + 180 j2 + 240 i + 180 j + 240 0x0000);
    56. tft.fillRect168 285 30 30 0x0000);
    57. tft.setTextSize2);
    58. tft.setTextColor0xffff);
    59. tft.setCursor168 285);
    60. tft.printb / 40); tft.print(“%”);
    61. b++;}
    62. if c s {
    63. j = 14 sinPI c / 2000));
    64. i = 14 cosPI c / 2000));
    65. j2 = 1 sinPI c / 2000));
    66. i2 = 1 cosPI c / 2000));
    67. tft.drawLinei2 + 297 j2 + 240 i + 297 j + 240 White);
    68. j = 14 sinPI c-300 / 2000));
    69. i = 14 cosPI c-300 / 2000));
    70. j2 = 1 sinPI c-300 / 2000));
    71. i2 = 1 cosPI c-300 / 2000));
    72. tft.drawLinei2 + 297 j2 + 240 i + 297 j + 240 0x0000);
    73. tft.fillRect286 285 30 30 0x0000);
    74. tft.setTextSize2);
    75. tft.setTextColor0xffff);
    76. tft.setCursor286 285);
    77. tft.printc / 40); tft.print(“%”);
    78. c++;}
    79. if d s {j = 14 sinPI d / 2000)); i = 14 cosPI d / 2000)); j2 = 1 sinPI d / 2000)); i2 = 1 cosPI d / 2000)); tft.drawLinei2 + 414 j2 + 240 i + 414 j + 240 White); j = 14 sinPI d-300 / 2000)); i = 14 cosPI d-300 / 2000)); j2 = 1 sinPI d-300 / 2000)); i2 = 1 cosPI d-300 / 2000)); tft.drawLinei2 + 414 j2 + 240 i + 414 j + 240 0x0000); tft.fillRect402 285 30 30 0x0000); tft.setTextSize2); tft.setTextColor0xffff); tft.setCursor402 285); tft.printd / 40); tft.print(“%”); d++;} if a s {
    80. j = 14 sinPI a / 2000));
    81. i = 14 cosPI a / 2000));
    82. j2 = 1 sinPI a / 2000));
    83. i2 = 1 cosPI a / 2000));
    84. tft.drawLinei2 + 62 j2 + 240 i + 62 j + 240 White);
    85. j = 14 sinPI a+300 / 2000));
    86. i = 14 cosPI a+300 / 2000));
    87. j2 = 1 sinPI a+300 / 2000));
    88. i2 = 1 cosPI a+300 / 2000));
    89. tft.drawLinei2 + 62 j2 + 240 i + 62 j + 240 0x0000);
    90. tft.fillRect50 285 30 30 0x0000);
    91. tft.setTextSize2);
    92. tft.setTextColor0xffff);
    93. tft.setCursor50 285);
    94. tft.printa / 40); tft.print(“%”);
    95. a--;}
    96. if b s {
    97. j = 14 sinPI b / 2000));
    98. i = 14 cosPI b / 2000));
    99. j2 = 1 sinPI b / 2000));
    100. i2 = 1 cosPI b / 2000));
    101. tft.drawLinei2 + 180 j2 + 240 i + 180 j + 240 White);
    102. j = 14 sinPI b+300 / 2000));
    103. i = 14 cosPI b+300 / 2000));
    104. j2 = 1 sinPI b+300 / 2000));
    105. i2 = 1 cosPI b+300 / 2000));
    106. tft.drawLinei2 + 180 j2 + 240 i + 180 j + 240 0x0000);
    107. tft.fillRect168 285 30 30 0x0000);
    108. tft.setTextSize2);
    109. tft.setTextColor0xffff);
    110. tft.setCursor168 285);
    111. tft.printb / 40); tft.print(“%”);
    112. b--;}
    113. if c s {
    114. j = 14 sinPI c / 2000));
    115. i = 14 cosPI c / 2000));
    116. j2 = 1 sinPI c / 2000));
    117. i2 = 1 cosPI c / 2000));
    118. tft.drawLinei2 + 297 j2 + 240 i + 297 j + 240 White);
    119. j = 14 sinPI c+300 / 2000));
    120. i = 14 cosPI c+300 / 2000));
    121. j2 = 1 sinPI c+300 / 2000));
    122. i2 = 1 cosPI c+300 / 2000));
    123. tft.drawLinei2 + 297 j2 + 240 i + 297 j + 240 0x0000);
    124. tft.fillRect286 285 30 30 0x0000);
    125. tft.setTextSize2);
    126. tft.setTextColor0xffff);
    127. tft.setCursor286 285);
    128. tft.printc / 40); tft.print(“%”);
    129. c--;}
    130. if d s {
    131. j = 14 sinPI d / 2000));
    132. i = 14 cosPI d / 2000));
    133. j2 = 1 sinPI d / 2000));
    134. i2 = 1 cosPI d / 2000));
    135. tft.drawLinei2 + 414 j2 + 240 i + 414 j + 240 White);
    136. j = 14 sinPI d+300 / 2000));
    137. i = 14 cosPI d+300 / 2000));
    138. j2 = 1 sinPI d+300 / 2000));
    139. i2 = 1 cosPI d+300 / 2000));
    140. tft.drawLinei2 + 414 j2 + 240 i + 414 j + 240 0x0000);
    141. tft.fillRect402 285 30 30 0x0000);
    142. tft.setTextSize2);
    143. tft.setTextColor0xffff);
    144. tft.setCursor402 285);
    145. tft.printd / 40); tft.print(“%”);
    146. d--;}
    147. }
    148. }