{"action":"created","issue":{"url":"https://api.github.com/repos/bbcmicrobit/micropython/issues/9","labels_url":"https://api.github.com/repos/bbcmicrobit/micropython/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/bbcmicrobit/micropython/issues/9/comments","events_url":"https://api.github.com/repos/bbcmicrobit/micropython/issues/9/events","html_url":"https://github.com/bbcmicrobit/micropython/issues/9","id":106949396,"number":9,"title":"Add gesture functions","user":{"login":"dpgeorge","id":6187689,"avatar_url":"https://avatars.githubusercontent.com/u/6187689?v=3","gravatar_id":"","url":"https://api.github.com/users/dpgeorge","html_url":"https://github.com/dpgeorge","followers_url":"https://api.github.com/users/dpgeorge/followers","following_url":"https://api.github.com/users/dpgeorge/following{/other_user}","gists_url":"https://api.github.com/users/dpgeorge/gists{/gist_id}","starred_url":"https://api.github.com/users/dpgeorge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpgeorge/subscriptions","organizations_url":"https://api.github.com/users/dpgeorge/orgs","repos_url":"https://api.github.com/users/dpgeorge/repos","events_url":"https://api.github.com/users/dpgeorge/events{/privacy}","received_events_url":"https://api.github.com/users/dpgeorge/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/bbcmicrobit/micropython/milestones/1","html_url":"https://github.com/bbcmicrobit/micropython/milestones/Version%200.9","labels_url":"https://api.github.com/repos/bbcmicrobit/micropython/milestones/1/labels","id":1399264,"number":1,"title":"Version 0.9","description":"An initial pre-release for MicroPython on the micro:bit.","creator":{"login":"ntoll","id":37602,"avatar_url":"https://avatars.githubusercontent.com/u/37602?v=3","gravatar_id":"","url":"https://api.github.com/users/ntoll","html_url":"https://github.com/ntoll","followers_url":"https://api.github.com/users/ntoll/followers","following_url":"https://api.github.com/users/ntoll/following{/other_user}","gists_url":"https://api.github.com/users/ntoll/gists{/gist_id}","starred_url":"https://api.github.com/users/ntoll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ntoll/subscriptions","organizations_url":"https://api.github.com/users/ntoll/orgs","repos_url":"https://api.github.com/users/ntoll/repos","events_url":"https://api.github.com/users/ntoll/events{/privacy}","received_events_url":"https://api.github.com/users/ntoll/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":11,"state":"open","created_at":"2015-11-07T14:26:28Z","updated_at":"2015-11-30T16:05:14Z","due_on":"2015-11-16T00:00:00Z","closed_at":null},"comments":19,"created_at":"2015-09-17T09:54:13Z","updated_at":"2015-12-16T19:34:54Z","closed_at":null,"body":"We should add a simple API for accelerometer gestures, such as: shake, falling, logo_up, logo_down, facing_up, facing_down.\r\n\r\nAll of them just require sampling the accelerometer over about 1 second and looking at the data to see if the gesture occurred.  That can be done asynchronously and transparent to the user, and just\r\naccessed using simple functions.\r\n\r\nWe can make a gesture module, or have it as an object as part of the microbit module.  Ie:\r\n```python\r\nimport gesture\r\nprint(gesture.falling())\r\n# or\r\nimport microbit\r\nprint(microbit.gesture.falling())\r\n```\r\n\r\nThere are some subtleties with the API: logo_up, logo_down, facing_up and facing_down are all \"continuous\" events (like a button being held down) so when you call one of these function it can return True/False if that gesture is currently occurring.\r\n\r\nBut you might miss a shake or a fall and want methods like fell and shook (or did_fall, did_shake) which return True if the device fell/shook since the last call to these functions, and then return False until the device has the gesture again.  So they are not simple \"read only\" gestures, they are read&modify.\r\n\r\nIs it enough to have falling and shaking and just make sure your code doesn't miss them, or do we also want did_fall and did_shake?"},"comment":{"url":"https://api.github.com/repos/bbcmicrobit/micropython/issues/comments/165222958","html_url":"https://github.com/bbcmicrobit/micropython/issues/9#issuecomment-165222958","issue_url":"https://api.github.com/repos/bbcmicrobit/micropython/issues/9","id":165222958,"user":{"login":"finneyj","id":11539567,"avatar_url":"https://avatars.githubusercontent.com/u/11539567?v=3","gravatar_id":"","url":"https://api.github.com/users/finneyj","html_url":"https://github.com/finneyj","followers_url":"https://api.github.com/users/finneyj/followers","following_url":"https://api.github.com/users/finneyj/following{/other_user}","gists_url":"https://api.github.com/users/finneyj/gists{/gist_id}","starred_url":"https://api.github.com/users/finneyj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/finneyj/subscriptions","organizations_url":"https://api.github.com/users/finneyj/orgs","repos_url":"https://api.github.com/users/finneyj/repos","events_url":"https://api.github.com/users/finneyj/events{/privacy}","received_events_url":"https://api.github.com/users/finneyj/received_events","type":"User","site_admin":false},"created_at":"2015-12-16T19:34:54Z","updated_at":"2015-12-16T19:34:54Z","body":"Hi @markshannon \r\n\r\nSure:. https://github.com/lancaster-university/microbit-dal/pull/65\r\n\r\nI've spoken to the MSR guys and this has been live/tested on test.microbit.co.uk for a few weeks now, so largely I wanted to solicit feedback from the micro:python community too, in case you'd like to suggest anything that might improve it form your perspective.\r\n\r\nI'm already considering breaking it out into a separate gestures module, but as most gestures are Accelerometer based its slightly more RAM efficient to leave it where it is for now. Might do this later if I find time to bring gestures on board from other sensors (e.g magnetometer)."}}