{"id":3476,"date":"2018-12-16T11:02:26","date_gmt":"2018-12-16T02:02:26","guid":{"rendered":"http:\/\/fisherman.jp\/23\/?p=3476"},"modified":"2018-12-16T11:16:34","modified_gmt":"2018-12-16T02:16:34","slug":"%e5%ae%9f%e9%a8%93-%e5%85%b1%e6%9c%89%ef%bc%88i2c-aqm0802%ef%bc%89-psoc4-raspberry-pi-zero-wh","status":"publish","type":"post","link":"http:\/\/fisherman.jp\/23\/3476","title":{"rendered":"\u5b9f\u9a13 \u5171\u6709\uff08I2C AQM0802\uff09 PSoC4 Raspberry Pi Zero WH"},"content":{"rendered":"<p>\u5b9f\u9a13 \u5171\u6709\uff08I2C AQM0802 LCD\uff09 PSoC4 Raspberry Pi Zero WH<br \/>\nI2C Slave AQM0802\uff08address 0x3E\uff09\u5171\u6709<br \/>\nI2C Master Raspberry Pi<br \/>\nI2C Multi-Master-Slave PSoC4\uff08address 0x08\uff09<br \/>\n$ i2cdetect -y 1 #AQM0802 \u3068 PSoC4 \u3092\u8a8d\u8b58\u3057\u3066\u3044\u308b<\/p>\n<p>Code Python Raspberry Pi<\/p>\n<pre>import smbus,time\r\n\r\ni2c1=smbus.SMBus(1) #0=(port I2C0), 1=(port I2C1)\r\ni2c1.write_i2c_block_data(0x3E,0x00,[0x38,0x39,0x14,0x78,0x5E,0x6A]); time.sleep(0.200) #200ms\r\ni2c1.write_i2c_block_data(0x3E,0x00,[0x0C,0x01]); time.sleep(0.002) #2ms\r\ni2c1.write_byte_data(0x3E,0x00,0x06)\r\ni2c1.write_byte_data(0x3E,0x00,0xC0) #0x80=1st line #0xC0=2nd\r\ni2c1.write_i2c_block_data(0x3E,0x40,[ord(' '),ord(' '),ord('P'),ord('i'),ord(' '),ord('I'),ord('2'),ord('C')])\r\n\r\nd=1\r\nwhile 1:\r\n    d=0x30+((1+d)%10) #9-0 countdown ascii\r\n    time.sleep(1.000) #1s\r\n    try:\r\n        i2c1.write_byte_data(0x3E,0x00,0xC0) #0xC0=2nd line\r\n        i2c1.write_byte_data(0x3E,0x40,d)\r\n    except Exception as e:\r\n        pass ;print(e) #error if exist\r\n<\/pre>\n<p>Code C PSoC4<\/p>\n<pre>...\r\n    const uint8 b0[]={0x00,  0x80}; \/\/1st 0x00 not valid \/\/0x80=1st line 0xC0=2nd line\r\n    const uint8 b1[]={0x00,  ' ',' ','P','S','o','C','4'}; \/\/1st 0x00 not valid\r\n    uint8   d[2];\r\n\twhile(1) {\r\n\t\tCyDelay(1000);        \r\n                I2C_write((uint8 *)b0, 0x3E, 0x00, 1);\r\n                I2C_write((uint8 *)b1, 0x3E, 0x40, 7);\r\n                d[1]=0x30+((1+d[1])%10); \/\/9-0 countdown ascii\r\n                I2C_write((uint8 *)b0, 0x3E, 0x00, 1);\r\n                I2C_write((uint8 *)d,  0x3E, 0x40, 1);\r\n...\r\n<\/pre>\n<p><a href=\"http:\/\/fisherman.jp\/23\/3476\/screenshot-from-2018-12-16-10-50-04\" rel=\"attachment wp-att-3477\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3477\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-16-10-50-04-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a> <a href=\"http:\/\/fisherman.jp\/23\/3476\/screenshot-from-2018-12-16-10-51-18\" rel=\"attachment wp-att-3478\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3478\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-16-10-51-18-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a> <a href=\"http:\/\/fisherman.jp\/23\/3476\/screenshot-from-2018-12-16-10-52-17\" rel=\"attachment wp-att-3479\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3479\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-16-10-52-17-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a> <a href=\"http:\/\/fisherman.jp\/23\/3476\/screenshot-from-2018-12-16-10-52-47\" rel=\"attachment wp-att-3480\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3480\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/Screenshot-from-2018-12-16-10-52-47-80x80.png\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><a href=\"http:\/\/fisherman.jp\/23\/3476\/p1030970\" rel=\"attachment wp-att-3489\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3489\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/P1030970-80x80.jpg\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><a href=\"http:\/\/fisherman.jp\/23\/3476\/p1030969\" rel=\"attachment wp-att-3488\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-thumbnail wp-image-3488\" src=\"http:\/\/fisherman.jp\/23\/wp-content\/uploads\/2018\/12\/P1030969-80x80.jpg\" alt=\"\" width=\"80\" height=\"80\" \/><\/a><br \/>\nI2C Master PSoC4 \u306e\u8a2d\u5b9a\u3067\u3082\u5171\u6709\u53ef\uff08\u901a\u4fe1\u306e\u30b3\u30f3\u30d5\u30ea\u30af\u30c8\u304c\u3042\u308b\u3060\u308d\u3046\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9f\u9a13 \u5171\u6709\uff08I2C AQM0802 LCD\uff09 PSoC4 Raspberry Pi Zero WH I2C Slave AQM0802\uff08address 0x3E\uff09\u5171\u6709 I2C Master Raspberry Pi I2 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36,32],"tags":[],"class_list":["post-3476","post","type-post","status-publish","format-standard","hentry","category-psoc","category-raspberry-pi"],"_links":{"self":[{"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/posts\/3476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/comments?post=3476"}],"version-history":[{"count":8,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/posts\/3476\/revisions"}],"predecessor-version":[{"id":3490,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/posts\/3476\/revisions\/3490"}],"wp:attachment":[{"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/media?parent=3476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/categories?post=3476"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/fisherman.jp\/23\/wp-json\/wp\/v2\/tags?post=3476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}