{"id":2514,"date":"2023-08-05T11:31:18","date_gmt":"2023-08-05T03:31:18","guid":{"rendered":"https:\/\/104.es\/?p=2514"},"modified":"2023-08-05T11:31:18","modified_gmt":"2023-08-05T03:31:18","slug":"microbitmicropython-ssd1306","status":"publish","type":"post","link":"https:\/\/104.es\/index.php\/2023\/08\/05\/microbitmicropython-ssd1306\/","title":{"rendered":"\u3010micro:bit\u3011MicroPython SSD1306 oled\u5be6\u4f5c"},"content":{"rendered":"\n<p>\u5728\u524d\u9762\u7684\u55ae\u5143\u4e2d\u6211\u5011\u66fe\u7d93\u4ecb\u7d39\u904e\u4e00\u6b3e0.96\u540b\uff0c\u89e3\u6790\u5ea6\u5728128&#215;64\u7684OLED\u986f\u793a\u5668\uff0c\u7576\u6642\u662f\u5728\u7a4d\u6728\u958b\u767c\u7684\u74b0\u5883\u4e0b\u4f7f\u7528\u5b83\u7684\u64f4\u5145\u7a4d\u6728\u4f86\u986f\u793a\u6587\u5b57\uff0c\u73fe\u5728\uff0c\u4f7f\u7528\u540c\u6a23\u7684\u9023\u7dda\u65b9\u5f0f\uff08\u628aSCL\u548cSCL\u63a5\u5728\u4e00\u8d77\uff0cSDA\u548cSDA\u63a5\u5728\u4e00\u8d77\uff0c\u4e26\u4f9b\u96fb\u7d66oled\uff09\uff0c\u5229\u7528MicroPython\u4e5f\u53ef\u4ee5\u5728\u986f\u793a\u5668\u4e0a\u986f\u793a\u51fa\u6587\u5b57\u548c\u5716\u5f62\u3002<\/p>\n\n\n\n<p>\u4e0d\u904e\u5728\u5167\u5efa\u7684MicroPython\u6a21\u7d44\u4e2d\u4e26\u6c92\u6709\u76f4\u63a5\u652f\u63f4\u9019\u6b3e\u986f\u793a\u5668\uff08ssd1306\uff09\u7684\u7a0b\u5f0f\u78bc\uff0c\u6240\u5e78\u6709\u71b1\u5fc3\u4eba\u58eb\u63d0\u4f9b\u4e86Python\u7a0b\u5f0f\u53ef\u4f9b\u6211\u5011\u532f\u5165\u4f7f\u7528\uff0c\u9023\u7d50\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/fizban99\/microbit_ssd1306\">https:\/\/github.com\/fizban99\/microbit_ssd1306<\/a><\/p>\n\n\n\n<p>\u5728\u4e0a\u9762\u7684\u7db2\u9801\u4e2d\u6709\u8a73\u7d30\u7684\u4f7f\u7528\u8aaa\u660e\uff0c\u5c0d\u6211\u5011\u4f86\u8aaa\uff0c\u53ea\u8981\u628a\u9019\u4e9b\u7a0b\u5f0f\uff08\u6240\u6709*.py\uff09\u901a\u901a\u4e0b\u8f09\u5230\u6211\u5011\u7684\u96fb\u8166\uff0c\u89e3\u58d3\u7e2e\u4e4b\u5f8c\u628a\u6240\u6709\u7684\u7a0b\u5f0f\u90fd\u653e\u5728mu_code\u8cc7\u6599\u593e\u4e4b\u4e0b\uff0c\u518d\u900f\u904eMu Editor\u628a\u9019\u4e9b.py\u7684\u6a94\u6848\u9010\u4e00\u4e0a\u50b3\u5230micro:bit\u677f\u5b50\u4e0a\uff0c\u57fa\u672c\u4e0a\u5c31\u53ef\u4ee5\u7576\u4f5c\u662f\u6a21\u7d44\u5728\u6211\u5011\u7684\u7a0b\u5f0f\u4e2d\u532f\u5165\u4e26\u4f7f\u7528\u5b83\u7684\u51fd\u6578\u4e86\u3002<\/p>\n\n\n\n<p>\u5148\u4f86\u770b\u770b\u7a0b\u5f0f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from ssd1306 import initialize, clear_oled\r\nfrom ssd1306_text import add_text\r\nfrom microbit import *\r\n\r\ninitialize()\r\nclear_oled()\r\nadd_text(0, 0, 'NKUST')\r\nadd_text(0, 1, 'Richard Ho')\r\nwhile True:\r\n    add_text(0, 2, '{:>4d}'.format(temperature()))\r\n    sleep(2000)<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u53ea\u662f\u8981\u986f\u793a\u6587\u5b57\u7684\u8a71\uff0c\u9700\u8981\u7528\u5230\u7684\u662finitialize\u521d\u59cb\u5316\u51fd\u6578\u4ee5\u53caclear_oled\uff0c\u7528\u4f86\u6e05\u9664\u756b\u9762\u7684clear_oled\u51fd\u6578\uff0c\u8981\u986f\u793a\u6587 \u5b57\u5247\u662f\u4f7f\u7528add_text\u51fd\u6578\uff0c\u5b83\u7684\u524d2\u500b\u53c3\u6578\u5206\u5225\u662f\u884c\u4ee5\u53ca\u5217\uff0c\u7b2c3\u500b\u51fd\u6578\u5247\u662f\u8981\u986f\u793a\u7684\u6587\u5b57\u5b57\u4e32\u5167\u5bb9\u3002<\/p>\n\n\n\n<p>\u5728\u4e0a\u9762\u7684\u7a0b\u5f0f\u4f8b\u5b50\u4e2d\u7684\u7b2c7\u884c\u5148\u5728\u7b2c0\u5217\u986f\u793a\u51fa\u5b78\u6821\u7684\u7c21\u7a31\uff0c\u7b2c8\u884c\u5728\u7b2c1\u5217\u986f\u793a\u51fa\u81ea\u5df1\u7684\u82f1\u6587\u540d\u5b57\uff0c\u7b2c10\u884c\u5247\u662f\u5728\u7b2c2\u5217\u986f\u793a\u51fa\u76ee\u524d\u7684\u6676\u7247\u8868\u9762\u6eab\u5ea6\u3002<\/p>\n\n\n\n<p>\u6709\u4e86\u9019\u500b\u986f\u793a\u5668\uff0c\u6211\u5011\u5c31\u4e0d\u518d\u9700\u8981\u4f7f\u7528\u5167\u5efa5x5LED\u4f86\u6372\u52d5\u6587\u5b57\u4e86\uff0c\u975e\u5e38\u65b9\u4fbf\u5594\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u524d\u9762\u7684\u55ae\u5143\u4e2d\u6211\u5011\u66fe\u7d93\u4ecb\u7d39\u904e\u4e00\u6b3e0.96\u540b\uff0c\u89e3\u6790\u5ea6\u5728128&#215;64\u7684OLED\u986f\u793a\u5668\uff0c\u7576\u6642\u662f\u5728\u7a4d\u6728\u958b\u767c\u7684\u74b0\u5883\u4e0b\u4f7f\u7528\u5b83\u7684\u64f4\u5145\u7a4d\u6728\u4f86\u986f\u793a\u6587\u5b57\uff0c\u73fe\u5728\uff0c\u4f7f\u7528\u540c\u6a23\u7684\u9023\u7dda\u65b9\u5f0f\uff08\u628aSCL\u548cSCL\u63a5\u5728\u4e00\u8d77\uff0cSDA\u548cSDA\u63a5\u5728\u4e00\u8d77\uff0c\u4e26\u4f9b\u96fb\u7d66oled\uff09\uff0c\u5229\u7528MicroPython\u4e5f\u53ef\u4ee5\u5728\u986f\u793a\u5668\u4e0a\u986f\u793a\u51fa\u6587\u5b57\u548c\u5716\u5f62\u3002<\/p>\n","protected":false},"author":1,"featured_media":2341,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[11,15],"tags":[],"class_list":["post-2514","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microbit","category-python"],"jetpack_featured_media_url":"https:\/\/104.es\/wp-content\/uploads\/2023\/07\/image-129.png","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2514","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/comments?post=2514"}],"version-history":[{"count":1,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2514\/revisions"}],"predecessor-version":[{"id":2515,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/posts\/2514\/revisions\/2515"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media\/2341"}],"wp:attachment":[{"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/media?parent=2514"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/categories?post=2514"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/104.es\/index.php\/wp-json\/wp\/v2\/tags?post=2514"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}