{"action":"created","issue":{"url":"https://api.github.com/repos/spark/firmware/issues/1154","repository_url":"https://api.github.com/repos/spark/firmware","labels_url":"https://api.github.com/repos/spark/firmware/issues/1154/labels{/name}","comments_url":"https://api.github.com/repos/spark/firmware/issues/1154/comments","events_url":"https://api.github.com/repos/spark/firmware/issues/1154/events","html_url":"https://github.com/spark/firmware/pull/1154","id":186139662,"number":1154,"title":"Generate system event when low battery condition is detected","user":{"login":"sergeuz","id":770094,"avatar_url":"https://avatars.githubusercontent.com/u/770094?v=3","gravatar_id":"","url":"https://api.github.com/users/sergeuz","html_url":"https://github.com/sergeuz","followers_url":"https://api.github.com/users/sergeuz/followers","following_url":"https://api.github.com/users/sergeuz/following{/other_user}","gists_url":"https://api.github.com/users/sergeuz/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeuz/subscriptions","organizations_url":"https://api.github.com/users/sergeuz/orgs","repos_url":"https://api.github.com/users/sergeuz/repos","events_url":"https://api.github.com/users/sergeuz/events{/privacy}","received_events_url":"https://api.github.com/users/sergeuz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"sergeuz","id":770094,"avatar_url":"https://avatars.githubusercontent.com/u/770094?v=3","gravatar_id":"","url":"https://api.github.com/users/sergeuz","html_url":"https://github.com/sergeuz","followers_url":"https://api.github.com/users/sergeuz/followers","following_url":"https://api.github.com/users/sergeuz/following{/other_user}","gists_url":"https://api.github.com/users/sergeuz/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeuz/subscriptions","organizations_url":"https://api.github.com/users/sergeuz/orgs","repos_url":"https://api.github.com/users/sergeuz/repos","events_url":"https://api.github.com/users/sergeuz/events{/privacy}","received_events_url":"https://api.github.com/users/sergeuz/received_events","type":"User","site_admin":false},"assignees":[{"login":"sergeuz","id":770094,"avatar_url":"https://avatars.githubusercontent.com/u/770094?v=3","gravatar_id":"","url":"https://api.github.com/users/sergeuz","html_url":"https://github.com/sergeuz","followers_url":"https://api.github.com/users/sergeuz/followers","following_url":"https://api.github.com/users/sergeuz/following{/other_user}","gists_url":"https://api.github.com/users/sergeuz/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeuz/subscriptions","organizations_url":"https://api.github.com/users/sergeuz/orgs","repos_url":"https://api.github.com/users/sergeuz/repos","events_url":"https://api.github.com/users/sergeuz/events{/privacy}","received_events_url":"https://api.github.com/users/sergeuz/received_events","type":"User","site_admin":false},{"login":"technobly","id":2249224,"avatar_url":"https://avatars.githubusercontent.com/u/2249224?v=3","gravatar_id":"","url":"https://api.github.com/users/technobly","html_url":"https://github.com/technobly","followers_url":"https://api.github.com/users/technobly/followers","following_url":"https://api.github.com/users/technobly/following{/other_user}","gists_url":"https://api.github.com/users/technobly/gists{/gist_id}","starred_url":"https://api.github.com/users/technobly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/technobly/subscriptions","organizations_url":"https://api.github.com/users/technobly/orgs","repos_url":"https://api.github.com/users/technobly/repos","events_url":"https://api.github.com/users/technobly/events{/privacy}","received_events_url":"https://api.github.com/users/technobly/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/spark/firmware/milestones/28","html_url":"https://github.com/spark/firmware/milestone/28","labels_url":"https://api.github.com/repos/spark/firmware/milestones/28/labels","id":2164610,"number":28,"title":"0.6.1","description":null,"creator":{"login":"technobly","id":2249224,"avatar_url":"https://avatars.githubusercontent.com/u/2249224?v=3","gravatar_id":"","url":"https://api.github.com/users/technobly","html_url":"https://github.com/technobly","followers_url":"https://api.github.com/users/technobly/followers","following_url":"https://api.github.com/users/technobly/following{/other_user}","gists_url":"https://api.github.com/users/technobly/gists{/gist_id}","starred_url":"https://api.github.com/users/technobly/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/technobly/subscriptions","organizations_url":"https://api.github.com/users/technobly/orgs","repos_url":"https://api.github.com/users/technobly/repos","events_url":"https://api.github.com/users/technobly/events{/privacy}","received_events_url":"https://api.github.com/users/technobly/received_events","type":"User","site_admin":false},"open_issues":7,"closed_issues":47,"state":"open","created_at":"2016-11-29T19:39:17Z","updated_at":"2016-12-09T19:35:44Z","due_on":null,"closed_at":null},"comments":10,"created_at":"2016-10-30T14:29:39Z","updated_at":"2016-12-09T21:13:48Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/spark/firmware/pulls/1154","html_url":"https://github.com/spark/firmware/pull/1154","diff_url":"https://github.com/spark/firmware/pull/1154.diff","patch_url":"https://github.com/spark/firmware/pull/1154.patch"},"body":"This PR adds `low_battery` system event, which is generated when low battery condition is detected. The event doesn't carry any data.\r\n\r\nI don't have any battery, nor adjustable power supply unit to test this PR properly, so any help with the testing would be appreciated. Test application can be as simple as the following:\r\n\r\n``` cpp\r\n#include \"application.h\"\r\n\r\nSYSTEM_MODE(MANUAL); // Electron will be offline!!!\r\n\r\nSerialLogHandler logHandler(LOG_LEVEL_WARN, {\r\n    { \"app\", LOG_LEVEL_ALL }\r\n});\r\n\r\nvoid lowBatteryHandler() {\r\n    Log.warn(\"Low battery!\");\r\n}\r\n\r\nvoid setup() {\r\n\tFuelGauge().setAlertThreshold(32); // MAX 32% (default 10%)\r\n\tSystem.on(low_battery, lowBatteryHandler);\r\n}\r\n\r\nvoid loop() {\r\n\tFuelGauge().quickStart();\r\n\tString stats = String(FuelGauge().getAlertThreshold()) + \"(\\%) \"\r\n\t\t+ String(FuelGauge().getSoC()) + \"(\\%) \"\r\n\t\t+ String(FuelGauge().getVCell()) + \"(V)\";\r\n\tLog.info(\"Battery stats: %s\", stats.c_str());\r\n\tdelay(1000);\r\n}\r\n```\r\n\r\nAccording to [current code](https://github.com/spark/firmware/blob/develop/system/src/main.cpp#L280), default threshold for low battery alarm is set to 10%.\r\n\r\n---\r\n\r\nDoneness:\r\n- [X] Contributor has signed CLA\r\n- [X] Problem and Solution clearly stated\r\n- [ ] Code peer reviewed\r\n- [ ] API tests compiled\r\n- [ ] Run unit/integration/application tests on device\r\n- [ ] Add documentation\r\n- [ ] Add to CHANGELOG.md after merging (add links to docs and issues)\r\n"},"comment":{"url":"https://api.github.com/repos/spark/firmware/issues/comments/266124931","html_url":"https://github.com/spark/firmware/pull/1154#issuecomment-266124931","issue_url":"https://api.github.com/repos/spark/firmware/issues/1154","id":266124931,"user":{"login":"sergeuz","id":770094,"avatar_url":"https://avatars.githubusercontent.com/u/770094?v=3","gravatar_id":"","url":"https://api.github.com/users/sergeuz","html_url":"https://github.com/sergeuz","followers_url":"https://api.github.com/users/sergeuz/followers","following_url":"https://api.github.com/users/sergeuz/following{/other_user}","gists_url":"https://api.github.com/users/sergeuz/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeuz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeuz/subscriptions","organizations_url":"https://api.github.com/users/sergeuz/orgs","repos_url":"https://api.github.com/users/sergeuz/repos","events_url":"https://api.github.com/users/sergeuz/events{/privacy}","received_events_url":"https://api.github.com/users/sergeuz/received_events","type":"User","site_admin":false},"created_at":"2016-12-09T21:13:48Z","updated_at":"2016-12-09T21:13:48Z","body":"Updated `system_power_management_update()` so that `low_battery` event can be generated again once the battery **starts** to charge. Rebased on top of current `develop`."}}
{"actor":{"display_login":"sergeuz"}}