{"action":"created","comment":{"url":"https://api.github.com/repos/01org/zephyr.js/pulls/comments/82739516","pull_request_review_id":3625003,"id":82739516,"diff_hunk":"@@ -0,0 +1,244 @@\n+// Copyright (c) 2016, Intel Corporation.\n+\n+// Sample code demonstrating how to use I2C to communicate with slave devices\n+\n+// Hardware Requirements:\n+//   - A BMP280 Temp/pressure sensor\n+//   - pull-up resistors for SDA and SCL, use two 10k resistors\n+\n+// Wiring:\n+//   For LCD:\n+//     - Wire SDA on the BMP280 to the pull-up resistor and connect that resistor to power (VCC)\n+//     - Wire SCL on the BMP280 to the pull-up resistor and connect that resistor to power (VCC)\n+//     - Wire SDA on the BMP280 to SDA on the Arduino 101\n+//     - Wire SCL on the BMP280 to SCL on the Arduino 101\n+//     - Wire power(5V) and ground accordingly\n+\n+var i2c = require(\"i2c\");\n+\n+var bmp280 = {\n+    BMP280_ADDRESS: 0x77,\n+    BMP280_NORMAL_MODE: 0x03,\n+    BMP280_REGISTER_DIG_T1: 0x88, // Unsigned Short\n+    BMP280_REGISTER_DIG_T2: 0x8A, // Signed Short\n+    BMP280_REGISTER_DIG_T3: 0x8C, // Signed Short\n+    BMP280_REGISTER_CHIPID: 0xD0,\n+    BMP280_REGISTER_CONTROL: 0xF4,\n+    BMP280_REGISTER_CONFIG: 0xF5,\n+    BMP280_REGISTER_TEMPDATA: 0xFA, //Signed 20bit. Always positive\n+    BMP280_STANDBY: 2 << 5,\n+    BMP280_FILTER: 0x00,\n+    BMP280_SPI_3W_DISABLE: 0x00,\n+    BMP280_PRESS_OVER: 1 << 2,\n+    BMP280_TEMP_OVER: 1 << 5\n+}\n+\n+var glcd = {\n+    GROVE_LCD_DISPLAY_ADDR : 0x3E,\n+    GROVE_RGB_BACKLIGHT_ADDR : 0x62,\n+// Defines for the GLCD_CMD_CURSOR_SHIFT\n+    GLCD_CS_DISPLAY_SHIFT : 1 << 3,\n+    GLCD_CS_RIGHT_SHIFT : 1 << 2,\n+// LCD Display Commands\n+    GLCD_CMD_SCREEN_CLEAR : 1 << 0,\n+    GLCD_CMD_CURSOR_RETURN : 1 << 1,\n+    GLCD_CMD_INPUT_SET : 1 << 2,\n+    GLCD_CMD_DISPLAY_SWITCH : 1 << 3,\n+    GLCD_CMD_CURSOR_SHIFT : 1 << 4,\n+    GLCD_CMD_FUNCTION_SET : 1 << 5,\n+    GLCD_CMD_SET_CGRAM_ADDR : 1 << 6,\n+    GLCD_CMD_SET_DDRAM_ADDR : 1 << 7,\n+// Defines for the LCD_FUNCTION_SET\n+    GLCD_FS_8BIT_MODE : 1 << 4,\n+    GLCD_FS_ROWS_2 : 1 << 3,\n+    GLCD_FS_ROWS_1 : 0 << 3,\n+    GLCD_FS_DOT_SIZE_BIG : 1 << 2,\n+    GLCD_FS_DOT_SIZE_LITTLE : 0 << 2,\n+// Defines for the GLCD_CMD_DISPLAY_SWITCH options\n+    GLCD_DS_DISPLAY_ON : 1 << 2,\n+    GLCD_DS_DISPLAY_OFF : 0 << 2,\n+    GLCD_DS_CURSOR_ON : 1 << 1,\n+    GLCD_DS_CURSOR_OFF : 0 << 1,\n+    GLCD_DS_BLINK_ON : 1 << 0,\n+    GLCD_DS_BLINK_OFF : 0 << 0,\n+    REGISTER_POWER : 0x08,\n+    REGISTER_R : 0x04,\n+    REGISTER_G : 0x03,\n+    REGISTER_B : 0x02\n+}\n+\n+/* Globals */\n+var i2cDevice = i2c.open({ bus: 0, speed: 100 });\n+var reader;\n+var dig_T1;\n+var dig_T2;\n+var dig_T3;\n+var setupData = new Buffer(2);","path":"samples/I2CBMP280.js","position":76,"original_position":76,"commit_id":"29f00338786f32cca4bccd1157c4e66c3811b094","original_commit_id":"29f00338786f32cca4bccd1157c4e66c3811b094","user":{"login":"kenchris","id":1101339,"avatar_url":"https://avatars.githubusercontent.com/u/1101339?v=3","gravatar_id":"","url":"https://api.github.com/users/kenchris","html_url":"https://github.com/kenchris","followers_url":"https://api.github.com/users/kenchris/followers","following_url":"https://api.github.com/users/kenchris/following{/other_user}","gists_url":"https://api.github.com/users/kenchris/gists{/gist_id}","starred_url":"https://api.github.com/users/kenchris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kenchris/subscriptions","organizations_url":"https://api.github.com/users/kenchris/orgs","repos_url":"https://api.github.com/users/kenchris/repos","events_url":"https://api.github.com/users/kenchris/events{/privacy}","received_events_url":"https://api.github.com/users/kenchris/received_events","type":"User","site_admin":false},"body":"if you only use this for the set up why not just do it there... ie avoid all these ugly globals","created_at":"2016-10-11T07:49:58Z","updated_at":"2016-10-11T07:49:58Z","html_url":"https://github.com/01org/zephyr.js/pull/272#discussion_r82739516","pull_request_url":"https://api.github.com/repos/01org/zephyr.js/pulls/272","_links":{"self":{"href":"https://api.github.com/repos/01org/zephyr.js/pulls/comments/82739516"},"html":{"href":"https://github.com/01org/zephyr.js/pull/272#discussion_r82739516"},"pull_request":{"href":"https://api.github.com/repos/01org/zephyr.js/pulls/272"}}},"pull_request":{"url":"https://api.github.com/repos/01org/zephyr.js/pulls/272","id":88694003,"html_url":"https://github.com/01org/zephyr.js/pull/272","diff_url":"https://github.com/01org/zephyr.js/pull/272.diff","patch_url":"https://github.com/01org/zephyr.js/pull/272.patch","issue_url":"https://api.github.com/repos/01org/zephyr.js/issues/272","number":272,"state":"open","locked":false,"title":"[Sample] Adding a sample program for BMP280","user":{"login":"brianjjones","id":725841,"avatar_url":"https://avatars.githubusercontent.com/u/725841?v=3","gravatar_id":"","url":"https://api.github.com/users/brianjjones","html_url":"https://github.com/brianjjones","followers_url":"https://api.github.com/users/brianjjones/followers","following_url":"https://api.github.com/users/brianjjones/following{/other_user}","gists_url":"https://api.github.com/users/brianjjones/gists{/gist_id}","starred_url":"https://api.github.com/users/brianjjones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianjjones/subscriptions","organizations_url":"https://api.github.com/users/brianjjones/orgs","repos_url":"https://api.github.com/users/brianjjones/repos","events_url":"https://api.github.com/users/brianjjones/events{/privacy}","received_events_url":"https://api.github.com/users/brianjjones/received_events","type":"User","site_admin":false},"body":"This is a sample javascript program that uses both the BMP280 and the Grove LCD.  Both sensors work off the same I2C bus.  The BMP280 reads the temperature while the Grove LCD prints it.  The Grove LCD also changes to red as it gets warmer and blue as it gets cooler.  There is also a (+) or (-) indicating if the temp has gone up or down since the last read.","created_at":"2016-10-10T16:36:55Z","updated_at":"2016-10-11T07:49:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7d75cf76574f3f752257725510f5bfdea3f6c6bf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/01org/zephyr.js/pulls/272/commits","review_comments_url":"https://api.github.com/repos/01org/zephyr.js/pulls/272/comments","review_comment_url":"https://api.github.com/repos/01org/zephyr.js/pulls/comments{/number}","comments_url":"https://api.github.com/repos/01org/zephyr.js/issues/272/comments","statuses_url":"https://api.github.com/repos/01org/zephyr.js/statuses/29f00338786f32cca4bccd1157c4e66c3811b094","head":{"label":"brianjjones:bmp280","ref":"bmp280","sha":"29f00338786f32cca4bccd1157c4e66c3811b094","user":{"login":"brianjjones","id":725841,"avatar_url":"https://avatars.githubusercontent.com/u/725841?v=3","gravatar_id":"","url":"https://api.github.com/users/brianjjones","html_url":"https://github.com/brianjjones","followers_url":"https://api.github.com/users/brianjjones/followers","following_url":"https://api.github.com/users/brianjjones/following{/other_user}","gists_url":"https://api.github.com/users/brianjjones/gists{/gist_id}","starred_url":"https://api.github.com/users/brianjjones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianjjones/subscriptions","organizations_url":"https://api.github.com/users/brianjjones/orgs","repos_url":"https://api.github.com/users/brianjjones/repos","events_url":"https://api.github.com/users/brianjjones/events{/privacy}","received_events_url":"https://api.github.com/users/brianjjones/received_events","type":"User","site_admin":false},"repo":{"id":70287810,"name":"zephyr.js-1","full_name":"brianjjones/zephyr.js-1","owner":{"login":"brianjjones","id":725841,"avatar_url":"https://avatars.githubusercontent.com/u/725841?v=3","gravatar_id":"","url":"https://api.github.com/users/brianjjones","html_url":"https://github.com/brianjjones","followers_url":"https://api.github.com/users/brianjjones/followers","following_url":"https://api.github.com/users/brianjjones/following{/other_user}","gists_url":"https://api.github.com/users/brianjjones/gists{/gist_id}","starred_url":"https://api.github.com/users/brianjjones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianjjones/subscriptions","organizations_url":"https://api.github.com/users/brianjjones/orgs","repos_url":"https://api.github.com/users/brianjjones/repos","events_url":"https://api.github.com/users/brianjjones/events{/privacy}","received_events_url":"https://api.github.com/users/brianjjones/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/brianjjones/zephyr.js-1","description":"JavaScript* Runtime for Zephyr* OS","fork":true,"url":"https://api.github.com/repos/brianjjones/zephyr.js-1","forks_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/forks","keys_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/teams","hooks_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/hooks","issue_events_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/issues/events{/number}","events_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/events","assignees_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/assignees{/user}","branches_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/branches{/branch}","tags_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/tags","blobs_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/statuses/{sha}","languages_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/languages","stargazers_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/stargazers","contributors_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/contributors","subscribers_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/subscribers","subscription_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/subscription","commits_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/contents/{+path}","compare_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/merges","archive_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/downloads","issues_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/issues{/number}","pulls_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/pulls{/number}","milestones_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/milestones{/number}","notifications_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/labels{/name}","releases_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/releases{/id}","deployments_url":"https://api.github.com/repos/brianjjones/zephyr.js-1/deployments","created_at":"2016-10-07T22:38:14Z","updated_at":"2016-10-07T22:38:15Z","pushed_at":"2016-10-11T00:26:40Z","git_url":"git://github.com/brianjjones/zephyr.js-1.git","ssh_url":"git@github.com:brianjjones/zephyr.js-1.git","clone_url":"https://github.com/brianjjones/zephyr.js-1.git","svn_url":"https://github.com/brianjjones/zephyr.js-1","homepage":"","size":667,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"01org:devel","ref":"devel","sha":"147bb63c305ea58d94ed1bf6689e7352eff1a03f","user":{"login":"01org","id":1635439,"avatar_url":"https://avatars.githubusercontent.com/u/1635439?v=3","gravatar_id":"","url":"https://api.github.com/users/01org","html_url":"https://github.com/01org","followers_url":"https://api.github.com/users/01org/followers","following_url":"https://api.github.com/users/01org/following{/other_user}","gists_url":"https://api.github.com/users/01org/gists{/gist_id}","starred_url":"https://api.github.com/users/01org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/01org/subscriptions","organizations_url":"https://api.github.com/users/01org/orgs","repos_url":"https://api.github.com/users/01org/repos","events_url":"https://api.github.com/users/01org/events{/privacy}","received_events_url":"https://api.github.com/users/01org/received_events","type":"Organization","site_admin":false},"repo":{"id":61588342,"name":"zephyr.js","full_name":"01org/zephyr.js","owner":{"login":"01org","id":1635439,"avatar_url":"https://avatars.githubusercontent.com/u/1635439?v=3","gravatar_id":"","url":"https://api.github.com/users/01org","html_url":"https://github.com/01org","followers_url":"https://api.github.com/users/01org/followers","following_url":"https://api.github.com/users/01org/following{/other_user}","gists_url":"https://api.github.com/users/01org/gists{/gist_id}","starred_url":"https://api.github.com/users/01org/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/01org/subscriptions","organizations_url":"https://api.github.com/users/01org/orgs","repos_url":"https://api.github.com/users/01org/repos","events_url":"https://api.github.com/users/01org/events{/privacy}","received_events_url":"https://api.github.com/users/01org/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/01org/zephyr.js","description":"JavaScript* Runtime for Zephyr* OS","fork":false,"url":"https://api.github.com/repos/01org/zephyr.js","forks_url":"https://api.github.com/repos/01org/zephyr.js/forks","keys_url":"https://api.github.com/repos/01org/zephyr.js/keys{/key_id}","collaborators_url":"https://api.github.com/repos/01org/zephyr.js/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/01org/zephyr.js/teams","hooks_url":"https://api.github.com/repos/01org/zephyr.js/hooks","issue_events_url":"https://api.github.com/repos/01org/zephyr.js/issues/events{/number}","events_url":"https://api.github.com/repos/01org/zephyr.js/events","assignees_url":"https://api.github.com/repos/01org/zephyr.js/assignees{/user}","branches_url":"https://api.github.com/repos/01org/zephyr.js/branches{/branch}","tags_url":"https://api.github.com/repos/01org/zephyr.js/tags","blobs_url":"https://api.github.com/repos/01org/zephyr.js/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/01org/zephyr.js/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/01org/zephyr.js/git/refs{/sha}","trees_url":"https://api.github.com/repos/01org/zephyr.js/git/trees{/sha}","statuses_url":"https://api.github.com/repos/01org/zephyr.js/statuses/{sha}","languages_url":"https://api.github.com/repos/01org/zephyr.js/languages","stargazers_url":"https://api.github.com/repos/01org/zephyr.js/stargazers","contributors_url":"https://api.github.com/repos/01org/zephyr.js/contributors","subscribers_url":"https://api.github.com/repos/01org/zephyr.js/subscribers","subscription_url":"https://api.github.com/repos/01org/zephyr.js/subscription","commits_url":"https://api.github.com/repos/01org/zephyr.js/commits{/sha}","git_commits_url":"https://api.github.com/repos/01org/zephyr.js/git/commits{/sha}","comments_url":"https://api.github.com/repos/01org/zephyr.js/comments{/number}","issue_comment_url":"https://api.github.com/repos/01org/zephyr.js/issues/comments{/number}","contents_url":"https://api.github.com/repos/01org/zephyr.js/contents/{+path}","compare_url":"https://api.github.com/repos/01org/zephyr.js/compare/{base}...{head}","merges_url":"https://api.github.com/repos/01org/zephyr.js/merges","archive_url":"https://api.github.com/repos/01org/zephyr.js/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/01org/zephyr.js/downloads","issues_url":"https://api.github.com/repos/01org/zephyr.js/issues{/number}","pulls_url":"https://api.github.com/repos/01org/zephyr.js/pulls{/number}","milestones_url":"https://api.github.com/repos/01org/zephyr.js/milestones{/number}","notifications_url":"https://api.github.com/repos/01org/zephyr.js/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/01org/zephyr.js/labels{/name}","releases_url":"https://api.github.com/repos/01org/zephyr.js/releases{/id}","deployments_url":"https://api.github.com/repos/01org/zephyr.js/deployments","created_at":"2016-06-20T23:53:57Z","updated_at":"2016-10-11T04:18:50Z","pushed_at":"2016-10-11T01:44:05Z","git_url":"git://github.com/01org/zephyr.js.git","ssh_url":"git@github.com:01org/zephyr.js.git","clone_url":"https://github.com/01org/zephyr.js.git","svn_url":"https://github.com/01org/zephyr.js","homepage":"","size":777,"stargazers_count":15,"watchers_count":15,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":10,"mirror_url":null,"open_issues_count":44,"forks":10,"open_issues":44,"watchers":15,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/01org/zephyr.js/pulls/272"},"html":{"href":"https://github.com/01org/zephyr.js/pull/272"},"issue":{"href":"https://api.github.com/repos/01org/zephyr.js/issues/272"},"comments":{"href":"https://api.github.com/repos/01org/zephyr.js/issues/272/comments"},"review_comments":{"href":"https://api.github.com/repos/01org/zephyr.js/pulls/272/comments"},"review_comment":{"href":"https://api.github.com/repos/01org/zephyr.js/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/01org/zephyr.js/pulls/272/commits"},"statuses":{"href":"https://api.github.com/repos/01org/zephyr.js/statuses/29f00338786f32cca4bccd1157c4e66c3811b094"}}}}
{"actor":{"display_login":"kenchris"}}