{"id":1292,"date":"2014-01-23T08:23:30","date_gmt":"2014-01-22T23:23:30","guid":{"rendered":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/?p=1292"},"modified":"2014-02-03T06:26:29","modified_gmt":"2014-02-02T21:26:29","slug":"beaglebone-black-6","status":"publish","type":"post","link":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/2014\/01\/beaglebone-black-6\/","title":{"rendered":"<!--:ja-->BeagleBone Black \u306e\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u30cf\u30c3\u30af(6)<!--:--><!--:en-->Hacking BeagleBone Black, part 6<!--:-->"},"content":{"rendered":"<p><!--:ja--><\/p>\n<h2>BeagleBone Black\u306e\u30bb\u30f3\u30b5\u8868\u793a\u306e\u30b3\u30fc\u30c9\u3092\u307e\u3068\u3081\u308b\u3002<\/h2>\n<p>\u3053\u308c\u307e\u3067\u4f5c\u3063\u3066\u304d\u305f\u30b3\u30fc\u30c9\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001BeagleBone Black\u306b\u53d6\u308a\u4ed8\u3051\u305fLCD\u306b\u6642\u523b\u3068\u6e29\u5ea6\u3001\u7167\u5ea6\u3092\u8868\u793a\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<div id=\"attachment_1301\" style=\"width: 382px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/01\/IMGP9674.jpg\"><img aria-describedby=\"caption-attachment-1301\" loading=\"lazy\" class=\"size-medium wp-image-1301\" title=\"LCD on BBB\" src=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/01\/IMGP9674-372x300.jpg\" alt=\"LCD on BBB\" width=\"372\" height=\"300\" srcset=\"http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/01\/IMGP9674-372x300.jpg 372w, http:\/\/morecatlab.akiba.coocan.jp\/lab\/wp-content\/uploads\/2014\/01\/IMGP9674.jpg 640w\" sizes=\"(max-width: 372px) 100vw, 372px\" \/><\/a><p id=\"caption-attachment-1301\" class=\"wp-caption-text\">LCD on BBB<\/p><\/div>\n<p><!--:--><!--more--><!--:ja-->\u5de5\u592b\u3057\u305f\u70b9\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002<\/p>\n<p>(1) AD\u5909\u63db\u306e\u305f\u3081\u306b\u4f7f\u3063\u305fAdafruit\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u306fpython\u3067\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u3002\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u304b\u3089\u5236\u5fa1\u3057\u3088\u3046\u3068\u3057\u305f\u5834\u5408\u3001\u6bce\u56depython\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u3000\u3053\u306e\u305f\u3081\u3001AD\u5909\u63db\u306e\u6a5f\u80fd\u3082\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u3067\u8a18\u8ff0\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>(2) (1)\u306b\u4f34\u3044\u3001cape\u306e\u521d\u671f\u5316\u3082\u30b7\u30a7\u30eb\u30b9\u30af\u30ea\u30d7\u30c8\u306b\u5165\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>(3) \u30bf\u30a4\u30df\u30f3\u30b0\u306b\u4f9d\u3063\u3066AD\u5909\u63db\u304c\u5931\u6557\u3059\u308b\u3053\u3068\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u30ea\u30c8\u30e9\u30a4\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u5b8c\u6210\u3057\u305f\u30b3\u30fc\u30c9\u306f\u6b21\u306e\u901a\u308a\u3067\u3059\u3002(\/usr\/local\/bin\/i2c-time-and-temp.sh)<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\n\r\nunset TERM\r\n\r\ni2cset=\/usr\/local\/sbin\/i2cset\r\nbus=1\r\nchip=0x3e\r\nLANG=C\r\n\r\n#initialize cape\r\nif ! grep -q cape-bone-iio \/sys\/devices\/bone_capemgr.9\/slots ; then\r\n    echo cape-bone-iio &gt; \/sys\/devices\/bone_capemgr.9\/slots ;\r\n    sleep 1;\r\nfi\r\n\r\nporttmp=`find \/sys -name \\*AIN1\\* -print`\r\nportcds=`find \/sys -name \\*AIN3\\* -print`\r\n\r\n# initialize LCD display\r\n$i2cset -y $bus $chip 0 0x38 0x39 0x14 0x7f 0x5f 0x6c i\r\nsleep 0.5\r\n$i2cset -y $bus $chip 0 0x38 0x0d 0x01 i\r\nsleep 0.5\r\n\r\nwhile true ; do\r\n    msg1=`date +&quot;%X&quot; | perl -pe '$_=join&quot; &quot;,map{ord }split\/\/'`\r\n\r\n    while true ; do\r\n\ttemp=`cat $porttmp 2&gt;&amp;1 \/dev\/null `\r\n\tif &#x5B; $? -eq 0 ]; then break; fi\r\n    done\r\n\r\n    while true ; do\r\n\tlight=`cat $portcds 2&gt;&amp;1 \/dev\/null`\r\n\tif &#x5B; $? -eq 0 ]; then break; fi\r\n    done\r\n\r\n    ttmp=`echo &quot;( $temp.0 - 500.0) * 0.1&quot; | bc`\r\n    light1=`echo &quot; $light \/ 18&quot; | bc`\r\n    msg2=`echo $ttmp $light1\\% | perl -pe '$_=join&quot; &quot;,map{ord }split\/\/'`\r\n    # echo $msg2\r\n    $i2cset -y $bus $chip 0 0x01\r\n    $i2cset -y $bus $chip 0x40 $msg1 i\r\n    $i2cset -y $bus $chip 0 0xc0 i\r\n    $i2cset -y $bus $chip 0x40 $msg2 i\r\n    sleep 1\r\ndone\r\n<\/pre>\n<p>\u8d77\u52d5\u6642\u306b\u3053\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u30d0\u30c3\u30af\u30b0\u30e9\u30a6\u30f3\u30c9\u3067\u52d5\u304b\u3059\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\/lib\/systemd\/system\/lcd.service\u306e\u8a2d\u5b9a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n\r\n&#x5B;Unit]\r\nDescription=LCD Display\r\n\r\n&#x5B;Service]\r\nType=simple\r\nExecStart=\/usr\/local\/bin\/i2c-time-and-temp.sh\r\n\r\n&#x5B;Install]\r\nWantedBy=multi-user.target\r\n\r\n<\/pre>\n<p>\u30b5\u30fc\u30d3\u30b9\u306e\u767b\u9332<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n # ln -s \/lib\/systemd\/system\/lcd.service \/etc\/systemd\/system\r\n # systemctl daemon-reload\r\n # systemctl start lcd.service\r\n # systemctl enable lcd.service\r\n<\/pre>\n<p><!--:--><\/p>\n","protected":false},"excerpt":{"rendered":"<p>BeagleBone Black\u306e\u30bb\u30f3\u30b5\u8868\u793a\u306e\u30b3\u30fc\u30c9\u3092\u307e\u3068\u3081\u308b\u3002 \u3053\u308c\u307e\u3067\u4f5c\u3063\u3066\u304d\u305f\u30b3\u30fc\u30c9\u3092\u7d44\u307f\u5408\u308f\u305b\u3066\u3001BeagleBone Black\u306b\u53d6\u308a\u4ed8\u3051\u305fLCD\u306b\u6642\u523b\u3068\u6e29\u5ea6\u3001\u7167\u5ea6\u3092\u8868\u793a\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[18,7],"tags":[],"_links":{"self":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/posts\/1292"}],"collection":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/comments?post=1292"}],"version-history":[{"count":21,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/posts\/1292\/revisions"}],"predecessor-version":[{"id":1304,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/posts\/1292\/revisions\/1304"}],"wp:attachment":[{"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/media?parent=1292"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/categories?post=1292"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/morecatlab.akiba.coocan.jp\/lab\/index.php\/wp-json\/wp\/v2\/tags?post=1292"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}