{"action":"created","comment":{"url":"https://api.github.com/repos/vingtetun/gameboard/pulls/comments/89549209","pull_request_review_id":10095182,"id":89549209,"diff_hunk":"@@ -7,44 +8,40 @@ const Hardware = (function Hardware() {\n   const Constants = {\n     HeaderSize: 2,\n     FooterSize: 1,\n-    PixelSize: 3,\n-    Width: 64,\n-    Height: 32,\n+    PixelSize: 3, // 3 colors\n+    Width: 96,\n+    Height: 16,\n+    BoardCount: 3, // this needs to be a proper divider of the led count\n   };\n \n-  const leds = document.getElementsByClassName('led');\n-\n-  const kLedsCount = (Constants.Width / 2) * Constants.Height;\n-  if (leds.length != kLedsCount) {\n-    let msg = 'The total number of leds should be ' + kLedsCount + '.\\n' +\n-              'Current count is ' + leds.lenght + '.';\n-    throw new Error(msg);\n-  } \n+  let leds;\n \n   function updateLed(id, r, g, b) {\n-    if (r == 0 && g == 0 && b == 0) {\n+    if (r === 0 && g === 0 && b === 0) { // TODO use blend-mode ?\n       leds[id].style.backgroundColor = 'transparent';\n     } else {\n       leds[id].style.backgroundColor = 'rgb(' + r + ', ' + g + ', ' + b + ')';\n     }\n   }\n \n   function update(buffer) {\n-    let begin = Constants.HeaderSize;\n-    let end = buffer.length - Constants.FooterSize;\n-    let step = Constants.Width * Constants.PixelSize;\n-\n-    for (let i = begin; i < end; i += step) {\n-      // The first half does not have any physical representation as the real board is 32x32\n-      // but the protocol used is 64x32.\n-      let offset =  i + (step / 2);\n-      let iteration = (i - begin) / step;\n-\n-      for (let j = offset; j < (i + step); j += Constants.PixelSize) {\n-        let id = ((j - begin) / Constants.PixelSize) - ((iteration + 1) * Constants.Width / 2);\n-        updateLed(id, buffer[j], buffer[j+1], buffer[j+2]);\n+    if (!leds) {\n+      leds = document.getElementsByClassName('led');\n+\n+      const kLedsCount = Constants.Width * Constants.Height;\n+      if (leds.length !== kLedsCount) {\n+        let msg = 'The total number of leds should be ' + kLedsCount + '.\\n' +\n+                  'Current count is ' + leds.length + '.';\n+        throw new Error(msg);\n       }\n     }\n+\n+    const begin = Constants.HeaderSize;\n+    const end = buffer.length - Constants.FooterSize;\n+\n+    for (let i = begin, id = 0; i < end; i += Constants.PixelSize, id++) {\n+      updateLed(id, buffer[i], buffer[i + 1], buffer[i + 2]);","path":"hardware/scripts/hardware.js","position":66,"original_position":66,"commit_id":"2b7e06c541619d721e5f6bda27db0795c67e7370","original_commit_id":"2b7e06c541619d721e5f6bda27db0795c67e7370","user":{"login":"julienw","id":454175,"avatar_url":"https://avatars.githubusercontent.com/u/454175?v=3","gravatar_id":"","url":"https://api.github.com/users/julienw","html_url":"https://github.com/julienw","followers_url":"https://api.github.com/users/julienw/followers","following_url":"https://api.github.com/users/julienw/following{/other_user}","gists_url":"https://api.github.com/users/julienw/gists{/gist_id}","starred_url":"https://api.github.com/users/julienw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienw/subscriptions","organizations_url":"https://api.github.com/users/julienw/orgs","repos_url":"https://api.github.com/users/julienw/repos","events_url":"https://api.github.com/users/julienw/events{/privacy}","received_events_url":"https://api.github.com/users/julienw/received_events","type":"User","site_admin":false},"body":"this is a lot simpler than before as now the physical aspects of the board are handled by CSS.","created_at":"2016-11-24T22:13:00Z","updated_at":"2016-11-24T22:13:00Z","html_url":"https://github.com/vingtetun/gameboard/pull/13#discussion_r89549209","pull_request_url":"https://api.github.com/repos/vingtetun/gameboard/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/vingtetun/gameboard/pulls/comments/89549209"},"html":{"href":"https://github.com/vingtetun/gameboard/pull/13#discussion_r89549209"},"pull_request":{"href":"https://api.github.com/repos/vingtetun/gameboard/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/vingtetun/gameboard/pulls/13","id":95230105,"html_url":"https://github.com/vingtetun/gameboard/pull/13","diff_url":"https://github.com/vingtetun/gameboard/pull/13.diff","patch_url":"https://github.com/vingtetun/gameboard/pull/13.patch","issue_url":"https://api.github.com/repos/vingtetun/gameboard/issues/13","number":13,"state":"open","locked":false,"title":"Increase the size board to mimic the real board","user":{"login":"julienw","id":454175,"avatar_url":"https://avatars.githubusercontent.com/u/454175?v=3","gravatar_id":"","url":"https://api.github.com/users/julienw","html_url":"https://github.com/julienw","followers_url":"https://api.github.com/users/julienw/followers","following_url":"https://api.github.com/users/julienw/following{/other_user}","gists_url":"https://api.github.com/users/julienw/gists{/gist_id}","starred_url":"https://api.github.com/users/julienw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienw/subscriptions","organizations_url":"https://api.github.com/users/julienw/orgs","repos_url":"https://api.github.com/users/julienw/repos","events_url":"https://api.github.com/users/julienw/events{/privacy}","received_events_url":"https://api.github.com/users/julienw/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-11-24T21:49:42Z","updated_at":"2016-11-24T22:13:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5cbe62839b598dee94c575a74fdda60486b6a4da","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vingtetun/gameboard/pulls/13/commits","review_comments_url":"https://api.github.com/repos/vingtetun/gameboard/pulls/13/comments","review_comment_url":"https://api.github.com/repos/vingtetun/gameboard/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vingtetun/gameboard/issues/13/comments","statuses_url":"https://api.github.com/repos/vingtetun/gameboard/statuses/2b7e06c541619d721e5f6bda27db0795c67e7370","head":{"label":"julienw:increase-board-size","ref":"increase-board-size","sha":"2b7e06c541619d721e5f6bda27db0795c67e7370","user":{"login":"julienw","id":454175,"avatar_url":"https://avatars.githubusercontent.com/u/454175?v=3","gravatar_id":"","url":"https://api.github.com/users/julienw","html_url":"https://github.com/julienw","followers_url":"https://api.github.com/users/julienw/followers","following_url":"https://api.github.com/users/julienw/following{/other_user}","gists_url":"https://api.github.com/users/julienw/gists{/gist_id}","starred_url":"https://api.github.com/users/julienw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienw/subscriptions","organizations_url":"https://api.github.com/users/julienw/orgs","repos_url":"https://api.github.com/users/julienw/repos","events_url":"https://api.github.com/users/julienw/events{/privacy}","received_events_url":"https://api.github.com/users/julienw/received_events","type":"User","site_admin":false},"repo":{"id":74706947,"name":"gameboard","full_name":"julienw/gameboard","owner":{"login":"julienw","id":454175,"avatar_url":"https://avatars.githubusercontent.com/u/454175?v=3","gravatar_id":"","url":"https://api.github.com/users/julienw","html_url":"https://github.com/julienw","followers_url":"https://api.github.com/users/julienw/followers","following_url":"https://api.github.com/users/julienw/following{/other_user}","gists_url":"https://api.github.com/users/julienw/gists{/gist_id}","starred_url":"https://api.github.com/users/julienw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienw/subscriptions","organizations_url":"https://api.github.com/users/julienw/orgs","repos_url":"https://api.github.com/users/julienw/repos","events_url":"https://api.github.com/users/julienw/events{/privacy}","received_events_url":"https://api.github.com/users/julienw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/julienw/gameboard","description":null,"fork":true,"url":"https://api.github.com/repos/julienw/gameboard","forks_url":"https://api.github.com/repos/julienw/gameboard/forks","keys_url":"https://api.github.com/repos/julienw/gameboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/julienw/gameboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/julienw/gameboard/teams","hooks_url":"https://api.github.com/repos/julienw/gameboard/hooks","issue_events_url":"https://api.github.com/repos/julienw/gameboard/issues/events{/number}","events_url":"https://api.github.com/repos/julienw/gameboard/events","assignees_url":"https://api.github.com/repos/julienw/gameboard/assignees{/user}","branches_url":"https://api.github.com/repos/julienw/gameboard/branches{/branch}","tags_url":"https://api.github.com/repos/julienw/gameboard/tags","blobs_url":"https://api.github.com/repos/julienw/gameboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/julienw/gameboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/julienw/gameboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/julienw/gameboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/julienw/gameboard/statuses/{sha}","languages_url":"https://api.github.com/repos/julienw/gameboard/languages","stargazers_url":"https://api.github.com/repos/julienw/gameboard/stargazers","contributors_url":"https://api.github.com/repos/julienw/gameboard/contributors","subscribers_url":"https://api.github.com/repos/julienw/gameboard/subscribers","subscription_url":"https://api.github.com/repos/julienw/gameboard/subscription","commits_url":"https://api.github.com/repos/julienw/gameboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/julienw/gameboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/julienw/gameboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/julienw/gameboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/julienw/gameboard/contents/{+path}","compare_url":"https://api.github.com/repos/julienw/gameboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/julienw/gameboard/merges","archive_url":"https://api.github.com/repos/julienw/gameboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/julienw/gameboard/downloads","issues_url":"https://api.github.com/repos/julienw/gameboard/issues{/number}","pulls_url":"https://api.github.com/repos/julienw/gameboard/pulls{/number}","milestones_url":"https://api.github.com/repos/julienw/gameboard/milestones{/number}","notifications_url":"https://api.github.com/repos/julienw/gameboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/julienw/gameboard/labels{/name}","releases_url":"https://api.github.com/repos/julienw/gameboard/releases{/id}","deployments_url":"https://api.github.com/repos/julienw/gameboard/deployments","created_at":"2016-11-24T21:45:17Z","updated_at":"2016-11-24T21:45:18Z","pushed_at":"2016-11-24T21:45:44Z","git_url":"git://github.com/julienw/gameboard.git","ssh_url":"git@github.com:julienw/gameboard.git","clone_url":"https://github.com/julienw/gameboard.git","svn_url":"https://github.com/julienw/gameboard","homepage":null,"size":1921,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","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":"vingtetun:master","ref":"master","sha":"48489a3743b029dd86087d723fb01f50db3c0fc9","user":{"login":"vingtetun","id":579794,"avatar_url":"https://avatars.githubusercontent.com/u/579794?v=3","gravatar_id":"","url":"https://api.github.com/users/vingtetun","html_url":"https://github.com/vingtetun","followers_url":"https://api.github.com/users/vingtetun/followers","following_url":"https://api.github.com/users/vingtetun/following{/other_user}","gists_url":"https://api.github.com/users/vingtetun/gists{/gist_id}","starred_url":"https://api.github.com/users/vingtetun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vingtetun/subscriptions","organizations_url":"https://api.github.com/users/vingtetun/orgs","repos_url":"https://api.github.com/users/vingtetun/repos","events_url":"https://api.github.com/users/vingtetun/events{/privacy}","received_events_url":"https://api.github.com/users/vingtetun/received_events","type":"User","site_admin":false},"repo":{"id":70493501,"name":"gameboard","full_name":"vingtetun/gameboard","owner":{"login":"vingtetun","id":579794,"avatar_url":"https://avatars.githubusercontent.com/u/579794?v=3","gravatar_id":"","url":"https://api.github.com/users/vingtetun","html_url":"https://github.com/vingtetun","followers_url":"https://api.github.com/users/vingtetun/followers","following_url":"https://api.github.com/users/vingtetun/following{/other_user}","gists_url":"https://api.github.com/users/vingtetun/gists{/gist_id}","starred_url":"https://api.github.com/users/vingtetun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vingtetun/subscriptions","organizations_url":"https://api.github.com/users/vingtetun/orgs","repos_url":"https://api.github.com/users/vingtetun/repos","events_url":"https://api.github.com/users/vingtetun/events{/privacy}","received_events_url":"https://api.github.com/users/vingtetun/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vingtetun/gameboard","description":null,"fork":false,"url":"https://api.github.com/repos/vingtetun/gameboard","forks_url":"https://api.github.com/repos/vingtetun/gameboard/forks","keys_url":"https://api.github.com/repos/vingtetun/gameboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vingtetun/gameboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vingtetun/gameboard/teams","hooks_url":"https://api.github.com/repos/vingtetun/gameboard/hooks","issue_events_url":"https://api.github.com/repos/vingtetun/gameboard/issues/events{/number}","events_url":"https://api.github.com/repos/vingtetun/gameboard/events","assignees_url":"https://api.github.com/repos/vingtetun/gameboard/assignees{/user}","branches_url":"https://api.github.com/repos/vingtetun/gameboard/branches{/branch}","tags_url":"https://api.github.com/repos/vingtetun/gameboard/tags","blobs_url":"https://api.github.com/repos/vingtetun/gameboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vingtetun/gameboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vingtetun/gameboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/vingtetun/gameboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vingtetun/gameboard/statuses/{sha}","languages_url":"https://api.github.com/repos/vingtetun/gameboard/languages","stargazers_url":"https://api.github.com/repos/vingtetun/gameboard/stargazers","contributors_url":"https://api.github.com/repos/vingtetun/gameboard/contributors","subscribers_url":"https://api.github.com/repos/vingtetun/gameboard/subscribers","subscription_url":"https://api.github.com/repos/vingtetun/gameboard/subscription","commits_url":"https://api.github.com/repos/vingtetun/gameboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/vingtetun/gameboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/vingtetun/gameboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/vingtetun/gameboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/vingtetun/gameboard/contents/{+path}","compare_url":"https://api.github.com/repos/vingtetun/gameboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vingtetun/gameboard/merges","archive_url":"https://api.github.com/repos/vingtetun/gameboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vingtetun/gameboard/downloads","issues_url":"https://api.github.com/repos/vingtetun/gameboard/issues{/number}","pulls_url":"https://api.github.com/repos/vingtetun/gameboard/pulls{/number}","milestones_url":"https://api.github.com/repos/vingtetun/gameboard/milestones{/number}","notifications_url":"https://api.github.com/repos/vingtetun/gameboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vingtetun/gameboard/labels{/name}","releases_url":"https://api.github.com/repos/vingtetun/gameboard/releases{/id}","deployments_url":"https://api.github.com/repos/vingtetun/gameboard/deployments","created_at":"2016-10-10T13:56:45Z","updated_at":"2016-10-10T13:58:35Z","pushed_at":"2016-11-24T21:49:42Z","git_url":"git://github.com/vingtetun/gameboard.git","ssh_url":"git@github.com:vingtetun/gameboard.git","clone_url":"https://github.com/vingtetun/gameboard.git","svn_url":"https://github.com/vingtetun/gameboard","homepage":null,"size":1921,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":10,"forks":4,"open_issues":10,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vingtetun/gameboard/pulls/13"},"html":{"href":"https://github.com/vingtetun/gameboard/pull/13"},"issue":{"href":"https://api.github.com/repos/vingtetun/gameboard/issues/13"},"comments":{"href":"https://api.github.com/repos/vingtetun/gameboard/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/vingtetun/gameboard/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/vingtetun/gameboard/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vingtetun/gameboard/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/vingtetun/gameboard/statuses/2b7e06c541619d721e5f6bda27db0795c67e7370"}}}}
{"actor":{"display_login":"julienw"}}