{"action":"created","issue":{"url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/248","repository_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero","labels_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/248/labels{/name}","comments_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/248/comments","events_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/248/events","html_url":"https://github.com/RPi-Distro/python-gpiozero/issues/248","id":145554425,"number":248,"title":"Add Servo","user":{"login":"bennuttall","id":1609725,"avatar_url":"https://avatars.githubusercontent.com/u/1609725?v=3","gravatar_id":"","url":"https://api.github.com/users/bennuttall","html_url":"https://github.com/bennuttall","followers_url":"https://api.github.com/users/bennuttall/followers","following_url":"https://api.github.com/users/bennuttall/following{/other_user}","gists_url":"https://api.github.com/users/bennuttall/gists{/gist_id}","starred_url":"https://api.github.com/users/bennuttall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bennuttall/subscriptions","organizations_url":"https://api.github.com/users/bennuttall/orgs","repos_url":"https://api.github.com/users/bennuttall/repos","events_url":"https://api.github.com/users/bennuttall/events{/privacy}","received_events_url":"https://api.github.com/users/bennuttall/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/milestones/7","html_url":"https://github.com/RPi-Distro/python-gpiozero/milestones/v1.3","labels_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/milestones/7/labels","id":1683955,"number":7,"title":"v1.3","description":"","creator":{"login":"bennuttall","id":1609725,"avatar_url":"https://avatars.githubusercontent.com/u/1609725?v=3","gravatar_id":"","url":"https://api.github.com/users/bennuttall","html_url":"https://github.com/bennuttall","followers_url":"https://api.github.com/users/bennuttall/followers","following_url":"https://api.github.com/users/bennuttall/following{/other_user}","gists_url":"https://api.github.com/users/bennuttall/gists{/gist_id}","starred_url":"https://api.github.com/users/bennuttall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bennuttall/subscriptions","organizations_url":"https://api.github.com/users/bennuttall/orgs","repos_url":"https://api.github.com/users/bennuttall/repos","events_url":"https://api.github.com/users/bennuttall/events{/privacy}","received_events_url":"https://api.github.com/users/bennuttall/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":0,"state":"open","created_at":"2016-04-05T09:17:05Z","updated_at":"2016-04-05T09:24:55Z","due_on":null,"closed_at":null},"comments":28,"created_at":"2016-04-04T00:03:43Z","updated_at":"2016-04-06T18:48:43Z","closed_at":null,"body":"We should add a Servo class, or more likely, a series of Servo classes (e.g. `Servo180`, `Servo360`...). I'm not sure what the variety of different servos is like, but perhaps there needs to be much configuration ability on init.\r\n\r\nThe way servos work is with PWM, setting a specific duty cycle to turn the servo to a specific angle. The one I have, a [Tower Pro SG90](http://www.micropik.com/PDF/SG90Servo.pdf), moves proportionately between 0 degrees and about 170 degrees when the value is set between 0.033 and 0.253 at a frequency of 100, but any value outside that does nothing.\r\n\r\nI started playing with one using `PWMOutputDevice` and got it turning to certain angles by sending various signals via the `value` property.\r\n\r\nWhen thinking about implementing a class for this, I realised I probably didn't want to extend `PWMOutputDevice` as is, because I didn't need `on()`, `off()`, etc. so I guess we should introduce a `DigitalPWMOutputDevice` class for this, and all existing classes which currently extend `PWMOutputDevice` would switch to `DigitalPWMOutputDevice`, and `Servo` would extend the new `PWMOutputDevice`. Perhaps \"digital\" is the wrong word in this case...\r\n\r\nI'm not certain what the servo API should look like, but I guess ideally, you could set it by angle, and maybe setting `value` between 0 and 1 would move proportionally between the minimum and maximum positions."},"comment":{"url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/comments/206510819","html_url":"https://github.com/RPi-Distro/python-gpiozero/issues/248#issuecomment-206510819","issue_url":"https://api.github.com/repos/RPi-Distro/python-gpiozero/issues/248","id":206510819,"user":{"login":"waveform80","id":1076190,"avatar_url":"https://avatars.githubusercontent.com/u/1076190?v=3","gravatar_id":"","url":"https://api.github.com/users/waveform80","html_url":"https://github.com/waveform80","followers_url":"https://api.github.com/users/waveform80/followers","following_url":"https://api.github.com/users/waveform80/following{/other_user}","gists_url":"https://api.github.com/users/waveform80/gists{/gist_id}","starred_url":"https://api.github.com/users/waveform80/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/waveform80/subscriptions","organizations_url":"https://api.github.com/users/waveform80/orgs","repos_url":"https://api.github.com/users/waveform80/repos","events_url":"https://api.github.com/users/waveform80/events{/privacy}","received_events_url":"https://api.github.com/users/waveform80/received_events","type":"User","site_admin":false},"created_at":"2016-04-06T18:48:43Z","updated_at":"2016-04-06T18:48:43Z","body":"Any particular reason this shouldn't extend PWMOutputDevice? You could simply make on a method equivalent to setting the maximum angle (which would be consistent with the fact value will be 1 which is the result of calling on in other PWM devices). If you *really* want to get rid of on, Python is unusual in that you can remove methods from sub-classes with a little magic, but it's unusual enough that I'd generally discourage it (simply because people won't expect it)."}}