{"action":"created","comment":{"url":"https://api.github.com/repos/google/periph/pulls/comments/229280405","pull_request_review_id":169738804,"id":229280405,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyOTI4MDQwNQ==","diff_hunk":"@@ -0,0 +1,150 @@\n+// Copyright 2018 The Periph Authors. All rights reserved.\n+// Use of this source code is governed under the Apache License, Version 2.0\n+// that can be found in the LICENSE file.\n+\n+package pca9685\n+\n+import (\n+\t\"time\"\n+\n+\t\"periph.io/x/periph/conn/gpio\"\n+\t\"periph.io/x/periph/conn/i2c\"\n+\t\"periph.io/x/periph/conn/physic\"\n+)\n+\n+// I2CAddr i2c default address.\n+const I2CAddr uint16 = 0x40\n+\n+// PCA9685 Commands\n+const (\n+\tmode1      byte = 0x00\n+\tmode2      byte = 0x01\n+\tsubAdr1    byte = 0x02\n+\tsubAdr2    byte = 0x03\n+\tsubAdr3    byte = 0x04\n+\tprescale   byte = 0xFE\n+\tled0OnL    byte = 0x06\n+\tled0OnH    byte = 0x07\n+\tled0OffL   byte = 0x08\n+\tled0OffH   byte = 0x09\n+\tallLedOnL  byte = 0xFA\n+\tallLedOnH  byte = 0xFB\n+\tallLedOffL byte = 0xFC\n+\tallLedOffH byte = 0xFD\n+\n+\t// Bits\n+\trestart byte = 0x80\n+\tsleep   byte = 0x10\n+\tallCall byte = 0x01\n+\tinvrt   byte = 0x10\n+\toutDrv  byte = 0x04\n+)\n+\n+// Dev is a handler to pca9685 controller\n+type Dev struct {\n+\tdev *i2c.Dev\n+}\n+\n+// NewI2C returns a Dev object that communicates over I2C.\n+//\n+// To use on the default address, pca9685.I2CAddr must be passed as argument.\n+func NewI2C(bus i2c.Bus, address uint16) (*Dev, error) {\n+\tdev := &Dev{\n+\t\tdev: &i2c.Dev{Bus: bus, Addr: address},\n+\t}\n+\terr := dev.init()\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\treturn dev, nil\n+}\n+\n+func (d *Dev) init() error {\n+\tif err := d.SetAllPwm(0, 0); err != nil {\n+\t\treturn err\n+\t}\n+\n+\tif _, err := d.dev.Write([]byte{mode2, outDrv}); err != nil {\n+\t\treturn err\n+\t}\n+\tif _, err := d.dev.Write([]byte{mode1, allCall}); err != nil {\n+\t\treturn err\n+\t}\n+\n+\ttime.Sleep(100 * time.Millisecond)\n+\n+\tmodeRead := [1]byte{}\n+\tif err := d.dev.Tx([]byte{mode1}, modeRead[:]); err != nil {\n+\t\treturn err\n+\t}\n+\n+\tmode := modeRead[0] & ^sleep\n+\tif _, err := d.dev.Write([]byte{mode1, mode}); err != nil {\n+\t\treturn err\n+\t}\n+\n+\ttime.Sleep(5 * time.Millisecond)\n+\n+\treturn d.SetPwmFreq(50 * physic.Hertz)\n+}\n+\n+// SetPwmFreq set the pwm frequency","path":"experimental/devices/pca9685/pca9685.go","position":92,"original_position":92,"commit_id":"7bf2896b575109d9593656dd780caa3ce3e0e570","original_commit_id":"7bf2896b575109d9593656dd780caa3ce3e0e570","user":{"login":"maruel","id":75011,"node_id":"MDQ6VXNlcjc1MDEx","avatar_url":"https://avatars2.githubusercontent.com/u/75011?v=4","gravatar_id":"","url":"https://api.github.com/users/maruel","html_url":"https://github.com/maruel","followers_url":"https://api.github.com/users/maruel/followers","following_url":"https://api.github.com/users/maruel/following{/other_user}","gists_url":"https://api.github.com/users/maruel/gists{/gist_id}","starred_url":"https://api.github.com/users/maruel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maruel/subscriptions","organizations_url":"https://api.github.com/users/maruel/orgs","repos_url":"https://api.github.com/users/maruel/repos","events_url":"https://api.github.com/users/maruel/events{/privacy}","received_events_url":"https://api.github.com/users/maruel/received_events","type":"User","site_admin":false},"body":"In a follow up, please terminate all documentation with a period.","created_at":"2018-10-30T12:10:49Z","updated_at":"2018-10-30T12:22:01Z","html_url":"https://github.com/google/periph/pull/296#discussion_r229280405","pull_request_url":"https://api.github.com/repos/google/periph/pulls/296","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/google/periph/pulls/comments/229280405"},"html":{"href":"https://github.com/google/periph/pull/296#discussion_r229280405"},"pull_request":{"href":"https://api.github.com/repos/google/periph/pulls/296"}}},"pull_request":{"url":"https://api.github.com/repos/google/periph/pulls/296","id":226335998,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI2MzM1OTk4","html_url":"https://github.com/google/periph/pull/296","diff_url":"https://github.com/google/periph/pull/296.diff","patch_url":"https://github.com/google/periph/pull/296.patch","issue_url":"https://api.github.com/repos/google/periph/issues/296","number":296,"state":"open","locked":false,"title":"[feat] Add support for pca9685 pwm module","user":{"login":"alvarowolfx","id":1615543,"node_id":"MDQ6VXNlcjE2MTU1NDM=","avatar_url":"https://avatars2.githubusercontent.com/u/1615543?v=4","gravatar_id":"","url":"https://api.github.com/users/alvarowolfx","html_url":"https://github.com/alvarowolfx","followers_url":"https://api.github.com/users/alvarowolfx/followers","following_url":"https://api.github.com/users/alvarowolfx/following{/other_user}","gists_url":"https://api.github.com/users/alvarowolfx/gists{/gist_id}","starred_url":"https://api.github.com/users/alvarowolfx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alvarowolfx/subscriptions","organizations_url":"https://api.github.com/users/alvarowolfx/orgs","repos_url":"https://api.github.com/users/alvarowolfx/repos","events_url":"https://api.github.com/users/alvarowolfx/events{/privacy}","received_events_url":"https://api.github.com/users/alvarowolfx/received_events","type":"User","site_admin":false},"body":"Add support for the PCA9685 16 channel PWM module. I create this for a demo on Gophercon Brazil talking about embedded development with Golang and one of the demos was a robot arm (MeArm) controlled through Google Assistant, Cloud IoT Core and Golang running on an Orange Pi Zero. So I extracted the code for controlling the pca9685 module and I'm sending this PR.\r\n\r\nCode for the project: https://github.com/alvarowolfx/golang-voice-iot\r\nDemo of it working: https://youtu.be/Xep6dZ3xOYA\r\n\r\nBased on https://github.com/wintersandroid/Android-Things-PCA9685\r\nDatasheets: https://cdn-shop.adafruit.com/datasheets/PCA9685.pdf\r\nProduct page: https://www.adafruit.com/product/815\r\n\r\n![img_4752](https://user-images.githubusercontent.com/1615543/47610830-fa722180-da2c-11e8-8e4e-86aa649d0b34.JPG)","created_at":"2018-10-28T01:22:36Z","updated_at":"2018-10-30T12:22:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b50cd8d9d7285f669147ea883cc6cdd981d97515","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/google/periph/pulls/296/commits","review_comments_url":"https://api.github.com/repos/google/periph/pulls/296/comments","review_comment_url":"https://api.github.com/repos/google/periph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/periph/issues/296/comments","statuses_url":"https://api.github.com/repos/google/periph/statuses/7bf2896b575109d9593656dd780caa3ce3e0e570","head":{"label":"alvarowolfx:pca9685","ref":"pca9685","sha":"7bf2896b575109d9593656dd780caa3ce3e0e570","user":{"login":"alvarowolfx","id":1615543,"node_id":"MDQ6VXNlcjE2MTU1NDM=","avatar_url":"https://avatars2.githubusercontent.com/u/1615543?v=4","gravatar_id":"","url":"https://api.github.com/users/alvarowolfx","html_url":"https://github.com/alvarowolfx","followers_url":"https://api.github.com/users/alvarowolfx/followers","following_url":"https://api.github.com/users/alvarowolfx/following{/other_user}","gists_url":"https://api.github.com/users/alvarowolfx/gists{/gist_id}","starred_url":"https://api.github.com/users/alvarowolfx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alvarowolfx/subscriptions","organizations_url":"https://api.github.com/users/alvarowolfx/orgs","repos_url":"https://api.github.com/users/alvarowolfx/repos","events_url":"https://api.github.com/users/alvarowolfx/events{/privacy}","received_events_url":"https://api.github.com/users/alvarowolfx/received_events","type":"User","site_admin":false},"repo":{"id":154899564,"node_id":"MDEwOlJlcG9zaXRvcnkxNTQ4OTk1NjQ=","name":"periph","full_name":"alvarowolfx/periph","private":false,"owner":{"login":"alvarowolfx","id":1615543,"node_id":"MDQ6VXNlcjE2MTU1NDM=","avatar_url":"https://avatars2.githubusercontent.com/u/1615543?v=4","gravatar_id":"","url":"https://api.github.com/users/alvarowolfx","html_url":"https://github.com/alvarowolfx","followers_url":"https://api.github.com/users/alvarowolfx/followers","following_url":"https://api.github.com/users/alvarowolfx/following{/other_user}","gists_url":"https://api.github.com/users/alvarowolfx/gists{/gist_id}","starred_url":"https://api.github.com/users/alvarowolfx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alvarowolfx/subscriptions","organizations_url":"https://api.github.com/users/alvarowolfx/orgs","repos_url":"https://api.github.com/users/alvarowolfx/repos","events_url":"https://api.github.com/users/alvarowolfx/events{/privacy}","received_events_url":"https://api.github.com/users/alvarowolfx/received_events","type":"User","site_admin":false},"html_url":"https://github.com/alvarowolfx/periph","description":"Go·Hardware·Lean","fork":true,"url":"https://api.github.com/repos/alvarowolfx/periph","forks_url":"https://api.github.com/repos/alvarowolfx/periph/forks","keys_url":"https://api.github.com/repos/alvarowolfx/periph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alvarowolfx/periph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alvarowolfx/periph/teams","hooks_url":"https://api.github.com/repos/alvarowolfx/periph/hooks","issue_events_url":"https://api.github.com/repos/alvarowolfx/periph/issues/events{/number}","events_url":"https://api.github.com/repos/alvarowolfx/periph/events","assignees_url":"https://api.github.com/repos/alvarowolfx/periph/assignees{/user}","branches_url":"https://api.github.com/repos/alvarowolfx/periph/branches{/branch}","tags_url":"https://api.github.com/repos/alvarowolfx/periph/tags","blobs_url":"https://api.github.com/repos/alvarowolfx/periph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alvarowolfx/periph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alvarowolfx/periph/git/refs{/sha}","trees_url":"https://api.github.com/repos/alvarowolfx/periph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alvarowolfx/periph/statuses/{sha}","languages_url":"https://api.github.com/repos/alvarowolfx/periph/languages","stargazers_url":"https://api.github.com/repos/alvarowolfx/periph/stargazers","contributors_url":"https://api.github.com/repos/alvarowolfx/periph/contributors","subscribers_url":"https://api.github.com/repos/alvarowolfx/periph/subscribers","subscription_url":"https://api.github.com/repos/alvarowolfx/periph/subscription","commits_url":"https://api.github.com/repos/alvarowolfx/periph/commits{/sha}","git_commits_url":"https://api.github.com/repos/alvarowolfx/periph/git/commits{/sha}","comments_url":"https://api.github.com/repos/alvarowolfx/periph/comments{/number}","issue_comment_url":"https://api.github.com/repos/alvarowolfx/periph/issues/comments{/number}","contents_url":"https://api.github.com/repos/alvarowolfx/periph/contents/{+path}","compare_url":"https://api.github.com/repos/alvarowolfx/periph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alvarowolfx/periph/merges","archive_url":"https://api.github.com/repos/alvarowolfx/periph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alvarowolfx/periph/downloads","issues_url":"https://api.github.com/repos/alvarowolfx/periph/issues{/number}","pulls_url":"https://api.github.com/repos/alvarowolfx/periph/pulls{/number}","milestones_url":"https://api.github.com/repos/alvarowolfx/periph/milestones{/number}","notifications_url":"https://api.github.com/repos/alvarowolfx/periph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alvarowolfx/periph/labels{/name}","releases_url":"https://api.github.com/repos/alvarowolfx/periph/releases{/id}","deployments_url":"https://api.github.com/repos/alvarowolfx/periph/deployments","created_at":"2018-10-26T22:08:21Z","updated_at":"2018-10-26T22:08:23Z","pushed_at":"2018-10-30T04:14:51Z","git_url":"git://github.com/alvarowolfx/periph.git","ssh_url":"git@github.com:alvarowolfx/periph.git","clone_url":"https://github.com/alvarowolfx/periph.git","svn_url":"https://github.com/alvarowolfx/periph","homepage":"https://periph.io","size":1975,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"b35390319a8167df52664cec1737e31b729055ad","user":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":70828109,"node_id":"MDEwOlJlcG9zaXRvcnk3MDgyODEwOQ==","name":"periph","full_name":"google/periph","private":false,"owner":{"login":"google","id":1342004,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEzNDIwMDQ=","avatar_url":"https://avatars1.githubusercontent.com/u/1342004?v=4","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/google/periph","description":"Go·Hardware·Lean","fork":false,"url":"https://api.github.com/repos/google/periph","forks_url":"https://api.github.com/repos/google/periph/forks","keys_url":"https://api.github.com/repos/google/periph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/periph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/periph/teams","hooks_url":"https://api.github.com/repos/google/periph/hooks","issue_events_url":"https://api.github.com/repos/google/periph/issues/events{/number}","events_url":"https://api.github.com/repos/google/periph/events","assignees_url":"https://api.github.com/repos/google/periph/assignees{/user}","branches_url":"https://api.github.com/repos/google/periph/branches{/branch}","tags_url":"https://api.github.com/repos/google/periph/tags","blobs_url":"https://api.github.com/repos/google/periph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/periph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/periph/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/periph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/periph/statuses/{sha}","languages_url":"https://api.github.com/repos/google/periph/languages","stargazers_url":"https://api.github.com/repos/google/periph/stargazers","contributors_url":"https://api.github.com/repos/google/periph/contributors","subscribers_url":"https://api.github.com/repos/google/periph/subscribers","subscription_url":"https://api.github.com/repos/google/periph/subscription","commits_url":"https://api.github.com/repos/google/periph/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/periph/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/periph/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/periph/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/periph/contents/{+path}","compare_url":"https://api.github.com/repos/google/periph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/periph/merges","archive_url":"https://api.github.com/repos/google/periph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/periph/downloads","issues_url":"https://api.github.com/repos/google/periph/issues{/number}","pulls_url":"https://api.github.com/repos/google/periph/pulls{/number}","milestones_url":"https://api.github.com/repos/google/periph/milestones{/number}","notifications_url":"https://api.github.com/repos/google/periph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/periph/labels{/name}","releases_url":"https://api.github.com/repos/google/periph/releases{/id}","deployments_url":"https://api.github.com/repos/google/periph/deployments","created_at":"2016-10-13T16:53:51Z","updated_at":"2018-10-29T19:24:10Z","pushed_at":"2018-10-30T04:14:52Z","git_url":"git://github.com/google/periph.git","ssh_url":"git@github.com:google/periph.git","clone_url":"https://github.com/google/periph.git","svn_url":"https://github.com/google/periph","homepage":"https://periph.io","size":1952,"stargazers_count":1108,"watchers_count":1108,"language":"Go","has_issues":true,"has_projects":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":91,"mirror_url":null,"archived":false,"open_issues_count":38,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":91,"open_issues":38,"watchers":1108,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/periph/pulls/296"},"html":{"href":"https://github.com/google/periph/pull/296"},"issue":{"href":"https://api.github.com/repos/google/periph/issues/296"},"comments":{"href":"https://api.github.com/repos/google/periph/issues/296/comments"},"review_comments":{"href":"https://api.github.com/repos/google/periph/pulls/296/comments"},"review_comment":{"href":"https://api.github.com/repos/google/periph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/periph/pulls/296/commits"},"statuses":{"href":"https://api.github.com/repos/google/periph/statuses/7bf2896b575109d9593656dd780caa3ce3e0e570"}},"author_association":"NONE"}}
{"actor":{"display_login":"maruel"}}