{"action":"created","comment":{"url":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/comments/207766752","pull_request_review_id":143443104,"id":207766752,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNzc2Njc1Mg==","diff_hunk":"@@ -0,0 +1,113 @@\n+/*\n+  NCP5623 I2C LED driver\n+*/\n+/*\n+   This program is free software: you can redistribute it and/or modify\n+   it under the terms of the GNU General Public License as published by\n+   the Free Software Foundation, either version 3 of the License, or\n+   (at your option) any later version.\n+\n+   This program is distributed in the hope that it will be useful,\n+   but WITHOUT ANY WARRANTY; without even the implied warranty of\n+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+   GNU General Public License for more details.\n+\n+   You should have received a copy of the GNU General Public License\n+   along with this program.  If not, see <http://www.gnu.org/licenses/>.\n+ */\n+\n+#include \"NCP5623.h\"\n+#include <utility>\n+\n+#include <AP_HAL/AP_HAL.h>\n+\n+extern const AP_HAL::HAL& hal;\n+\n+#define NCP5623_LED_BRIGHT  0x1f    // full brightness\n+#define NCP5623_LED_MEDIUM  0x18    // medium brightness\n+#define NCP5623_LED_DIM     0x0f    // dim\n+#define NCP5623_LED_OFF     0x00    // off\n+\n+#define NCP5623_LED_I2C_ADDR 0x38    // default I2C bus address\n+\n+#define NCP5623_LED_PWM0    0x40    // pwm0 register\n+#define NCP5623_LED_PWM1    0x60    // pwm1 register\n+#define NCP5623_LED_PWM2    0x80    // pwm2 register\n+#define NCP5623_LED_ENABLE  0x20    // enable register\n+\n+NCP5623::NCP5623(uint8_t bus)\n+    : RGBLed(NCP5623_LED_OFF, NCP5623_LED_BRIGHT, NCP5623_LED_MEDIUM, NCP5623_LED_DIM)\n+    , _bus(bus)\n+{\n+}\n+\n+bool NCP5623::write(uint8_t reg, uint8_t data)\n+{\n+\tuint8_t msg[1] = { 0x00 };\n+    msg[0] = ((reg & 0xe0) | (data & 0x1f));\n+    bool ret = _dev->transfer(msg, 1, nullptr, 0);\n+\treturn ret;\n+}\n+\n+bool NCP5623::writes(uint8_t *data, uint8_t len)\n+{\n+    bool ret = 0;\n+    uint8_t reg = data[0];\n+    for (uint8_t i = 0; i < (len - 1); i++) {\n+        ret = write(reg, data[i + 1]);\n+        if (!ret) return ret;\n+        reg = reg + 0x20;\n+    }\n+\treturn ret;\n+}\n+\n+bool NCP5623::hw_init(void)\n+{\n+    // first look for led on external bus\n+    _dev = std::move(hal.i2c_mgr->get_device(_bus, NCP5623_LED_I2C_ADDR));\n+    if (!_dev || !_dev->get_semaphore()->take(HAL_SEMAPHORE_BLOCK_FOREVER)) {\n+        return false;\n+    }\n+    _dev->set_retries(10);\n+\n+    // enable the led\n+    bool ret = write(NCP5623_LED_ENABLE, 0x1f);\n+    if (!ret) {\n+        _dev->get_semaphore()->give();\n+        return false;\n+    }\n+    // update the red, green and blue values to zero\n+    uint8_t val[4] = { NCP5623_LED_PWM0, _led_off, _led_off, _led_off };","path":"libraries/AP_Notify/NCP5623.cpp","position":80,"original_position":80,"commit_id":"a2c4e2dfa6bf0909426e3ab9b579c72c4b07a5a6","original_commit_id":"a2c4e2dfa6bf0909426e3ab9b579c72c4b07a5a6","user":{"login":"peterbarker","id":7077857,"node_id":"MDQ6VXNlcjcwNzc4NTc=","avatar_url":"https://avatars0.githubusercontent.com/u/7077857?v=4","gravatar_id":"","url":"https://api.github.com/users/peterbarker","html_url":"https://github.com/peterbarker","followers_url":"https://api.github.com/users/peterbarker/followers","following_url":"https://api.github.com/users/peterbarker/following{/other_user}","gists_url":"https://api.github.com/users/peterbarker/gists{/gist_id}","starred_url":"https://api.github.com/users/peterbarker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterbarker/subscriptions","organizations_url":"https://api.github.com/users/peterbarker/orgs","repos_url":"https://api.github.com/users/peterbarker/repos","events_url":"https://api.github.com/users/peterbarker/events{/privacy}","received_events_url":"https://api.github.com/users/peterbarker/received_events","type":"User","site_admin":false},"body":"`const`","created_at":"2018-08-06T03:25:02Z","updated_at":"2018-08-06T03:33:23Z","html_url":"https://github.com/ArduPilot/ardupilot/pull/9007#discussion_r207766752","pull_request_url":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/9007","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/comments/207766752"},"html":{"href":"https://github.com/ArduPilot/ardupilot/pull/9007#discussion_r207766752"},"pull_request":{"href":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/9007"}}},"pull_request":{"url":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/9007","id":203831471,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAzODMxNDcx","html_url":"https://github.com/ArduPilot/ardupilot/pull/9007","diff_url":"https://github.com/ArduPilot/ardupilot/pull/9007.diff","patch_url":"https://github.com/ArduPilot/ardupilot/pull/9007.patch","issue_url":"https://api.github.com/repos/ArduPilot/ardupilot/issues/9007","number":9007,"state":"open","locked":false,"title":"Add RGB LED driver for NCP5623","user":{"login":"CUAVcaijie","id":30532769,"node_id":"MDQ6VXNlcjMwNTMyNzY5","avatar_url":"https://avatars2.githubusercontent.com/u/30532769?v=4","gravatar_id":"","url":"https://api.github.com/users/CUAVcaijie","html_url":"https://github.com/CUAVcaijie","followers_url":"https://api.github.com/users/CUAVcaijie/followers","following_url":"https://api.github.com/users/CUAVcaijie/following{/other_user}","gists_url":"https://api.github.com/users/CUAVcaijie/gists{/gist_id}","starred_url":"https://api.github.com/users/CUAVcaijie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CUAVcaijie/subscriptions","organizations_url":"https://api.github.com/users/CUAVcaijie/orgs","repos_url":"https://api.github.com/users/CUAVcaijie/repos","events_url":"https://api.github.com/users/CUAVcaijie/events{/privacy}","received_events_url":"https://api.github.com/users/CUAVcaijie/received_events","type":"User","site_admin":false},"body":"","created_at":"2018-07-25T13:08:48Z","updated_at":"2018-08-06T03:33:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1b88f8523dedcfa74e59badad2f7a95c6256a0c4","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/9007/commits","review_comments_url":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/9007/comments","review_comment_url":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ArduPilot/ardupilot/issues/9007/comments","statuses_url":"https://api.github.com/repos/ArduPilot/ardupilot/statuses/a2c4e2dfa6bf0909426e3ab9b579c72c4b07a5a6","head":{"label":"cuav:ncp5623","ref":"ncp5623","sha":"a2c4e2dfa6bf0909426e3ab9b579c72c4b07a5a6","user":{"login":"cuav","id":1296251,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTYyNTE=","avatar_url":"https://avatars0.githubusercontent.com/u/1296251?v=4","gravatar_id":"","url":"https://api.github.com/users/cuav","html_url":"https://github.com/cuav","followers_url":"https://api.github.com/users/cuav/followers","following_url":"https://api.github.com/users/cuav/following{/other_user}","gists_url":"https://api.github.com/users/cuav/gists{/gist_id}","starred_url":"https://api.github.com/users/cuav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cuav/subscriptions","organizations_url":"https://api.github.com/users/cuav/orgs","repos_url":"https://api.github.com/users/cuav/repos","events_url":"https://api.github.com/users/cuav/events{/privacy}","received_events_url":"https://api.github.com/users/cuav/received_events","type":"Organization","site_admin":false},"repo":{"id":99225561,"node_id":"MDEwOlJlcG9zaXRvcnk5OTIyNTU2MQ==","name":"ardupilot","full_name":"cuav/ardupilot","owner":{"login":"cuav","id":1296251,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEyOTYyNTE=","avatar_url":"https://avatars0.githubusercontent.com/u/1296251?v=4","gravatar_id":"","url":"https://api.github.com/users/cuav","html_url":"https://github.com/cuav","followers_url":"https://api.github.com/users/cuav/followers","following_url":"https://api.github.com/users/cuav/following{/other_user}","gists_url":"https://api.github.com/users/cuav/gists{/gist_id}","starred_url":"https://api.github.com/users/cuav/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cuav/subscriptions","organizations_url":"https://api.github.com/users/cuav/orgs","repos_url":"https://api.github.com/users/cuav/repos","events_url":"https://api.github.com/users/cuav/events{/privacy}","received_events_url":"https://api.github.com/users/cuav/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cuav/ardupilot","description":"ArduPlane, ArduCopter, ArduRover source","fork":true,"url":"https://api.github.com/repos/cuav/ardupilot","forks_url":"https://api.github.com/repos/cuav/ardupilot/forks","keys_url":"https://api.github.com/repos/cuav/ardupilot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cuav/ardupilot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cuav/ardupilot/teams","hooks_url":"https://api.github.com/repos/cuav/ardupilot/hooks","issue_events_url":"https://api.github.com/repos/cuav/ardupilot/issues/events{/number}","events_url":"https://api.github.com/repos/cuav/ardupilot/events","assignees_url":"https://api.github.com/repos/cuav/ardupilot/assignees{/user}","branches_url":"https://api.github.com/repos/cuav/ardupilot/branches{/branch}","tags_url":"https://api.github.com/repos/cuav/ardupilot/tags","blobs_url":"https://api.github.com/repos/cuav/ardupilot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cuav/ardupilot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cuav/ardupilot/git/refs{/sha}","trees_url":"https://api.github.com/repos/cuav/ardupilot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cuav/ardupilot/statuses/{sha}","languages_url":"https://api.github.com/repos/cuav/ardupilot/languages","stargazers_url":"https://api.github.com/repos/cuav/ardupilot/stargazers","contributors_url":"https://api.github.com/repos/cuav/ardupilot/contributors","subscribers_url":"https://api.github.com/repos/cuav/ardupilot/subscribers","subscription_url":"https://api.github.com/repos/cuav/ardupilot/subscription","commits_url":"https://api.github.com/repos/cuav/ardupilot/commits{/sha}","git_commits_url":"https://api.github.com/repos/cuav/ardupilot/git/commits{/sha}","comments_url":"https://api.github.com/repos/cuav/ardupilot/comments{/number}","issue_comment_url":"https://api.github.com/repos/cuav/ardupilot/issues/comments{/number}","contents_url":"https://api.github.com/repos/cuav/ardupilot/contents/{+path}","compare_url":"https://api.github.com/repos/cuav/ardupilot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cuav/ardupilot/merges","archive_url":"https://api.github.com/repos/cuav/ardupilot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cuav/ardupilot/downloads","issues_url":"https://api.github.com/repos/cuav/ardupilot/issues{/number}","pulls_url":"https://api.github.com/repos/cuav/ardupilot/pulls{/number}","milestones_url":"https://api.github.com/repos/cuav/ardupilot/milestones{/number}","notifications_url":"https://api.github.com/repos/cuav/ardupilot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cuav/ardupilot/labels{/name}","releases_url":"https://api.github.com/repos/cuav/ardupilot/releases{/id}","deployments_url":"https://api.github.com/repos/cuav/ardupilot/deployments","created_at":"2017-08-03T11:28:48Z","updated_at":"2018-08-02T08:13:19Z","pushed_at":"2018-07-25T22:19:59Z","git_url":"git://github.com/cuav/ardupilot.git","ssh_url":"git@github.com:cuav/ardupilot.git","clone_url":"https://github.com/cuav/ardupilot.git","svn_url":"https://github.com/cuav/ardupilot","homepage":"http://ardupilot.org/","size":108985,"stargazers_count":2,"watchers_count":2,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":1,"open_issues":0,"watchers":2,"default_branch":"master"}},"base":{"label":"ArduPilot:master","ref":"master","sha":"62cf45659b045b79e1ea2efabb278bca5f82e25d","user":{"login":"ArduPilot","id":17919847,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3OTE5ODQ3","avatar_url":"https://avatars3.githubusercontent.com/u/17919847?v=4","gravatar_id":"","url":"https://api.github.com/users/ArduPilot","html_url":"https://github.com/ArduPilot","followers_url":"https://api.github.com/users/ArduPilot/followers","following_url":"https://api.github.com/users/ArduPilot/following{/other_user}","gists_url":"https://api.github.com/users/ArduPilot/gists{/gist_id}","starred_url":"https://api.github.com/users/ArduPilot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArduPilot/subscriptions","organizations_url":"https://api.github.com/users/ArduPilot/orgs","repos_url":"https://api.github.com/users/ArduPilot/repos","events_url":"https://api.github.com/users/ArduPilot/events{/privacy}","received_events_url":"https://api.github.com/users/ArduPilot/received_events","type":"Organization","site_admin":false},"repo":{"id":7512484,"node_id":"MDEwOlJlcG9zaXRvcnk3NTEyNDg0","name":"ardupilot","full_name":"ArduPilot/ardupilot","owner":{"login":"ArduPilot","id":17919847,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE3OTE5ODQ3","avatar_url":"https://avatars3.githubusercontent.com/u/17919847?v=4","gravatar_id":"","url":"https://api.github.com/users/ArduPilot","html_url":"https://github.com/ArduPilot","followers_url":"https://api.github.com/users/ArduPilot/followers","following_url":"https://api.github.com/users/ArduPilot/following{/other_user}","gists_url":"https://api.github.com/users/ArduPilot/gists{/gist_id}","starred_url":"https://api.github.com/users/ArduPilot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ArduPilot/subscriptions","organizations_url":"https://api.github.com/users/ArduPilot/orgs","repos_url":"https://api.github.com/users/ArduPilot/repos","events_url":"https://api.github.com/users/ArduPilot/events{/privacy}","received_events_url":"https://api.github.com/users/ArduPilot/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ArduPilot/ardupilot","description":"ArduPlane, ArduCopter, ArduRover source","fork":false,"url":"https://api.github.com/repos/ArduPilot/ardupilot","forks_url":"https://api.github.com/repos/ArduPilot/ardupilot/forks","keys_url":"https://api.github.com/repos/ArduPilot/ardupilot/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ArduPilot/ardupilot/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ArduPilot/ardupilot/teams","hooks_url":"https://api.github.com/repos/ArduPilot/ardupilot/hooks","issue_events_url":"https://api.github.com/repos/ArduPilot/ardupilot/issues/events{/number}","events_url":"https://api.github.com/repos/ArduPilot/ardupilot/events","assignees_url":"https://api.github.com/repos/ArduPilot/ardupilot/assignees{/user}","branches_url":"https://api.github.com/repos/ArduPilot/ardupilot/branches{/branch}","tags_url":"https://api.github.com/repos/ArduPilot/ardupilot/tags","blobs_url":"https://api.github.com/repos/ArduPilot/ardupilot/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ArduPilot/ardupilot/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ArduPilot/ardupilot/git/refs{/sha}","trees_url":"https://api.github.com/repos/ArduPilot/ardupilot/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ArduPilot/ardupilot/statuses/{sha}","languages_url":"https://api.github.com/repos/ArduPilot/ardupilot/languages","stargazers_url":"https://api.github.com/repos/ArduPilot/ardupilot/stargazers","contributors_url":"https://api.github.com/repos/ArduPilot/ardupilot/contributors","subscribers_url":"https://api.github.com/repos/ArduPilot/ardupilot/subscribers","subscription_url":"https://api.github.com/repos/ArduPilot/ardupilot/subscription","commits_url":"https://api.github.com/repos/ArduPilot/ardupilot/commits{/sha}","git_commits_url":"https://api.github.com/repos/ArduPilot/ardupilot/git/commits{/sha}","comments_url":"https://api.github.com/repos/ArduPilot/ardupilot/comments{/number}","issue_comment_url":"https://api.github.com/repos/ArduPilot/ardupilot/issues/comments{/number}","contents_url":"https://api.github.com/repos/ArduPilot/ardupilot/contents/{+path}","compare_url":"https://api.github.com/repos/ArduPilot/ardupilot/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ArduPilot/ardupilot/merges","archive_url":"https://api.github.com/repos/ArduPilot/ardupilot/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ArduPilot/ardupilot/downloads","issues_url":"https://api.github.com/repos/ArduPilot/ardupilot/issues{/number}","pulls_url":"https://api.github.com/repos/ArduPilot/ardupilot/pulls{/number}","milestones_url":"https://api.github.com/repos/ArduPilot/ardupilot/milestones{/number}","notifications_url":"https://api.github.com/repos/ArduPilot/ardupilot/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ArduPilot/ardupilot/labels{/name}","releases_url":"https://api.github.com/repos/ArduPilot/ardupilot/releases{/id}","deployments_url":"https://api.github.com/repos/ArduPilot/ardupilot/deployments","created_at":"2013-01-09T00:58:52Z","updated_at":"2018-08-06T02:31:17Z","pushed_at":"2018-08-06T03:01:47Z","git_url":"git://github.com/ArduPilot/ardupilot.git","ssh_url":"git@github.com:ArduPilot/ardupilot.git","clone_url":"https://github.com/ArduPilot/ardupilot.git","svn_url":"https://github.com/ArduPilot/ardupilot","homepage":"http://ardupilot.org/","size":112236,"stargazers_count":3382,"watchers_count":3382,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":6732,"mirror_url":null,"archived":false,"open_issues_count":1230,"license":{"key":"gpl-3.0","name":"GNU General Public License v3.0","spdx_id":"GPL-3.0","url":"https://api.github.com/licenses/gpl-3.0","node_id":"MDc6TGljZW5zZTk="},"forks":6732,"open_issues":1230,"watchers":3382,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/9007"},"html":{"href":"https://github.com/ArduPilot/ardupilot/pull/9007"},"issue":{"href":"https://api.github.com/repos/ArduPilot/ardupilot/issues/9007"},"comments":{"href":"https://api.github.com/repos/ArduPilot/ardupilot/issues/9007/comments"},"review_comments":{"href":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/9007/comments"},"review_comment":{"href":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ArduPilot/ardupilot/pulls/9007/commits"},"statuses":{"href":"https://api.github.com/repos/ArduPilot/ardupilot/statuses/a2c4e2dfa6bf0909426e3ab9b579c72c4b07a5a6"}},"author_association":"NONE"}}
{"actor":{"display_login":"peterbarker"}}