{"action":"created","comment":{"url":"https://api.github.com/repos/OpenXT/xctools/pulls/comments/45155538","id":45155538,"diff_hunk":"@@ -64,23 +67,223 @@ int get_current_battery_level(void) {\n         return NORMAL;\n }\n \n+\n+//Returns whether a battery is charging, discharging, full, etc.\n+int get_battery_charge_state(unsigned int battery_index) {\n+\n+    unsigned int percent, i;\n+\n+    if (last_status[battery_index].state & 0x1)\n+        return BATT_DISCHARGING;\n+    else if (last_status[battery_index].state & 0x2)\n+        return BATT_CHARGING;\n+    else {\n+        /* We're not charging nor discharging... */\n+        percent = get_battery_percentage(battery_index);\n+        /* Are we full or empty? */\n+        if (percent > 90)\n+            return BATT_FULL;\n+        else if (percent < 10)\n+             return BATT_EMPTY;\n+        else {\n+            /* Is anybody else (dis)charging? */\n+            for (i = 0; i < num_battery_structs_allocd; ++i) {\n+                if (i != battery_index &&\n+                    last_status[i].present == YES &&\n+                    (last_status[i].state & 0x1 || last_status[i].state & 0x2)) {\n+                    break;\n+                }\n+            }\n+            if (i < num_battery_structs_allocd) {\n+                /* Yes! */\n+                /* If the other battery is charging, we're pending charge */\n+                if (last_status[i].state & 0x2)\n+                    return BATT_PENDING_CHARGE;\n+                /* If the other battery is discharging, we're pending discharge */\n+                else if (last_status[i].state & 0x1)\n+                    return BATT_PENDING_DISCHARGE;\n+            } else\n+                /* We tried everything, the state is unknown... */\n+                return BATT_STATE_UNKNOWN;\n+        }\n+    }\n+\n+    return BATT_STATE_UNKNOWN;\n+}\n+\n+\n+//Returns whether the system as a whole is charging, discharging, full, or empty.\n+int get_system_charge_state(void) {\n+\n+    int percentage = get_overall_battery_percentage();\n+    long charge_rate = get_total_charge_rate();\n+\n+    if (get_ac_adapter_status() == ON_AC) {\n+        if (percentage > 98 || charge_rate == 0) {","path":"xcpmd/src/battery.c","position":73,"original_position":73,"commit_id":"da38656f79005f21268cf377b2c007fe6fef222a","original_commit_id":"da38656f79005f21268cf377b2c007fe6fef222a","user":{"login":"rneilturner","id":8103776,"avatar_url":"https://avatars.githubusercontent.com/u/8103776?v=3","gravatar_id":"","url":"https://api.github.com/users/rneilturner","html_url":"https://github.com/rneilturner","followers_url":"https://api.github.com/users/rneilturner/followers","following_url":"https://api.github.com/users/rneilturner/following{/other_user}","gists_url":"https://api.github.com/users/rneilturner/gists{/gist_id}","starred_url":"https://api.github.com/users/rneilturner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rneilturner/subscriptions","organizations_url":"https://api.github.com/users/rneilturner/orgs","repos_url":"https://api.github.com/users/rneilturner/repos","events_url":"https://api.github.com/users/rneilturner/events{/privacy}","received_events_url":"https://api.github.com/users/rneilturner/received_events","type":"User","site_admin":false},"body":"Above we make the case that percentage full is 90%, here we determine full to be 98%. Why the difference?","created_at":"2015-11-18T03:18:52Z","updated_at":"2015-11-18T03:18:52Z","html_url":"https://github.com/OpenXT/xctools/pull/17#discussion_r45155538","pull_request_url":"https://api.github.com/repos/OpenXT/xctools/pulls/17","_links":{"self":{"href":"https://api.github.com/repos/OpenXT/xctools/pulls/comments/45155538"},"html":{"href":"https://github.com/OpenXT/xctools/pull/17#discussion_r45155538"},"pull_request":{"href":"https://api.github.com/repos/OpenXT/xctools/pulls/17"}}},"pull_request":{"url":"https://api.github.com/repos/OpenXT/xctools/pulls/17","id":50987742,"html_url":"https://github.com/OpenXT/xctools/pull/17","diff_url":"https://github.com/OpenXT/xctools/pull/17.diff","patch_url":"https://github.com/OpenXT/xctools/pull/17.patch","issue_url":"https://api.github.com/repos/OpenXT/xctools/issues/17","number":17,"state":"open","locked":false,"title":"[xcpmd] Report aggregate stats for multi-battery systems, and other small improvements","user":{"login":"jctemkin","id":2059200,"avatar_url":"https://avatars.githubusercontent.com/u/2059200?v=3","gravatar_id":"","url":"https://api.github.com/users/jctemkin","html_url":"https://github.com/jctemkin","followers_url":"https://api.github.com/users/jctemkin/followers","following_url":"https://api.github.com/users/jctemkin/following{/other_user}","gists_url":"https://api.github.com/users/jctemkin/gists{/gist_id}","starred_url":"https://api.github.com/users/jctemkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jctemkin/subscriptions","organizations_url":"https://api.github.com/users/jctemkin/orgs","repos_url":"https://api.github.com/users/jctemkin/repos","events_url":"https://api.github.com/users/jctemkin/events{/privacy}","received_events_url":"https://api.github.com/users/jctemkin/received_events","type":"User","site_admin":false},"body":"Rolling a handful of small, orthogonal changes into one PR seemed like it'd make testing more convenient, but I can break it apart if desired.\r\n\r\nRelies on [IDL PR11](https://github.com/OpenXT/idl/pull/11).","created_at":"2015-11-17T18:52:51Z","updated_at":"2015-11-18T03:18:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"043a36d4a5a150ec5249bf79a68790842a47e2b0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/OpenXT/xctools/pulls/17/commits","review_comments_url":"https://api.github.com/repos/OpenXT/xctools/pulls/17/comments","review_comment_url":"https://api.github.com/repos/OpenXT/xctools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OpenXT/xctools/issues/17/comments","statuses_url":"https://api.github.com/repos/OpenXT/xctools/statuses/da38656f79005f21268cf377b2c007fe6fef222a","head":{"label":"jctemkin:master","ref":"master","sha":"da38656f79005f21268cf377b2c007fe6fef222a","user":{"login":"jctemkin","id":2059200,"avatar_url":"https://avatars.githubusercontent.com/u/2059200?v=3","gravatar_id":"","url":"https://api.github.com/users/jctemkin","html_url":"https://github.com/jctemkin","followers_url":"https://api.github.com/users/jctemkin/followers","following_url":"https://api.github.com/users/jctemkin/following{/other_user}","gists_url":"https://api.github.com/users/jctemkin/gists{/gist_id}","starred_url":"https://api.github.com/users/jctemkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jctemkin/subscriptions","organizations_url":"https://api.github.com/users/jctemkin/orgs","repos_url":"https://api.github.com/users/jctemkin/repos","events_url":"https://api.github.com/users/jctemkin/events{/privacy}","received_events_url":"https://api.github.com/users/jctemkin/received_events","type":"User","site_admin":false},"repo":{"id":40375490,"name":"xctools","full_name":"jctemkin/xctools","owner":{"login":"jctemkin","id":2059200,"avatar_url":"https://avatars.githubusercontent.com/u/2059200?v=3","gravatar_id":"","url":"https://api.github.com/users/jctemkin","html_url":"https://github.com/jctemkin","followers_url":"https://api.github.com/users/jctemkin/followers","following_url":"https://api.github.com/users/jctemkin/following{/other_user}","gists_url":"https://api.github.com/users/jctemkin/gists{/gist_id}","starred_url":"https://api.github.com/users/jctemkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jctemkin/subscriptions","organizations_url":"https://api.github.com/users/jctemkin/orgs","repos_url":"https://api.github.com/users/jctemkin/repos","events_url":"https://api.github.com/users/jctemkin/events{/privacy}","received_events_url":"https://api.github.com/users/jctemkin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jctemkin/xctools","description":"","fork":true,"url":"https://api.github.com/repos/jctemkin/xctools","forks_url":"https://api.github.com/repos/jctemkin/xctools/forks","keys_url":"https://api.github.com/repos/jctemkin/xctools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jctemkin/xctools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jctemkin/xctools/teams","hooks_url":"https://api.github.com/repos/jctemkin/xctools/hooks","issue_events_url":"https://api.github.com/repos/jctemkin/xctools/issues/events{/number}","events_url":"https://api.github.com/repos/jctemkin/xctools/events","assignees_url":"https://api.github.com/repos/jctemkin/xctools/assignees{/user}","branches_url":"https://api.github.com/repos/jctemkin/xctools/branches{/branch}","tags_url":"https://api.github.com/repos/jctemkin/xctools/tags","blobs_url":"https://api.github.com/repos/jctemkin/xctools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jctemkin/xctools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jctemkin/xctools/git/refs{/sha}","trees_url":"https://api.github.com/repos/jctemkin/xctools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jctemkin/xctools/statuses/{sha}","languages_url":"https://api.github.com/repos/jctemkin/xctools/languages","stargazers_url":"https://api.github.com/repos/jctemkin/xctools/stargazers","contributors_url":"https://api.github.com/repos/jctemkin/xctools/contributors","subscribers_url":"https://api.github.com/repos/jctemkin/xctools/subscribers","subscription_url":"https://api.github.com/repos/jctemkin/xctools/subscription","commits_url":"https://api.github.com/repos/jctemkin/xctools/commits{/sha}","git_commits_url":"https://api.github.com/repos/jctemkin/xctools/git/commits{/sha}","comments_url":"https://api.github.com/repos/jctemkin/xctools/comments{/number}","issue_comment_url":"https://api.github.com/repos/jctemkin/xctools/issues/comments{/number}","contents_url":"https://api.github.com/repos/jctemkin/xctools/contents/{+path}","compare_url":"https://api.github.com/repos/jctemkin/xctools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jctemkin/xctools/merges","archive_url":"https://api.github.com/repos/jctemkin/xctools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jctemkin/xctools/downloads","issues_url":"https://api.github.com/repos/jctemkin/xctools/issues{/number}","pulls_url":"https://api.github.com/repos/jctemkin/xctools/pulls{/number}","milestones_url":"https://api.github.com/repos/jctemkin/xctools/milestones{/number}","notifications_url":"https://api.github.com/repos/jctemkin/xctools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jctemkin/xctools/labels{/name}","releases_url":"https://api.github.com/repos/jctemkin/xctools/releases{/id}","created_at":"2015-08-07T18:41:04Z","updated_at":"2015-08-07T18:41:05Z","pushed_at":"2015-11-17T18:44:51Z","git_url":"git://github.com/jctemkin/xctools.git","ssh_url":"git@github.com:jctemkin/xctools.git","clone_url":"https://github.com/jctemkin/xctools.git","svn_url":"https://github.com/jctemkin/xctools","homepage":null,"size":2577,"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":"OpenXT:master","ref":"master","sha":"239c0e30e65c10b95afde53aa678491180e2483a","user":{"login":"OpenXT","id":7283187,"avatar_url":"https://avatars.githubusercontent.com/u/7283187?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenXT","html_url":"https://github.com/OpenXT","followers_url":"https://api.github.com/users/OpenXT/followers","following_url":"https://api.github.com/users/OpenXT/following{/other_user}","gists_url":"https://api.github.com/users/OpenXT/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenXT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenXT/subscriptions","organizations_url":"https://api.github.com/users/OpenXT/orgs","repos_url":"https://api.github.com/users/OpenXT/repos","events_url":"https://api.github.com/users/OpenXT/events{/privacy}","received_events_url":"https://api.github.com/users/OpenXT/received_events","type":"Organization","site_admin":false},"repo":{"id":20779275,"name":"xctools","full_name":"OpenXT/xctools","owner":{"login":"OpenXT","id":7283187,"avatar_url":"https://avatars.githubusercontent.com/u/7283187?v=3","gravatar_id":"","url":"https://api.github.com/users/OpenXT","html_url":"https://github.com/OpenXT","followers_url":"https://api.github.com/users/OpenXT/followers","following_url":"https://api.github.com/users/OpenXT/following{/other_user}","gists_url":"https://api.github.com/users/OpenXT/gists{/gist_id}","starred_url":"https://api.github.com/users/OpenXT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OpenXT/subscriptions","organizations_url":"https://api.github.com/users/OpenXT/orgs","repos_url":"https://api.github.com/users/OpenXT/repos","events_url":"https://api.github.com/users/OpenXT/events{/privacy}","received_events_url":"https://api.github.com/users/OpenXT/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OpenXT/xctools","description":"","fork":false,"url":"https://api.github.com/repos/OpenXT/xctools","forks_url":"https://api.github.com/repos/OpenXT/xctools/forks","keys_url":"https://api.github.com/repos/OpenXT/xctools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OpenXT/xctools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OpenXT/xctools/teams","hooks_url":"https://api.github.com/repos/OpenXT/xctools/hooks","issue_events_url":"https://api.github.com/repos/OpenXT/xctools/issues/events{/number}","events_url":"https://api.github.com/repos/OpenXT/xctools/events","assignees_url":"https://api.github.com/repos/OpenXT/xctools/assignees{/user}","branches_url":"https://api.github.com/repos/OpenXT/xctools/branches{/branch}","tags_url":"https://api.github.com/repos/OpenXT/xctools/tags","blobs_url":"https://api.github.com/repos/OpenXT/xctools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OpenXT/xctools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OpenXT/xctools/git/refs{/sha}","trees_url":"https://api.github.com/repos/OpenXT/xctools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OpenXT/xctools/statuses/{sha}","languages_url":"https://api.github.com/repos/OpenXT/xctools/languages","stargazers_url":"https://api.github.com/repos/OpenXT/xctools/stargazers","contributors_url":"https://api.github.com/repos/OpenXT/xctools/contributors","subscribers_url":"https://api.github.com/repos/OpenXT/xctools/subscribers","subscription_url":"https://api.github.com/repos/OpenXT/xctools/subscription","commits_url":"https://api.github.com/repos/OpenXT/xctools/commits{/sha}","git_commits_url":"https://api.github.com/repos/OpenXT/xctools/git/commits{/sha}","comments_url":"https://api.github.com/repos/OpenXT/xctools/comments{/number}","issue_comment_url":"https://api.github.com/repos/OpenXT/xctools/issues/comments{/number}","contents_url":"https://api.github.com/repos/OpenXT/xctools/contents/{+path}","compare_url":"https://api.github.com/repos/OpenXT/xctools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OpenXT/xctools/merges","archive_url":"https://api.github.com/repos/OpenXT/xctools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OpenXT/xctools/downloads","issues_url":"https://api.github.com/repos/OpenXT/xctools/issues{/number}","pulls_url":"https://api.github.com/repos/OpenXT/xctools/pulls{/number}","milestones_url":"https://api.github.com/repos/OpenXT/xctools/milestones{/number}","notifications_url":"https://api.github.com/repos/OpenXT/xctools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OpenXT/xctools/labels{/name}","releases_url":"https://api.github.com/repos/OpenXT/xctools/releases{/id}","created_at":"2014-06-12T18:57:34Z","updated_at":"2015-09-18T21:45:23Z","pushed_at":"2015-11-17T18:52:51Z","git_url":"git://github.com/OpenXT/xctools.git","ssh_url":"git@github.com:OpenXT/xctools.git","clone_url":"https://github.com/OpenXT/xctools.git","svn_url":"https://github.com/OpenXT/xctools","homepage":null,"size":2852,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":1,"forks":7,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OpenXT/xctools/pulls/17"},"html":{"href":"https://github.com/OpenXT/xctools/pull/17"},"issue":{"href":"https://api.github.com/repos/OpenXT/xctools/issues/17"},"comments":{"href":"https://api.github.com/repos/OpenXT/xctools/issues/17/comments"},"review_comments":{"href":"https://api.github.com/repos/OpenXT/xctools/pulls/17/comments"},"review_comment":{"href":"https://api.github.com/repos/OpenXT/xctools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OpenXT/xctools/pulls/17/commits"},"statuses":{"href":"https://api.github.com/repos/OpenXT/xctools/statuses/da38656f79005f21268cf377b2c007fe6fef222a"}}}}