{"id":7100,"date":"2020-05-07T00:00:59","date_gmt":"2020-05-06T15:00:59","guid":{"rendered":"https:\/\/techclass.wfjydl.com\/?p=7100"},"modified":"2022-11-22T14:57:59","modified_gmt":"2022-11-22T06:57:59","slug":"tft%e6%b6%b2%e6%99%b6%e9%9d%a2%e6%9d%bf%e4%b8%8e%e4%b8%89%e8%bd%b4%e5%8a%a0%e9%80%9f%e5%ba%a6%e8%ae%a1%e7%9a%84%e9%85%8d%e5%90%88%e4%bd%bf%e7%94%a8-%e7%ac%ac2%e9%83%a8%e5%88%86","status":"publish","type":"post","link":"https:\/\/techclass.wfjydl.com\/knowledge\/deviceplus\/how-tos\/arduino\/3x-accelerometer-using-tft-lcd-panel-part-2","title":{"rendered":"TFT\u6db2\u6676\u9762\u677f\u4e0e\u4e09\u8f74\u52a0\u901f\u5ea6\u8ba1\u7684\u914d\u5408\u4f7f\u7528\u2013\u7b2c2\u90e8\u5206"},"content":{"rendered":"<p><script type=\"text\/javascript\" src=\"https:\/\/ssl-cache.stream.ne.jp\/www50\/eqa194obdo\/jmc_pub\/jmc_swf\/player\/t3\/if.js\" charset=\"UTF-8\"><\/script><\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e<a href=\"https:\/\/www.deviceplus.com\/\">DevicePlus.com<\/a>\u82f1\u8bed\u7f51\u7ad9\u7684\u7ffb\u8bd1\u7a3f\u3002<\/p>\n<p><a style=\"font-size: 20px;\" href=\"https:\/\/techclass.wfjydl.com\/knowledge\/deviceplus\/how-tos\/arduino\/3x-accelerometer-using-tft-lcd-panel-part-1\"><strong>\u70b9\u51fb\u6b64\u5904\u9605\u8bfb\u672c\u6587\u7684\u7b2c1\u90e8\u5206 &gt;<\/strong><\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6060\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image001-4.jpg\" alt=\"tft lcd\" width=\"700\" height=\"394\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image001-4.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image001-4-300x169.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image001-4-260x146.jpg 260w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image001-4-50x28.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image001-4-133x75.jpg 133w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">\u5728\u7b2c1\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u80fd\u591f\u83b7\u53d6KX022-1020\u52a0\u901f\u5ea6\u8ba1\u7684\u6570\u503c\u5e76\u5c06\u5176\u663e\u793a\u5230TFT\u6db2\u6676LCD\u9762\u677f\u4e0a\u3002\u5728\u7b2c2\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u5c06\u5c55\u793a\u5982\u4f55\u5728\u8bfb\u53d6\u7a0b\u5e8f\u5185\u5bb9\u7684\u540c\u65f6\u63a7\u5236TFT\u663e\u793a\u5c4f\uff01<\/span><\/p>\n<h2><b>\u4eca\u5929\u7684\u7535\u5b50\u98df\u8c31<\/b><\/h2>\n<p><b>\u9884\u8ba1\u5b8c\u6210\u65f6\u95f4\uff1a60\u5206\u949f<\/b><\/p>\n<p><b>\u6240\u9700\u90e8\u4ef6\uff1a<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">Arduino \u4e3b\u4f53 (Arduino UNO R3)<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u7f57\u59c6\u4f20\u611f\u5668\u8bc4\u4f30\u5957\u4ef6<\/span><a href=\"https:\/\/www.rohm.com\/web\/global\/sensor-shield-support\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">https:\/\/www.rohm.com\/web\/global\/sensor-shield-support<\/span><\/a><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">TFT \u6db2\u6676\u9762\u677f (sainsmart 1.8)  <\/span><span style=\"font-weight: 400;\">https:\/\/www.sainsmart.com\/sainsmart-1-8-spi-lcd-module-with-microsd-led-backlight-for-arduino-mega-atmel-atmega.html<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">\u203b<\/span><span style=\"font-weight: 400;\"> \u60a8\u53ef\u4ee5\u4ece\u4ee5\u4e0b\u7ad9\u70b9\u8d2d\u4e70\u7f57\u59c6\u4f20\u611f\u5668\u8bc4\u4f30\u5957\u4ef6\uff01<\/span><\/p>\n<p><a href=\"https:\/\/www.chip1stop.com\/dispDetail.do?partId=极悦娱乐-0160122&amp;cid=Rohmsite201602\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">Chip One Stop <\/span><\/a><\/p>\n<p><a href=\"https:\/\/www.mouser.com\/ProductDetail\/极悦娱乐-Semiconductor\/SENSORSHIELD-EVK-001\/?qs=%2fha2pyFadujfuq%252bcaAfOBk4clAgyRB4498slvCo6FqtJL7KJRjFxZQ2be6BhDJpN\" target=\"_blank\" rel=\"noopener noreferrer\"><span style=\"font-weight: 400;\">Mouser Electronics<\/span><\/a><\/p>\n<p>&nbsp;<\/p>\n<h2><b>\u901a\u8fc7Arduino\u5728TFT\u6db2\u6676\u663e\u793a\u5c4f\u4e0a\u663e\u793a\u6570\u636e<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">\u548c\u4e4b\u524d\u4e00\u6837\uff0c\u6211\u4eec\u4f7f\u7528<\/span><span style=\"font-weight: 400;\">SainSmart ST7735R<\/span><span style=\"font-weight: 400;\">TFT\u663e\u793a\u5c4f\u3002\u8fd9\u662f\u4e00\u6b3e\u7d27\u51d1\u7684LCD\u663e\u793a\u5c4f\uff0c\u53ef\u517c\u5bb9Arduino\u548cRaspberry Pi\u3002\u8be5\u663e\u793a\u5c4f\u5177\u6709\u5185\u7f6emicroSD\u5361\u63d2\u69fd\uff0c\u56e0\u6b64\u9664\u4e86\u8bfb\u53d6\u548c\u5199\u5165\u6570\u636e\u5916\uff0c\u8fd8\u53ef\u4ee5\u5b58\u50a8\u548c\u52a0\u8f7d\u56fe\u50cf\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4ec5\u5c1d\u8bd5\u5728\u8be5TFT\u663e\u793a\u5c4f\u4e0a\u663e\u793a\u6570\u503c\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u6211\u4eec\u5f00\u59cb\u5427\uff01\u9996\u5148\uff0c\u5c06TFT\u663e\u793a\u5c4f\u4e0eArduino\u8fde\u63a5\u8d77\u6765\u3002<\/span><\/p>\n<div id=\"attachment_6053\" style=\"width: 710px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6053\" class=\"size-full wp-image-6053\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image019-2.jpg\" alt=\"tft lcd\" width=\"700\" height=\"394\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image019-2.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image019-2-300x169.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image019-2-260x146.jpg 260w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image019-2-50x28.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image019-2-133x75.jpg 133w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p id=\"caption-attachment-6053\" class=\"wp-caption-text\">\u56fe1  SainSmart ST7735R TFT\u663e\u793a\u5c4f<\/p>\n<\/div>\n<div id=\"attachment_6059\" style=\"width: 710px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6059\" class=\"size-full wp-image-6059\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image005-4.jpg\" alt=\"tft lcd\" width=\"700\" height=\"383\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image005-4.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image005-4-300x164.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image005-4-260x142.jpg 260w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image005-4-50x27.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image005-4-137x75.jpg 137w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p id=\"caption-attachment-6059\" class=\"wp-caption-text\">\u56fe2  TFT\u663e\u793a\u5c4f\u7684\u80cc\u9762<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">TFT \u5f15\u811a\u5b9a\u4e49\uff1a<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">VCC &#8211; \u4f9b\u7535\u7535\u538b<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">GND &#8211; \u5730 <\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">SCL &#8211; \u4e32\u884c\u65f6\u949f\u7ebf<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">SDA &#8211; \u4e32\u884c\u6570\u636e\u7ebf<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">RS \/ DC &#8211; \u547d\u4ee4\/\u6570\u636e\u9009\u62e9<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">RES &#8211; \u63a7\u5236\u5668\u590d\u4f4d<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">CS &#8211; TF\u5361\u7684\u7247\u9009\u4fe1\u53f7<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">\u5c06Arduino\u8fde\u81f3TFT\u663e\u793a\u5c4f\u4e4b\u540e\uff0c\u6211\u4eec\u6765\u8fd0\u884c\u793a\u4f8b\u7a0b\u5e8f\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><b>\u5c06TFT\u663e\u793a\u5c4f\u5e93\u6587\u4ef6\u5e94\u7528\u4e8eArduino<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">\u6b63\u5982\u6587\u7ae0\u7b2c1\u90e8\u5206\u4e2d\u63d0\u5230\u7684\uff0c\u6211\u4eec\u9700\u8981\u5bf9\u5e93\u6587\u4ef6\uff08ST7735R\uff09\u8fdb\u884c\u4e00\u4e9b\u5c0f\u7684\u4fee\u6539\uff0c\u4ee5\u4fbf\u8ba9TFT\u663e\u793a\u5c4f\u517c\u5bb9Arduino\u7cfb\u7edf\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u7528\u4e8eArduino\u7684SainSmart 1.8 ST7735R TFT\u6db2\u6676\u663e\u793a\u5c4f\uff0c\u642d\u8f7dMicroSD\u5361\u69fd\u548cLED\u80cc\u5149<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Raspberry Pi \u5e93 (ST7735R V0.2)<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u4e0a\u8ff0URL\u7684\u9875\u9762\u5e95\u90e8\u6709\u4e00\u4e2a\u4e0b\u8f7d\u94fe\u63a5\u3002\u5355\u51fb\u9875\u9762\u4e0a\u6807\u6709 &#8220;<\/span><b>Download Link<\/b><span style=\"font-weight: 400;\">&#8221; \u7684\u94fe\u63a5\uff0c\u4e0b\u8f7d\u5b8c\u6574\u7684\u5e93\u3001\u793a\u4f8b\u4ee3\u7801\u53ca\u6587\u6863\u7b49\u3002\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u89e3\u538b\u6587\u4ef6\u5e76\u91cd\u65b0\u7f16\u5199\u5fc5\u8981\u7684\u6587\u4ef6\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u8bf7\u7528\u80fd\u591f\u7f16\u8f91\u6587\u672c\u7684\u7f16\u8f91\u5668\u6253\u5f00 &#8220;<\/span><b>ST7735.h<\/b><span style=\"font-weight: 400;\">&#8221; \uff0c\u7136\u540e\u66f4\u6539\u4e0b\u56fe\u6240\u793a\u7684\u90e8\u5206\u3002\u60a8\u4e5f\u53ef\u4ee5\u4f7f\u7528Arduino IDE\u3002<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6058\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image007-3.jpg\" alt=\"tft lcd\" width=\"689\" height=\"147\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image007-3.jpg 689w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image007-3-300x64.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image007-3-260x55.jpg 260w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image007-3-50x11.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image007-3-150x32.jpg 150w\" sizes=\"auto, (max-width: 689px) 100vw, 689px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">\u66f4\u6539\u5b8c\u6210\u540e\uff0c\u7528zip\u518d\u6b21\u538b\u7f29 &#8220;<\/span><b>TFT 18<\/b><span style=\"font-weight: 400;\">&#8221; \u76ee\u5f55\uff0c\u7136\u540e\u5728Arduino\uff08\u6216Arduino Create\uff09Add Library\u4e2d\u5c06\u5176\u4f5c\u4e3a\u4e00\u4e2a\u5e93\u6dfb\u52a0\uff1b\u6216\u8005\u5c06\u5176\u653e\u7f6e\u5728Arduino\u5b89\u88c5\u76ee\u5f55\u7684\u201clibraries\u201d\u76ee\u5f55\u4e0b\u5e76\u52a0\u8f7d\u8be5\u5e93\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5bfc\u5165\u5e93\u4e4b\u540e\uff0c\u8bf7\u5c1d\u8bd5\u5728\u793a\u4f8b\u7a0b\u5e8f\u4e2d\u79fb\u52a8 &#8220;TFT 18&#8221; &#8211; &#8220;graphictest&#8221; \u3002<\/span><\/p>\n<p><script type=\"text\/javascript\">\n\tjstream_t3.PlayerFactoryIF.create({\n\tb:\"eqa194obdo.eq.webcdn.stream.ne.jp\/www50\/eqa194obdo\/jmc_pub\/jmc_swf\/player\/\",\n\tc:\"NDc3\",\n\tm:\"NDQy\",\n\ts:{\n\t\thp:360,\n\t\til:\"off\",\n\t\trb:\"off\",\n\t\tsn:\"f,t,g\",\n\t\twp:640\n\t}});\n<\/script><\/p>\n<p><span style=\"font-weight: 400;\">\u60a8\u4f1a\u770b\u5230\u793a\u4f8b\u7a0b\u5e8f\u7684\u663e\u793a\u975e\u5e38\u6d41\u7545\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u793a\u4f8b\u7a0b\u5e8f &#8211; graphictest<\/span><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>\/\/Pin setting\r\n#define sclk 4\r\n#define mosi 5\r\n#define cs 6\r\n#define dc 7\r\n#define rst 8\r\n\/\/Color numbering\r\n#define BLACK       \t0x0000\r\n#define BLUE        \t0x001F\r\n#define RED         \t0xF800\r\n#define GREEN       \t0x07E0\r\n#define CYAN        \t0x07FF\r\n#define MAGENTA     \t0xF81F\r\n#define YELLOW      \t0xFFE0 \r\n#define WHITE       \t0xFFFF\r\n#include &lt;ST7735.h&gt;\r\n#include &lt;SPI.h&gt;\r\nST7735 tft = ST7735(cs, dc, mosi, sclk, rst); \r\nvoid fillpixelbypixel(uint16_t color) {\r\n for (uint8_t x=0; x &lt; tft.width; x++) {\r\n   for (uint8_t y=0; y &lt; tft.height; y++) {\r\n     tft.drawPixel(x, y, color);\r\n   }\r\n }\r\n delay(100);\r\n}\r\nvoid setup(void) {\r\n Serial.begin(9600);\r\n Serial.print(\"hello!\");\r\n tft.initR();           \t\/\/ initialize a ST7735R chip\r\n Serial.println(\"init\");\r\n tft.writecommand(ST7735_DISPON);\r\n  \r\n uint16_t time = millis();\r\n tft.fillScreen(BLACK);\r\n time = millis() - time;\r\n  \r\n Serial.println(time, DEC);\r\n delay(500);\r\n  \r\n \/\/\r\n tft.fillScreen(BLACK);\r\n testdrawtext(\"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing ante sed nibh tincidunt feugiat. Maecenas enim massa, fringilla sed malesuada et, malesuada sit amet turpis. Sed porttitor neque ut ante pretium vitae malesuada nunc bibendum. Nullam aliquet ultrices massa eu hendrerit. Ut sed nisi lorem. In vestibulum purus a tortor imperdiet posuere. \", WHITE);\r\n delay(1000);\r\n  \r\n \/\/a single pixel\r\n tft.drawPixel(tft.width\/2, tft.height\/2, GREEN);\r\n delay(500);\r\n  \r\n \/\/ line draw test\r\n testlines(YELLOW);\r\n delay(500);\t\r\n  \r\n \/\/ optimized lines\r\n testfastlines(RED, BLUE);\r\n delay(500);\t\r\n testdrawrects(GREEN);\r\n delay(500);\r\n testfillrects(YELLOW, MAGENTA);\r\n delay(500);\r\n tft.fillScreen(BLACK);\r\n testfillcircles(10, BLUE);\r\n testdrawcircles(10, WHITE);\r\n  \r\n Serial.println(\"done\");\r\n delay(1000);\r\n}\r\nvoid loop() {\r\n tft.writecommand(ST7735_INVON);\r\n delay(500);\r\n tft.writecommand(ST7735_INVOFF);\r\n delay(500);\r\n}\r\nvoid testlines(uint16_t color) {\r\n  tft.fillScreen(BLACK);\r\n  for (uint16_t x=0; x &lt; tft.width; x+=6) {\r\n    tft.drawLine(0, 0, x, tft.height-1, color);\r\n  }\r\n  for (uint16_t y=0; y &lt; tft.height; y+=6) {\r\n    tft.drawLine(0, 0, tft.width-1, y, color);\r\n  }\r\n   \r\n  tft.fillScreen(BLACK);\r\n  for (uint16_t x=0; x &lt; tft.width; x+=6) {\r\n    tft.drawLine(tft.width-1, 0, x, tft.height-1, color);\r\n  }\r\n  for (uint16_t y=0; y &lt; tft.height; y+=6) {\r\n    tft.drawLine(tft.width-1, 0, 0, y, color);\r\n  }\r\n   \r\n  tft.fillScreen(BLACK);\r\n  for (uint16_t x=0; x &lt; tft.width; x+=6) {\r\n    tft.drawLine(0, tft.height-1, x, 0, color);\r\n  }\r\n  for (uint16_t y=0; y &lt; tft.height; y+=6) {\r\n    tft.drawLine(0, tft.height-1, tft.width-1, y, color);\r\n  }\r\n  tft.fillScreen(BLACK);\r\n  for (uint16_t x=0; x &lt; tft.width; x+=6) {\r\n    tft.drawLine(tft.width-1, tft.height-1, x, 0, color);\r\n  }\r\n  for (uint16_t y=0; y &lt; tft.height; y+=6) {\r\n    tft.drawLine(tft.width-1, tft.height-1, 0, y, color);\r\n  }\r\n   \r\n}\r\nvoid testdrawtext(char *text, uint16_t color) {\r\n tft.drawString(0, 0, text, color);\r\n}\r\nvoid testfastlines(uint16_t color1, uint16_t color2) {\r\n  tft.fillScreen(BLACK);\r\n  for (uint16_t y=0; y &lt; tft.height; y+=5) {\r\n    tft.drawHorizontalLine(0, y, tft.width, color1);\r\n  }\r\n  for (uint16_t x=0; x &lt; tft.width; x+=5) {\r\n    tft.drawVerticalLine(x, 0, tft.height, color2);\r\n  }\r\n}\r\nvoid testdrawrects(uint16_t color) {\r\ntft.fillScreen(BLACK);\r\nfor (uint16_t x=0; x &lt; tft.width; x+=6) { tft.drawRect(tft.width\/2 -x\/2, tft.height\/2 -x\/2 , x, x, color); } } void testfillrects(uint16_t color1, uint16_t color2) { tft.fillScreen(BLACK); for (uint16_t x=tft.width-1; x &gt; 6; x-=6) {\r\n  tft.fillRect(tft.width\/2 -x\/2, tft.height\/2 -x\/2 , x, x, color1);\r\n  tft.drawRect(tft.width\/2 -x\/2, tft.height\/2 -x\/2 , x, x, color2);\r\n}\r\n}\r\nvoid testfillcircles(uint8_t radius, uint16_t color) {\r\n for (uint8_t x=radius; x &lt; tft.width; x+=radius*2) {\r\n   for (uint8_t y=radius; y &lt; tft.height; y+=radius*2) {\r\n     tft.fillCircle(x, y, radius, color);\r\n   }\r\n } \r\n}\r\nvoid testdrawcircles(uint8_t radius, uint16_t color) {\r\n for (uint8_t x=0; x &lt; tft.width+radius; x+=radius*2) {\r\n   for (uint8_t y=0; y &lt; tft.height+radius; y+=radius*2) {\r\n     tft.drawCircle(x, y, radius, color);\r\n   }\r\n } \r\n}\r\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u8be5TFT\u663e\u793a\u5c4f\u7684\u4e3b\u8981\u529f\u80fd\u5982\u4e0b\u6240\u793a\uff1a<\/span><\/p>\n<p><span style=\"color: white; background-color: black;\"><span style=\"color: #ffff00;\">tft.drawPixel(x,y,color);<\/span> <\/span><span style=\"font-weight: 400;\">&#8211; \u5728\u6307\u5b9a\u4f4d\u7f6e(x,y)\u663e\u793a\u6307\u5b9a\u989c\u8272(color)\u7684\u70b9\u3002<\/span><\/p>\n<p><span style=\"color: #ffff00; background-color: black;\">tft.drawCircle(x, y, radius, color);<\/span><span style=\"font-weight: 400;\"> &#8211; \u5728\u6307\u5b9a\u4f4d\u7f6e(x,y)\u7528\u6307\u5b9a\u534a\u5f84(radius)\u753b\u4e00\u4e2a\u5706\u3002<\/span><\/p>\n<p><span style=\"color: #ffff00; background-color: black;\">tft.fillRect(x1,y1, x2, y2, color);<\/span><span style=\"font-weight: 400;\"> &#8211; \u586b\u5145\u6307\u5b9a\u4f4d\u7f6e1(x1, y1)\u81f3\u6307\u5b9a\u4f4d\u7f6e2(x2, y2)\u4e4b\u95f4\u7684\u77e9\u5f62\u3002<\/span><\/p>\n<p><span style=\"color: #ffff00; background-color: black;\">tft.drawString(x, y, text, color);<\/span><span style=\"font-weight: 400;\"> &#8211; \u5728\u6307\u5b9a\u4f4d\u7f6e(x,y)\u7528\u6307\u5b9a\u989c\u8272(color)\u663e\u793a\u6587\u672c\u3002<\/span><\/p>\n<p><span style=\"color: #ffff00; background-color: black;\">tft.fillScreen(0x0000);<\/span><span style=\"font-weight: 400;\"> &#8211; \u7528\u6307\u5b9a\u989c\u8272\u586b\u5145\u6574\u4e2a\u663e\u793a\u5c4f\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5c3d\u7ba1\u8fd8\u6709\u5176\u4ed6\u529f\u80fd\uff0c\u4f46\u662f\u4e0a\u8ff0\u4e3b\u8981\u529f\u80fd\u5df2\u7ecf\u80fd\u591f\u6ee1\u8db3\u51e0\u4e4e\u6240\u6709\u6211\u4eec\u7684\u663e\u793a\u8981\u6c42\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><b>\u5c06\u52a0\u901f\u5ea6\u8ba1\u7684\u6570\u503c\u7ed8\u5236\u6210\u56fe\u5f62<\/b><\/h2>\n<p><span style=\"font-weight: 400;\">\u63a5\u4e0b\u6765\uff0c\u8ba9\u6211\u4eec\u5728TFT\u663e\u793a\u5c4f\u4e0a\u663e\u793a\u52a0\u901f\u5ea6\u8ba1\u7684\u6570\u503c\uff01\u57fa\u672c\u4e0a\uff0c\u5c31\u4f20\u611f\u5668\u8bc4\u4f30\u5957\u4ef6\u800c\u8a00\uff0c\u6211\u4eec\u65e0\u9700\u66f4\u6539TFT\u663e\u793a\u5c4f\u8fd9\u8fb9\u7684\u8fde\u7ebf\u3002\u53ea\u9700\u5c06KX022-1020\u52a0\u901f\u5ea6\u8ba1\u63d2\u5165\u4f20\u611f\u5668\u5f00\u53d1\u677f\u5373\u53ef\u3002<\/span><\/p>\n<div id=\"attachment_6061\" style=\"width: 710px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-6061\" class=\"size-full wp-image-6061\" src=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image011-4.jpg\" alt=\"tft lcd\" width=\"700\" height=\"394\" srcset=\"https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image011-4.jpg 700w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image011-4-300x169.jpg 300w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image011-4-260x146.jpg 260w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image011-4-50x28.jpg 50w, https:\/\/techclass.wfjydl.com\/wp-content\/uploads\/2017\/07\/image011-4-133x75.jpg 133w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/p>\n<p id=\"caption-attachment-6061\" class=\"wp-caption-text\">\u56fe3 \u52a0\u901f\u5ea6\u8ba1\u548cTFT\u663e\u793a\u5c4f<\/p>\n<\/div>\n<p><span style=\"font-weight: 400;\">\u663e\u793a\u52a0\u901f\u5ea6\u8ba1\u6570\u503c\u7684\u7a0b\u5e8f\u5982\u4e0b\uff1a<\/span><\/p>\n<div class=\"hcb_wrap\">\n<pre class=\"prism undefined-numbers lang-c\" data-lang=\"C\"><code>#include &lt;Wire.h&gt;\r\n#include &lt;KX022.h&gt;\r\n#include &lt;ST7735.h&gt;\r\n#include &lt;SPI.h&gt;\r\n\/\/ You can use any (4 or) 5 pins\r\n#define sclk 4\r\n#define mosi 5\r\n#define cs 6\r\n#define dc 7\r\n#define rst 8  \/\/ you can also connect this to the Arduino reset\r\n\/\/ Color definitions\r\n#define BLACK       \t0x0000\r\n#define BLUE        \t0x001F\r\n#define RED         \t0xF800\r\n#define GREEN       \t0x07E0\r\n#define CYAN        \t0x07FF\r\n#define MAGENTA     \t0xF81F\r\n#define YELLOW      \t0xFFE0 \r\n#define WHITE       \t0xFFFF\r\nST7735 tft = ST7735(cs, dc, mosi, sclk, rst); \r\nKX022 kx022(KX022_DEVICE_ADDRESS_1E);\r\nint _cnt = 0;\r\n\/\/Graph initial position\r\nint _xc = 120;\r\nint _yc = 130;\r\nint _zc = 140;\r\nvoid fillpixelbypixel(uint16_t color) {\r\nfor (uint8_t x=0; x &lt; tft.width; x++) {\r\nfor (uint8_t y=0; y &lt; tft.height; y++) {\r\ntft.drawPixel(x, y, color);\r\n}\r\n}\r\ndelay(100);\r\n}\r\nvoid setup(void) {\r\nbyte rc;\r\nSerial.begin(9600);\r\nwhile (!Serial);\r\nWire.begin();\r\ntft.initR(); \/\/ initialize a ST7735R chip\r\nrc = kx022.init();\r\ntft.fillScreen(BLACK);\r\n \r\n1.DEVICE PLUS\r\ntestdrawtext(\"DEVICE PLUS!!\", WHITE,25,50);\r\ndelay(1000);\r\ntft.fillScreen(BLACK);\r\n}\r\nvoid loop() {\r\n\/\/KX022\r\nbyte rc;\r\nfloat acc[3];\r\n\/\/2.Acquire accelerometer values\r\nrc = kx022.get_val(acc);\r\nif (rc == 0) {\r\nSerial.write(\"KX022 (X) = \");\r\nSerial.print(acc[0]);\r\nSerial.println(\" [g]\");\r\nSerial.write(\"KX022 (Y) = \");\r\nSerial.print(acc[1]);\r\nSerial.println(\" [g]\");\r\nSerial.write(\"KX022 (Z) = \");\r\nSerial.print(acc[2]);\r\nSerial.println(\" [g]\");\r\nSerial.println();\r\n\/\/Convert float type to char type\r\nchar xVal[10];\r\ndtostrf(acc[0], 5, 2, xVal);\r\nchar yVal[10];\r\ndtostrf(acc[1], 5, 2, yVal);\r\nchar zVal[10];\r\ndtostrf(acc[2], 5, 2, zVal);\r\n\/\/Convert to TFT liquid crystal\r\n\/\/tft.fillScreen(BLACK);\r\ntft.fillRect(0,0, 120, 60, BLACK);\r\ntestdrawtext(\"X:\", RED, 5, 15);\r\ntestdrawtext(xVal, WHITE, 30, 15);\r\ntestdrawtext(\"Y:\", BLUE, 5, 30);\r\ntestdrawtext(yVal, WHITE, 30, 30);\r\ntestdrawtext(\"Z:\", GREEN, 5, 45);\r\ntestdrawtext(zVal, WHITE, 30, 45);\r\n\/\/3.Draw a graph\r\nint x = int(acc[0]*100)+120;\r\nint y = int(acc[1]*100)+130;\r\nint z = int(acc[2]*100)+40;\r\ntft.drawLine(_cnt-1, _xc, _cnt, x, RED);\r\ntft.drawLine(_cnt-1, _yc, _cnt, y, BLUE);\r\ntft.drawLine(_cnt-1, _zc, _cnt, z, GREEN);\r\n_cnt++;\r\n\/\/Reset to the end of the screen\r\nif(_cnt &gt; 120){\r\n_cnt = 0;\r\ntft.fillScreen(BLACK);\r\n}\r\n_xc = x;\r\n_yc = y;\r\n_zc = z;\r\n \r\ndelay(10);\r\n}\r\ndelay(10);\r\n}\r\nvoid testlines(uint16_t color) {\r\n  tft.fillScreen(BLACK);\r\n  for (uint16_t x=0; x &lt; tft.width; x+=6) {\r\n    tft.drawLine(0, 0, x, tft.height-1, color);\r\n  }\r\n  for (uint16_t y=0; y &lt; tft.height; y+=6) {\r\n    tft.drawLine(0, 0, tft.width-1, y, color);\r\n  }\r\n   \r\n  tft.fillScreen(BLACK);\r\n  for (uint16_t x=0; x &lt; tft.width; x+=6) {\r\n    tft.drawLine(tft.width-1, 0, x, tft.height-1, color);\r\n  }\r\n  for (uint16_t y=0; y &lt; tft.height; y+=6) {\r\n    tft.drawLine(tft.width-1, 0, 0, y, color);\r\n  }\r\n   \r\n  tft.fillScreen(BLACK);\r\n  for (uint16_t x=0; x &lt; tft.width; x+=6) {\r\n    tft.drawLine(0, tft.height-1, x, 0, color);\r\n  }\r\n  for (uint16_t y=0; y &lt; tft.height; y+=6) {\r\n    tft.drawLine(0, tft.height-1, tft.width-1, y, color);\r\n  }\r\n  tft.fillScreen(BLACK);\r\n  for (uint16_t x=0; x &lt; tft.width; x+=6) {\r\n    tft.drawLine(tft.width-1, tft.height-1, x, 0, color);\r\n  }\r\n  for (uint16_t y=0; y &lt; tft.height; y+=6) {\r\n    tft.drawLine(tft.width-1, tft.height-1, 0, y, color);\r\n  }\r\n}\r\nvoid testdrawtext(char *text, uint16_t color,int x,int y) {\r\n tft.drawString(x, y, text, color);\r\n}\r\nvoid testfastlines(uint16_t color1, uint16_t color2) {\r\n  tft.fillScreen(BLACK);\r\n  for (uint16_t y=0; y &lt; tft.height; y+=5) {\r\n    tft.drawHorizontalLine(0, y, tft.width, color1);\r\n  }\r\n  for (uint16_t x=0; x &lt; tft.width; x+=5) {\r\n    tft.drawVerticalLine(x, 0, tft.height, color2);\r\n  }\r\n}\r\nvoid testdrawrects(uint16_t color) {\r\ntft.fillScreen(BLACK);\r\nfor (uint16_t x=0; x &lt; tft.width; x+=6) { tft.drawRect(tft.width\/2 -x\/2, tft.height\/2 -x\/2 , x, x, color); } } void testfillrects(uint16_t color1, uint16_t color2) { tft.fillScreen(BLACK); for (uint16_t x=tft.width-1; x &gt; 6; x-=6) {\r\n  tft.fillRect(tft.width\/2 -x\/2, tft.height\/2 -x\/2 , x, x, color1);\r\n  tft.drawRect(tft.width\/2 -x\/2, tft.height\/2 -x\/2 , x, x, color2);\r\n}\r\n}\r\nvoid testfillcircles(uint8_t radius, uint16_t color) {\r\n for (uint8_t x=radius; x &lt; tft.width; x+=radius*2) {\r\n   for (uint8_t y=radius; y &lt; tft.height; y+=radius*2) {\r\n     tft.fillCircle(x, y, radius, color);\r\n   }\r\n } \r\n}\r\nvoid testdrawcircles(uint8_t radius, uint16_t color) {\r\n for (uint8_t x=0; x &lt; tft.width+radius; x+=radius*2) {\r\n   for (uint8_t y=0; y &lt; tft.height+radius; y+=radius*2) {\r\n     tft.drawCircle(x, y, radius, color);\r\n   }\r\n } \r\n}\r\n<\/code><\/pre>\n<\/div>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">\u8fd0\u884c\u4e0a\u8ff0\u7a0b\u5e8f\u540e\uff0c\u663e\u793a\u5c4f\u4f1a\u5c06\u52a0\u901f\u5ea6\u8ba1\u7684\u6570\u503c\u7528\u56fe\u5f62\u663e\u793a\u51fa\u6765\u3002<\/span><\/p>\n<p><script type=\"text\/javascript\">\n\tjstream_t3.PlayerFactoryIF.create({\n\tb:\"eqa194obdo.eq.webcdn.stream.ne.jp\/www50\/eqa194obdo\/jmc_pub\/jmc_swf\/player\/\",\n\tc:\"NDc3\",\n\tm:\"NDQz\",\n\ts:{\n\t\thp:360,\n\t\til:\"off\",\n\t\trb:\"off\",\n\t\tsn:\"f,t,g\",\n\t\twp:640\n\t}});\n<\/script><\/p>\n<p><span style=\"font-weight: 400;\">\u8be5\u7a0b\u5e8f\u6d41\u7a0b\u6458\u8981\u5982\u4e0b\uff1a<\/span><\/p>\n<ol>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u542f\u52a8\u65f6\u663e\u793a &#8220;DEVICE PLUS !!&#8221; \u5b57\u7b26<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u83b7\u53d6\u52a0\u901f\u5ea6\u8ba1\u7684\u6570\u503c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u6574\u6570<\/span><\/li>\n<li style=\"font-weight: 400;\"><span style=\"font-weight: 400;\">\u6839\u636e\u6570\u503c\u663e\u793a\u56fe\u5f62\u548c\u6587\u672c<\/span><\/li>\n<\/ol>\n<p><span style=\"font-weight: 400;\">\u6bcf\u4e00\u5e27\u6211\u4eec\u7ed9x\u8f74\u52a01\uff0c\u4ee5\u4fbf\u4ece\u5de6\u5230\u53f3\u7ed8\u5236\u56fe\u5f62\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u5f53\u753b\u9762\u5230\u8fbe120px\u663e\u793a\u5c4f\u7684\u8fb9\u7f18\u65f6\uff0c\u7a0b\u5e8f\u4f1a\u7528drawrect\u6e05\u9664\u56fe\u5f62\u3002\u5c4f\u5e55\u4e0a\u65b9\u7684\u6570\u5b57\u4ee5\u76f8\u540c\u7684\u65b9\u5f0f\u901a\u8fc7drawrect\u8fdb\u884c\u6bcf\u5e27\u66f4\u65b0\u3002<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u81f3\u6b64\uff0c\u5229\u7528TFT\u6db2\u6676\u663e\u793a\u5c4f\u663e\u793a\u52a0\u901f\u5ea6\u8ba1\u7684\u6570\u503c\u5e76\u7ed8\u5236\u76f8\u5173\u56fe\u5f62\u7684\u6559\u7a0b\u5c31\u7ed3\u675f\u4e86\uff01\u6211\u4eec\u8fd8\u53ef\u4ee5\u8003\u8651\u5f00\u53d1\u66f4\u591a\u7684\u9644\u5e26\u9879\u76ee\u3002\u6bd4\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6b64TFT\u663e\u793a\u5c4f\u4e0eArduino Pro Mini\u7ec4\u5408\u5728\u4e00\u8d77\uff0c\u5236\u4f5c\u5177\u6709\u5c0f\u578b\u6e38\u620f\u529f\u80fd\u7684\u624b\u8868\u7b49\uff1b\u8fd8\u53ef\u4ee5\u5229\u7528\u4f20\u611f\u5668\u8bc4\u4f30\u5957\u4ef6\u4e2d\u7684\u4e0d\u540c\u4f20\u611f\u5668\u6765\u5236\u4f5c\u6570\u636e\u8bb0\u5f55\u5668\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><a style=\"font-size: 20px;\" href=\"https:\/\/techclass.wfjydl.com\/knowledge\/deviceplus\/how-tos\/arduino\/3x-accelerometer-using-tft-lcd-panel-part-1\"><strong>\u70b9\u51fb\u6b64\u5904\u9605\u8bfb\u672c\u6587\u7684\u7b2c1\u90e8\u5206 &gt;<\/strong><\/a><\/p>\n<div class=\"author-box-wrapper\">\n<div class=\"avatar-wrapper\">\n\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/micro.wfjydl.com\/deviceplus\/wp-content\/uploads\/2018\/08\/Device-Plus-logo-for-author-info-75x75.png\" width=\"64\" height=\"64\" alt=\"DevicePlus \u7f16\u8f91\u56e2\u961f\">\n\t<\/div>\n<div class=\"desc-wrapper\">\n<h5>DevicePlus \u7f16\u8f91\u56e2\u961f<\/h5>\n<div class=\"desc\">\n<p>\u8bbe\u5907\u5347\u7ea7\u7248\u9002\u7528\u4e8e\u6240\u6709\u70ed\u7231\u7535\u5b50\u548c\u673a\u7535\u4e00\u4f53\u5316\u7684\u4eba\u3002<\/p>\n<\/div><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"\u8fd9\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8eDevicePlus.com\u82f1\u8bed\u7f51\u7ad9\u7684\u7ffb\u8bd1\u7a3f\u3002 \u70b9\u51fb\u6b64\u5904\u9605\u8bfb\u672c\u6587\u7684\u7b2c1\u90e8\u5206 &gt; \u5728\u7b2c1\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u80fd\u591f\u83b7\u53d6KX022-1020\u52a0\u901f\u5ea6\u8ba1\u7684\u6570\u503c\u5e76\u5c06\u5176\u663e\u793a\u5230TFT\u6db2\u6676LCD\u9762\u677f\u4e0a\u3002\u5728\u7b2c2\u90e8\u5206\u4e2d\uff0c\u6211\u4eec\u5c06\u5c55\u793a [&hellip;]","protected":false},"author":3,"featured_media":20704,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1130],"tags":[],"class_list":["post-7100","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino"],"acf":[],"wps_subtitle":"","_links":{"self":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/7100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/comments?post=7100"}],"version-history":[{"count":7,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/7100\/revisions"}],"predecessor-version":[{"id":21641,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/posts\/7100\/revisions\/21641"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media\/20704"}],"wp:attachment":[{"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/media?parent=7100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/categories?post=7100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techclass.wfjydl.com\/wp-json\/wp\/v2\/tags?post=7100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}