{"id":405,"date":"2024-10-24T14:33:47","date_gmt":"2024-10-24T06:33:47","guid":{"rendered":"https:\/\/pakies.cc\/?p=405"},"modified":"2024-10-24T14:53:26","modified_gmt":"2024-10-24T06:53:26","slug":"%e6%a8%a1%e6%8b%9f%e6%95%b0%e5%ad%97%e7%af%9d%e7%81%ab%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1","status":"publish","type":"post","link":"https:\/\/pakies.cc\/index.php\/2024\/10\/24\/%e6%a8%a1%e6%8b%9f%e6%95%b0%e5%ad%97%e7%af%9d%e7%81%ab%e7%a8%8b%e5%ba%8f%e8%ae%be%e8%ae%a1\/","title":{"rendered":"\u3010\u4e09\u3011\u6a21\u62df\u6570\u5b57\u7bdd\u706b\u7a0b\u5e8f\u8bbe\u8ba1"},"content":{"rendered":"\n<p>\u5728\u6a21\u62df\u6570\u5b57\u7bdd\u706b\u7684\u9879\u76ee\u4e2d\u6211\u4eec\u5c06\u706b\u7130\u7684\u5f62\u72b6\u3001\u660e\u5ea6\u3001\u8272\u5f69\u7b49\u7279\u5f81\u8fdb\u884c\u4e86\u63d0\u53d6\uff0c\u8bd5\u56fe\u901a\u8fc7\u7a0b\u5e8f\u7684\u65b9\u5f0f\u5c06\u706b\u7130\u901a\u8fc7\u6570\u5b57\u7684\u5f62\u5f0f\u590d\u73b0\u51fa\u6765\uff0c\u5e76\u5728\u5176\u4e2d\u53ef\u4ee5\u5f15\u5165\u53ef\u4f9b\u8c03\u6574\u7684\u53d8\u91cf\uff0c\u5728\u6b64\u8bb0\u5f55\u4e0b\u6574\u4e2a\u7a0b\u5e8f\u7684\u5b9e\u73b0\u601d\u8def\u3002<\/p>\n\n\n\n<h2 id=\"%e7%81%ab%e7%84%b0%e7%9a%84%e7%89%b9%e5%be%81\" class=\"wp-block-heading has-text-align-center\"><strong>\u706b\u7130\u7684\u7279\u5f81<\/strong><\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"496\" height=\"372\" src=\"https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u56fe\u5c42-1.jpg\" alt=\"\" class=\"wp-image-406\" srcset=\"https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u56fe\u5c42-1.jpg 496w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u56fe\u5c42-1-300x225.jpg 300w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u56fe\u5c42-1-110x83.jpg 110w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u56fe\u5c42-1-200x150.jpg 200w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u56fe\u5c42-1-380x285.jpg 380w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u56fe\u5c42-1-255x191.jpg 255w\" sizes=\"auto, (max-width: 496px) 100vw, 496px\" \/><figcaption class=\"wp-element-caption\">\u706b\u7130\u6240\u5177\u6709\u7684\u7279\u5f81<\/figcaption><\/figure>\n<\/div>\n\n\n<p><strong>\u706b\u7130\u672c\u8d28\u4e0a\u662f\u4e00\u79cd\u65e0\u5e8f\u968f\u673a\u7684\u7b49\u79bb\u5b50\u5316\u5b66\u53cd\u5e94\uff0c\u4f46\u53c8\u6709\u4ee5\u4e0b\u7684\u4e00\u4e9b\u7279\u5f81\uff1a<\/strong><\/p>\n\n\n\n<p>\uff081\uff09\u901a\u5e38\u706b\u7130\u5e95\u90e8\u4e3a\u66f4\u4e3a\u9c9c\u8273\u548c\u660e\u4eae\uff0c\u5448\u73b0\u51fa\u9c9c\u8273\u7684\u9ec4\u8272\u8272\u5f69\u3002<\/p>\n\n\n\n<p>\uff082\uff09\u4ece\u706b\u7130\u5e95\u90e8\u81ea\u4e0b\u800c\u4e0a\u4eae\u5ea6\u4f1a\u9010\u6b65\u9012\u51cf\uff0c\u4e14\u8272\u5f69\u4f1a\u9010\u6b65\u53d8\u6df1\u5411\u6df1\u7ea2\u3001\u8910\u7ea2\u8272\u9760\u8fd1\u3002<\/p>\n\n\n\n<p>\uff083\uff09\u6bcf\u4e00\u652f\u706b\u7130\u7684\u9ad8\u5ea6\u662f\u968f\u673a\u8df3\u8dc3\u7684\uff0c\u6574\u4f53\u6210\u56e2\u72b6\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-1024x576.jpg\" alt=\"\" class=\"wp-image-407\" srcset=\"https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-1024x576.jpg 1024w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-300x169.jpg 300w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-768x432.jpg 768w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-1536x864.jpg 1536w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-110x62.jpg 110w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-200x113.jpg 200w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-380x214.jpg 380w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-255x143.jpg 255w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-550x309.jpg 550w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-800x450.jpg 800w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1-1160x653.jpg 1160w, https:\/\/pakies.cc\/wp-content\/uploads\/2024\/10\/\u672a\u6807\u9898-2-1.jpg 1920w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u4ee5\u4e0a\u4e09\u79cd\u7279\u5f81\u5c06\u4f1a\u4f5c\u4e3a\u7a0b\u5e8f\u5b9e\u73b0\u7684\u601d\u8def\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 id=\"%e7%a8%8b%e5%ba%8f%e7%9a%84%e5%ae%9e%e7%8e%b0\" class=\"wp-block-heading has-text-align-center\"><strong>\u7a0b\u5e8f\u7684\u5b9e\u73b0<\/strong><\/h2>\n\n\n\n<p>\u5728\u7b2c\u4e00\u7bc7\u6587\u7ae0\u4e2d\u63d0\u5230\uff0c\u7b14\u8005\u4f7f\u7528\u4e86FastLED\u5e93\u5bf91024\u9897WS2812\u7684LED\u9635\u5217\u8fdb\u884c\u9a71\u52a8\uff0c\u8fd9\u4e2aArduino\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u975e\u5e38\u65b9\u4fbf\u5730\u51fd\u6570\u5bf9\u4e8eLED\u9635\u5217\u8fdb\u884c\u5feb\u901f\u9a71\u52a8\uff0c\u63a5\u4e0b\u6765\u7684\u7a0b\u5e8f\u4e5f\u5c06\u4f7f\u7528\u5230\u8fd9\u4e2a\u5e93\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void Fire()\n{\n\/\/ \u6bcf\u9897LED\u7684\u70ed\u91cf\u53c2\u6570\n  static uint8_t heat&#91;NUM_LEDS];\n \n  \/\/ Step 1.  \u51b7\u5374\u6bcf\u4e2a\u5355\u5143\u683c\uff0c\u4f7f\u706b\u7130\u53d8\u51b7\n    for( int i = 0; i &lt; NUM_LEDS; i++) {\n      heat&#91;i] = qsub8( heat&#91;i],  random8(0, ((COOLING * 10) \/ NUM_LEDS) + 2));\n    }\n  \n    \/\/ Step 2.  \u70ed\u91cf\u4ece\u6bcf\u4e2a\u5355\u5143\u683c\u5411\u4e0a\u6269\u6563\n    for( int k= NUM_LEDS - 1; k >= 2; k--) {\n      heat&#91;k] = (heat&#91;k - 1] + heat&#91;k - 2] + heat&#91;k - 3] ) \/ 3;\n    }\n    \n    \/\/ Step 3.  \u968f\u673a\u70b9\u71c3\u5e95\u90e8\u7684\u65b0\u706b\u82b1\n    if( random8() &lt; SPARKING ) {\n      int y = random8(7);\n      heat&#91;y] = qadd8( heat&#91;y], random8(160,255) );\n    }\n \n    \/\/ Step 4.  \u5c06\u70ed\u91cf\u503c\u6620\u5c04\u5230\u989c\u8272\uff0c\u901a\u8fc7\u8c03\u8272\u677f\u751f\u6210\u989c\u8272\n    for( int j = 0; j &lt; NUM_LEDS; j++) {\n      \/\/ Scale the heat value from 0-255 down to 0-240\n      \/\/ for best results with color palettes.\n      uint8_t colorindex = scale8( heat&#91;j], 240);\n      CRGB color = ColorFromPalette( gPal, colorindex);\n      int pixelnumber;\n      if( gReverseDirection ) {\n        pixelnumber = (NUM_LEDS-1) - j;\n      } else {\n        pixelnumber = j;\n      }\n      leds&#91;pixelnumber] = color;\n    }<\/code><\/pre>\n\n\n\n<p>\u8fd9\u662f\u4e00\u6bb5\u57fa\u4e8efire2012\u8fdb\u884c\u4fee\u6539\u7684\u5f97\u5230\u7684\u5b9e\u73b0\u706b\u7130\u6548\u679c\u7684\u6838\u5fc3\u7a0b\u5e8f\uff1a<\/p>\n\n\n\n<p><strong>1\u3001\u70ed\u91cf\u53c2\u6570\u6570\u7ec4<\/strong><\/p>\n\n\n\n<p>static uint8_t heat[NUM_LEDS];<\/p>\n\n\n\n<p>\u8fd9\u662f\u4e00\u4e2a\u9759\u6001\u6570\u7ec4\uff0c\u7528\u4e8e\u5b58\u50a8\u6bcf\u4e2aLED\u7684\u70ed\u91cf\u503c\u3002\u7531\u4e8e\u4f7f\u7528<code>static<\/code>\u4fee\u9970\u7b26\uff0c\u8fd9\u4e2a\u6570\u7ec4\u5728\u51fd\u6570\u8c03\u7528\u4e4b\u95f4\u4fdd\u7559\u5176\u503c\u3002<\/p>\n\n\n\n<p><strong>2\u3001\u706b\u7130\u7684\u51b7\u5374<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (int i = 0; i &lt; NUM_LEDS; i++) {\n    heat&#91;i] = qsub8(heat&#91;i], random8(0, ((COOLING * 10) \/ NUM_LEDS) + 2));\n}<\/code><\/pre>\n\n\n\n<p>\u6bcf\u4e2aLED\u7684\u70ed\u91cf\u4f1a\u51cf\u5c11\uff0c<code>qsub8<\/code>\u51fd\u6570\u786e\u4fdd\u70ed\u91cf\u4e0d\u4f1a\u4f4e\u4e8e0\u3002\u51cf\u5c11\u7684\u91cf\u662f\u968f\u673a\u7684\uff0c\u53d6\u51b3\u4e8e<code>COOLING<\/code>\u53c2\u6570\uff0c\u5f62\u6210\u81ea\u7136\u7684\u51b7\u5374\u6548\u679c\u3002<\/p>\n\n\n\n<p><strong>3\u3001\u70ed\u91cf\u7684\u6269\u6563<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (int k = NUM_LEDS - 1; k >= 2; k--) {\n    heat&#91;k] = (heat&#91;k - 1] + heat&#91;k - 2] + heat&#91;k - 2]) \/ 3;\n}<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u7684\u903b\u8f91\u662f\u5c06\u6bcf\u4e2aLED\u7684\u70ed\u91cf\u66f4\u65b0\u4e3a\u5176\u4e0b\u65b9LED\u7684\u70ed\u91cf\u7684\u5e73\u5747\u503c\u3002\u8fd9\u6837\uff0c\u70ed\u91cf\u4f1a\u9010\u6e10\u5411\u4e0a\u6269\u6563\uff0c\u6a21\u62df\u706b\u7130\u5411\u4e0a\u7684\u6d41\u52a8\u3002<\/p>\n\n\n\n<p><strong>4\u3001\u968f\u673a\u4ea7\u751f\u65b0\u7684\u706b\u82b1<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (random8() &lt; SPARKING) {\n    int y = random8(7);\n    heat&#91;y] = qadd8(heat&#91;y], random8(160, 255));\n}<\/code><\/pre>\n\n\n\n<p><strong>5\u3001\u5c06heat[]\u6620\u5c04\u5230LED\u771f\u5b9e\u7684RGB\u8272\u5f69<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>for (int j = 0; j &lt; NUM_LEDS; j++) {\n    uint8_t colorindex = scale8(heat&#91;j], 240);\n    CRGB color = ColorFromPalette(gPal, colorindex);\n    int pixelnumber;\n    if (gReverseDirection) {\n        pixelnumber = (NUM_LEDS - 1) - j;\n    } else {\n        pixelnumber = j;\n    }\n    leds&#91;pixelnumber] = color;\n}<\/code><\/pre>\n\n\n\n<p>\u5c06\u70ed\u91cf\u503c\u7f29\u653e\u52300-240\u8303\u56f4\u5185\uff0c\u4ee5\u9002\u5e94\u8c03\u8272\u677f\u7684\u989c\u8272\u7d22\u5f15\u3002\u4f7f\u7528<code>ColorFromPalette()<\/code>\u51fd\u6570\u4ece\u6307\u5b9a\u7684\u8c03\u8272\u677f\u4e2d\u83b7\u53d6\u76f8\u5e94\u7684\u989c\u8272\u3002\u6700\u540e\uff0c\u6839\u636e\u662f\u5426\u53cd\u5411\u663e\u793a\uff0c\u5c06\u989c\u8272\u5e94\u7528\u5230\u76f8\u5e94\u7684LED\u4e0a\u3002<\/p>\n\n\n\n<p><strong>\u5176\u4e2d\u53ef\u4ee5\u8c03\u6574\u7684\u53d8\u91cf\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n<p><strong>COOLING<\/strong>\uff1a\u63a7\u5236\u706b\u7130\u51b7\u5374\u7684\u901f\u5ea6\uff0c\u8f83\u4f4e\u503c\u4f1a\u4f7f\u706b\u7130\u53d8\u9ad8\uff0c\u8f83\u9ad8\u503c\u5219\u4f1a\u4f7f\u706b\u7130\u8f83\u77ed\u3002<\/p>\n\n\n\n<p><strong>SPARKING<\/strong>\uff1a\u63a7\u5236\u65b0\u706b\u82b1\u70b9\u71c3\u7684\u6982\u7387\uff0c\u8f83\u9ad8\u503c\u4f7f\u706b\u7130\u66f4\u65fa\u76db\uff0c\u8f83\u4f4e\u503c\u5219\u4f7f\u706b\u7130\u66f4\u95ea\u70c1\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u8fd9\u4e9b\u53c2\u6570\u53ef\u4ee5\u5bf9\u706b\u7130\u7684\u7279\u5f81\u8fdb\u884c\u4e00\u5b9a\u7a0b\u5ea6\u7684\u8c03\u6574\uff0c\u5305\u62ec\u706b\u7130\u5927\u5c0f\u5e45\u5ea6\uff0c\u4e14\u4fee\u6539\u4ee3\u7801\u53ef\u8c03\u6574\u8272\u5f69\u4e0d\u5c40\u9650\u4e8e\u5e38\u89c4\u7684\u706b\u7130\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u4ee5\u4e0a\u4ee3\u7801\u5b9e\u73b0\u4e86\u706b\u7130\u6a21\u62df\u7684\u8fc7\u7a0b\uff0c\u4e14\u901a\u8fc7\u8868\u9762\u7684\u78e8\u7802\u4e9a\u514b\u529b\u677f\u8fdb\u4e00\u6b65\u5bf9\u56fe\u50cf\u8fdb\u884c\u4e86\u6a21\u7cca\u5316\u5904\u7406\u8fdb\u800c\u5448\u73b0\u51fa\u66f4\u4e3a\u6bd4\u903c\u771f\u7684\u6548\u679c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728\u6a21\u62df\u6570\u5b57\u7bdd\u706b\u7684\u9879\u76ee\u4e2d\u6211\u4eec\u5c06\u706b\u7130\u7684\u5f62&hellip;\n","protected":false},"author":1,"featured_media":394,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[20,21,22,19],"class_list":{"0":"post-405","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-18","8":"tag-esp32","9":"tag-ws2812b","10":"tag-22","11":"tag-19"},"acf":[],"_links":{"self":[{"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/posts\/405","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/comments?post=405"}],"version-history":[{"count":2,"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/posts\/405\/revisions"}],"predecessor-version":[{"id":411,"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/posts\/405\/revisions\/411"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/media\/394"}],"wp:attachment":[{"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/media?parent=405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/categories?post=405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pakies.cc\/index.php\/wp-json\/wp\/v2\/tags?post=405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}