{"id":672,"date":"2020-01-17T16:27:23","date_gmt":"2020-01-17T08:27:23","guid":{"rendered":"http:\/\/www.x1985.org\/?p=672"},"modified":"2020-01-17T16:28:10","modified_gmt":"2020-01-17T08:28:10","slug":"%e2%99%9e%e6%a0%91%e8%8e%93%e6%b4%be%e4%b9%8b%e5%ae%89%e8%a3%85%e5%a2%a8%e6%b0%b4%e5%b1%8f","status":"publish","type":"post","link":"http:\/\/www.x1985.org\/?p=672","title":{"rendered":"\u265e\u6811\u8393\u6d3e\u4e4b\u5b89\u88c5\u58a8\u6c34\u5c4f"},"content":{"rendered":"<pre title=\"\u4f7f\u7528\u7cfb\u7edf\u955c\u50cf\" class=\"lang:vim decode:true\">2019-09-26-raspbian-buster-lite.img<\/pre>\n<p style=\"text-align: left;\">\u58a8\u6c34\u5c4f\u91c7\u7528\u7684\u662f\u5fae\u96ea\u7535\u5b50\u76842.13inch e-Paper HAT\u578b\u53f7\uff0c\u662f\u5e26\u677f\u9ed1\u767d\u7248\u7684\uff0c\u652f\u6301\u5c40\u90e8\u5237\u65b0\uff08\u5982\u4e0b\u56fe\u6240\u793a\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-675 size-medium\" src=\"http:\/\/www.x1985.org\/wp-content\/uploads\/2020\/01\/2_13inch-e-Paper-HAT-3-e1579245255830-300x144.jpg\" alt=\"\" width=\"300\" height=\"144\" srcset=\"http:\/\/www.x1985.org\/wp-content\/uploads\/2020\/01\/2_13inch-e-Paper-HAT-3-e1579245255830-300x144.jpg 300w, http:\/\/www.x1985.org\/wp-content\/uploads\/2020\/01\/2_13inch-e-Paper-HAT-3-e1579245255830-600x287.jpg 600w, http:\/\/www.x1985.org\/wp-content\/uploads\/2020\/01\/2_13inch-e-Paper-HAT-3-e1579245255830.jpg 1029w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><br \/>\n<strong>\u786c\u4ef6\u8fde\u63a5<\/strong><\/p>\n<table class=\"table table-striped table-bordered\" style=\"width: 700px;\" border=\"1\" align=\"center\">\n<caption>\u6811\u8393\u6d3e\u8fde\u63a5\u5f15\u811a\u5bf9\u5e94\u5173\u7cfb<\/caption>\n<tbody>\n<tr style=\"background: #228B22; color: white;\" align=\"center\">\n<td rowspan=\"2\">e-Paper<\/td>\n<td colspan=\"2\">Raspberry Pi<\/td>\n<\/tr>\n<tr style=\"background: #228B22; color: white;\" align=\"center\">\n<td>BCM2835\u7f16\u7801<\/td>\n<td>Board\u7269\u7406\u5f15\u811a\u5e8f\u53f7<\/td>\n<\/tr>\n<tr align=\"center\">\n<td>VCC<\/td>\n<td>3.3V<\/td>\n<td>3.3V<\/td>\n<\/tr>\n<tr align=\"center\">\n<td>GND<\/td>\n<td>GND<\/td>\n<td>GND<\/td>\n<\/tr>\n<tr align=\"center\">\n<td>DIN<\/td>\n<td>MOSI<\/td>\n<td>19<\/td>\n<\/tr>\n<tr align=\"center\">\n<td>CLK<\/td>\n<td>SCLK<\/td>\n<td>23<\/td>\n<\/tr>\n<tr align=\"center\">\n<td>CS<\/td>\n<td>CE0<\/td>\n<td>24<\/td>\n<\/tr>\n<tr align=\"center\">\n<td>DC<\/td>\n<td>25<\/td>\n<td>22<\/td>\n<\/tr>\n<tr align=\"center\">\n<td>RST<\/td>\n<td>17<\/td>\n<td>11<\/td>\n<\/tr>\n<tr align=\"center\">\n<td>BUSY<\/td>\n<td>24<\/td>\n<td>18<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u524d\u671f\u51c6\u5907\u5de5\u4f5c<\/strong><\/p>\n<pre title=\"\u6253\u5f00\u6811\u8393\u6d3e\u7ec8\u7aef\" class=\"top-margin:5 bottom-margin:5 lang:sh decode:true\">#\u5347\u7ea7\u7cfb\u7edf\r\nsudo apt-get update\r\nsudo apt-get upgrade\r\n\r\n#\u5f00\u542fSPI\u63a5\u53e3\r\nsudo raspi-config\r\n\u9009\u62e9Interfacing Options -&gt; SPI -&gt; Yes \u5f00\u542fSPI\u63a5\u53e3\r\n\r\nsudo reboot\r\n\r\nsudo apt-get install git<\/pre>\n<p><strong>\u5b89\u88c5Python\u53ca\u51fd\u6570\u5e93<\/strong><\/p>\n<pre title=\"Python2\u73af\u5883\" class=\"top-margin:5 bottom-margin:5 lang:sh decode:true\">sudo apt-get update\r\nsudo apt-get install python-pip\r\nsudo apt-get install python-pil\r\nsudo apt-get install python-numpy\r\nsudo pip install RPi.GPIO\r\nsudo pip install spidev<\/pre>\n<pre title=\"Python3\u73af\u5883\" class=\"top-margin:5 bottom-margin:5 lang:sh decode:true\">sudo apt-get update\r\nsudo apt-get install python3-pip\r\nsudo apt-get install python3-pil\r\nsudo apt-get install python3-numpy\r\nsudo pip3 install RPi.GPIO\r\nsudo pip3 install spidev<\/pre>\n<pre title=\"\u4e0b\u8f7d\u5e94\u7528\u7a0b\u5e8f\u53ca\u6d4b\u8bd5\" class=\"top-margin:5 bottom-margin:5 lang:sh decode:true\">sudo git clone https:\/\/github.com\/waveshare\/e-Paper\r\ncd e-Paper\/RaspberryPi\\&amp;JetsonNano\/python\/examples\r\nsudo python3 epd_2in13_V3_test.py<\/pre>\n<pre title=\"\u265e\u5f00\u673a\u542f\u52a8\u8bbe\u7f6e \/etc\/rc.local\" class=\"top-margin:5 bottom-margin:5 lang:sh decode:true\">#exit 0\u524d\u63d2\u5165\r\nsu pi -c \"python3 \/home\/pi\/e-Paper\/RaspberryPi\\&amp;JetsonNano\/python\/examples\/view_ip.py\"<\/pre>\n<pre title=\"\u9644\u672c\u4eba\u5b9e\u9645\u4f7f\u7528view_ip.py\u6587\u4ef6\u4ee3\u7801\" class=\"height-set:true height:200 lang:python decode:true\">#!\/usr\/bin\/python\r\n# -*- coding:utf-8 -*-\r\n#250*122\r\nimport sys\r\nimport os\r\nimport socket\r\npicdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'pic')\r\nlibdir = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), 'lib')\r\nif os.path.exists(libdir):\r\n    sys.path.append(libdir)\r\n\r\nimport logging\r\nfrom waveshare_epd import epd2in13_V2\r\nimport time,datetime\r\nfrom PIL import Image,ImageDraw,ImageFont\r\nimport traceback\r\n\r\nlogging.basicConfig(level=logging.DEBUG)\r\n\r\ntry:\r\n    \r\n    # Drawing on the image\r\n    fonta = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 14)\r\n    fontb = ImageFont.truetype(os.path.join(picdir, 'Font.ttc'), 18)\r\n    \r\n    # # partial update\r\n    logging.info(\"1.show IP Address\")\r\n    epd = epd2in13_V2.EPD()\r\n    view_ip_w = Image.new('1', (epd.height, epd.width), 255)\r\n    view_ip = ImageDraw.Draw(view_ip_w)\r\n    \r\n    eth0_status=os.popen(\"ethtool eth0 |grep \\\"Link detected:\\\"\").readline().split(\":\")[1].replace(\"\\n\",\" \").strip()\r\n    #print(eth0_status)\r\n    if eth0_status == \"yes\":\r\n        #\u63d0\u53d6IP\u5730\u5740\r\n\t#s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)   \r\n\t#s.connect(('1.1.1.1',80))\r\n\t#ip_address =s.getsockname()[0]\r\n\t#s.close()\r\n        ip_address=os.popen(\"ifconfig eth0 |grep \\\"inet \\\"\").readline().strip().split(\" \")[1]\r\n    else:\r\n        ip_address=\"\u672a\u8054\u63a5\u6709\u7ebf\u7f51\u7edc\"\r\n\r\n    ff=open(\"\/etc\/hostapd\/hostapd.conf\",\"rt\")\r\n    fff=ff.readlines()\r\n    \r\n    wifi_ssid=fff[1].split(\"=\")[1]\r\n    wifi_pass=fff[7].split(\"=\")[1]\r\n    ff.close()\r\n    del fff\r\n    start_date=\"\u672c\u6b21\u5f00\u673a\u65f6\u95f4\uff1a\"+datetime.datetime.now().strftime(\"%Y-%m-%d  %H:%M:%S\") \r\n\r\n    view_ip.text((10, 5), u'\u4e1c\u6e2f\u5e02\u9ed1\u9a6c\u7f51\u7edc\u79d1\u6280\u6709\u9650\u516c\u53f8', font = fontb, fill = 0)\r\n    view_ip.line([(0,30),(250,30)], fill = 0,width = 2)\r\n    view_ip.line([(0,55),(250,55)], fill = 0,width = 1)\r\n    view_ip.text((0,35), u\"\u6709\u7ebf\u8bbf\u95ee\u5730\u5740:\"+ip_address, font = fonta, fill = 0)\r\n    view_ip.text((0,59), u\"\u65e0\u7ebf\u8bbf\u95ee\u5730\u5740:192.168.66.1\", font = fonta, fill = 0)\r\n    view_ip.line([(0,80),(250,80)], fill = 0,width = 2)\r\n    view_ip.text((0,82),u'\u70ed\u70b9',font=fonta,fill=0)\r\n    view_ip.line([(35,80),(35,100)], fill = 0,width = 1)\r\n    view_ip.line([(125,80),(125,100)],fill=0,width=1)\r\n    view_ip.text((40,82),wifi_ssid,font=fonta,fill=0)  \r\n    view_ip.text((130,82),wifi_pass,font=fonta,fill=0)  \r\n    view_ip.line([(0,100),(250,100)], fill = 0,width = 2)\r\n    view_ip.text((0,104),start_date,font=fonta,fill=0)\r\n    epd.init(epd.FULL_UPDATE)\r\n    epd.displayPartBaseImage(epd.getbuffer(view_ip_w))\r\n\r\n\r\n    #epd.init(epd.PART_UPDATE)\r\n    #epd.displayPartial(epd.getbuffer(view_ip_w))\r\n    #epd.display(epd.getbuffer(view_ip_w))\r\n\r\n    \r\n    #logging.info(\"Clear...\")\r\n    #epd.init(epd.FULL_UPDATE)\r\n    #epd.Clear(0xFF)\r\n    \r\n    logging.info(\"Goto Sleep...\")\r\n    epd.sleep()\r\n        \r\nexcept IOError as e:\r\n    logging.info(e)\r\n    \r\nexcept KeyboardInterrupt:    \r\n    logging.info(\"ctrl + c:\")\r\n    epd2in13_V2.epdconfig.module_exit()\r\n    exit()\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2019-09-26-raspbian-buster-lite.img \u58a8\u6c34\u5c4f\u91c7\u7528\u7684\u662f\u5fae\u96ea\u7535\u5b50\u76842.13inc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":584,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[86,44],"_links":{"self":[{"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/posts\/672"}],"collection":[{"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.x1985.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=672"}],"version-history":[{"count":16,"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/posts\/672\/revisions"}],"predecessor-version":[{"id":689,"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/posts\/672\/revisions\/689"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.x1985.org\/index.php?rest_route=\/wp\/v2\/media\/584"}],"wp:attachment":[{"href":"http:\/\/www.x1985.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.x1985.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=672"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.x1985.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}