Code Monkey home page Code Monkey logo

gpiozero's Introduction

gpiozero

A simple interface to GPIO devices with Raspberry Pi, developed and maintained by Ben Nuttall and Dave Jones.

About

Component interfaces are provided to allow a frictionless way to get started with physical computing:

from gpiozero import LED
from time import sleep

led = LED(17)

while True:
    led.on()
    sleep(1)
    led.off()
    sleep(1)

With very little code, you can quickly get going connecting your components together:

from gpiozero import LED, Button
from signal import pause

led = LED(17)
button = Button(3)

button.when_pressed = led.on
button.when_released = led.off

pause()

You can advance to using the declarative paradigm along with provided to describe the behaviour of devices and their interactions:

from gpiozero import OutputDevice, MotionSensor, LightSensor
from gpiozero.tools import booleanized, all_values
from signal import pause

garden = OutputDevice(17)
motion = MotionSensor(4)
light = LightSensor(5)

garden.source = all_values(booleanized(light, 0, 0.1), motion)

pause()

See the chapter on Source/Values for more information.

The library includes interfaces to many simple everyday components, as well as some more complex things like sensors, analogue-to-digital converters, full colour LEDs, robotics kits and more. See the Recipes chapter of the documentation for ideas on how to get started.

Pin factories

GPIO Zero builds on a number of underlying pin libraries, including RPi.GPIO and pigpio, each with their own benefits. You can select a particular pin library to be used, either for the whole script or per-device, according to your needs. See the section on changing the pin factory.

A "mock pin" interface is also provided for testing purposes. Read more about this in the section on mock pins.

Installation

GPIO Zero is installed by default in the Raspberry Pi OS desktop image, available from raspberrypi.org. To install on Raspberry Pi OS Lite or other operating systems, including for PCs using remote GPIO, see the Installing chapter.

Documentation

Comprehensive documentation is available at https://gpiozero.readthedocs.io/. Please refer to the Contributing and Development chapters in the documentation for information on contributing to the project.

Issues and questions

If you have a feature request or bug report, please open an issue on GitHub. If you have a question or need help, this may be better suited to our GitHub discussion board, the Raspberry Pi Stack Exchange or the Raspberry Pi Forums.

Contributors

See the contributors page on GitHub for more info.

gpiozero's People

Contributors

alexwlchan avatar bennuttall avatar chrisruk avatar dglaude avatar edwardbetts avatar f9n avatar fangchenli avatar fortoffee avatar gadgetoid avatar jee1mr avatar lurch avatar makslevental avatar martchus avatar martinohanlon avatar mk-fg avatar mrharcombe avatar notbobthebuilder avatar pmuller avatar ricksbt avatar rmisev avatar ryanteck avatar sofiiakosovan avatar steveamor avatar stewartadcock avatar thiagosfsilva avatar thijstriemstra avatar tjguk avatar tuftii avatar waveform80 avatar yisraeldov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpiozero's Issues

Deb packaging

We should get on with Raspbian packaging fairly quickly. I want this on the image for the next Birmingham picademy, and I'd like to include instructions on the worksheet for teachers to install this on any other Pi's they have with minimal hassle. I can handle this if you wish.

Add keep alive functionality

I've been doing all my testing in an IPython shell and it's great fun. However, I just tried to run an example in a file and nothing happened because there was nothing keeping the program alive.

License?

Just putting together a PR to start work on the docs and I was wondering what license you want to bung this under? (it's necessary for part of the Sphinx setup basically)

Using blink as primitive2

Something went wrong with the last thread - it was locked down for some reason

@waveform80
As you said - your not a hardware person - which isn't a problem when working with software/web stuff etc but its not ideal in a physical computing discussion.
GPIOZero is intended to make it a bit easier to program the gpio pins.

I'm saying - making a blink is taking it too far.
Creating a threaded blink isn't actually a problem because of the rarity it would be used for)

The gpio pins are pins - they are not LEDS or buzzers or motors.
They go up to 3.3V and down to zero.
I think its important at GPIOZero target audience to understand that
removing the setup lines for RPi.GPIO is admirable and excellent idea
saying LEDa = LED(17) is too much of a simplification
saying led(17).blink is even worse

Threading is complicated - it would be nice to wrap threading up in a nice easy to use package so that it can be applied to anything - not just a special for a LED

Let people digest this and #53 (comment) and see what others think

Simon

PIR Motionsensor seems laggy and a bit unreliable

I guess it's something to do with the moving average way that it is being read, but I've tried two different PIR sensors with the same results, just using this code...

from gpiozero import LED, MotionSensor
from time import sleep
pir = MotionSensor(21)
light = LED(26)
pir.when_motion = light.on
pir.when_no_motion = light.off
sleep(30)

Using a 10k pull-down on the PIR output helps quite a bit, but the response is still rather laggy.

while True: led.red = pot.value

Would it be possible to automatically pass the value of a potentiometer directly into something like an RGBLED?

So that the following example:

led = RGBLED(2, 3, 4)
pot = MCP3008()

while True:
    led.red = pot.value

can be done automatically somehow?

i.e. When the pot value changes, the LED changes accordingly.

button.when_pressed = led.blink causes Exception

I'm trying a few variations of the following code:

button = Button(17)
led = LED(4)

button.when_pressed = led.blink

which always causes the following:

Exception in thread Thread-10:
Traceback (most recent call last):
  File "/usr/lib/python3.2/threading.py", line 740, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.2/threading.py", line 693, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.2/dist-packages/gpiozero/output_devices.py", line 43, in _blink_led
    if self._blink_thread.stopping.wait(on_time):
  File "/usr/lib/python3.2/threading.py", line 422, in wait
    signaled = self._cond.wait(timeout)
  File "/usr/lib/python3.2/threading.py", line 240, in wait
    if timeout > 0:
TypeError: unorderable types: Button() > int()

The following similar examples work:

  • button.when_pressed = led.on
  • button.when_pressed = led.off
  • button.when_pressed = traffic_lights.on
  • button.when_pressed = traffic_lights.off

But any use of blink associated with a callback fails. I can't tell what's causing it. Is it just threads falling over each other?

led.is_on not led.is_active

Someone suggested on the forums that the LED class's is_active property should be named is_on. I think it's a good idea and aligns with other aliases like is_pressed in Button.

@waveform80 can we move _alias from input_devices.py to devices.py and use it in both input and output devices?

ReST for docs

As a docs junkie I've got to at least try to make this case! Bear with me...

In praise of Markdown

Generally, I love Markdown. It's far and away the easiest mark-up language, and perfect for wikis and short documents. I suspect Markdown has been selected primarily to make contributions to the project's documentation as easy as possible; a laudable goal. However, its very simplicity means that managing a large trove of technical documentation (such as an API reference) rapidly becomes difficult under MD compared to ReST, and there's several other places where ReST is superior...

Links

When making intra-document links (links between pages or sections within the same repository) there seems little consensus whether to link to the MD source files, or the HTML output files (from whatever generator is employed). Moreover, there seem to be several competing ideas on structuring fragments in the first place (inline HTML for naming fragments, using a single MD source for each fragment and combining the output, etc. etc.).

The major issue here is that MD has no extensible link types and thus can't have "a method link" or "an attribute link". For example, in ReST docs I can use :attr:pin`` to make a link to the pin attribute in the current class wherever that may be in the eventual output (in the same page, another page, etc.).

Personally, this came in extremely handy recently when I decided the picamera API docs were becoming far too long (they were taking nearly 10 seconds to load on a mobile platform) and I split them up by module; nothing terribly complicated was involved because most of the class, attribute, and method links stayed more or less the same.

Docstrings and the command line

MD docs typically aren't entered as inline docstrings in the code. This has the unfortunate side-effect that the documentation isn't (easily) accessible from the command line. For example, a user of picamera can simply do the following on the command line to retrieve the (raw) docs for the PiCamera class constructor, and then the resolution property:

>>> import picamera
>>> camera = picamera.PiCamera()
>>> help(camera)
>>> help(camera.resolution)

This becomes even easier under IPython where instead of wrapping things with help() one can simply append a ? suffix for the same effect. This also ties into Goal 1 of the ReST project: to have a markup language that is readable both raw and cooked. I think MD is equally readable raw except when it dives into inline HTML to achieve more complex things (admonitions like hints and warnings, and complex tables layouts).

Still, I will be content if I have at least persuaded you of the need for inline docstrings (whether in MD or ReST) to permit easy command line usage (incidentally, this also allows usage in things like IPython notebook's popup help).

Offline access

While offline access is becoming less of a requirement in our ever more connected world there are still plenty of places with less than stellar connectivity (cough Leeds Digital Garage cough). For such places it's extremely useful not only to have the command line docs detailed above (which are necessarily offline) but to have the nicely rendered HTML output too (with all its fancy images and extra chapters).

Again, this is relatively easy to do with the sphinx tooling for ReST. In picamera I have the python-picamera-docs package in Raspbian containing the complete docs available for offline viewing (install it and you'll find them under /usr/share/doc/python-picamera-docs/). This is produced from the same ReST source that generates the online docs for ReadTheDocs, which in turn automatically incorporates all the inline docstrings.

I'm not aware of MD tooling that allows this same facility, at least with similar ease to sphinx (it's especially notable that sphinx does most of the work for integrating the offline docs with Debian's doc-base system). Still, I may be less than well informed and I'd at least be happy if we could generate a traditional python-gpiozero-docs package from the MD source.

Searching / indexing

Again, trivial with the sphinx tooling; it's all done automatically and the searching even works with the offline copy of the docs (it's just some local javascript accessing a pre-built index). There do appear to be several possibilities here for MD but I'm not aware of any with similar offline capabilities. Perhaps there's something I'm not aware of?

Cross-referencing

A quick example from the picraft vector chapter. Note the link to "dict" and "set". In the source ReST these are as simple as:

...However, it conveys an extremely important capability in
Python: only immutable objects may be keys of a :class:`dict`
or members of a :class:`set`...

Sphinx looks for the "dict" and "set" classes within picraft, realizes they don't exist, then goes and looks in the indexes of the defined inter-sphinx docs. It finds them there and links to them.

Note at the moment the inter-sphinx link is defined as targetting Python 3.2. This is because I'm aware the foundation wishes to push Python 3 as the version of Python to learn, and because 3.2 is the current version of Python 3.x available on Raspbian. I'm hoping the new Jessie based version of Raspbian will ship with Python 3.4 (much better :) in which case all I need do to update any such links is change that inter-sphinx definition then rebuild the docs.

Again, this seems harder in MD?

Tables

Tables have a bit of a bad rep in ReST. This is largely because people aren't aware of the multiple different table types in ReST compared to MD's (well, GFM's anyway given that generic MD has no tables other than inline HTML). The classic ReST table (the one everyone complains about) is indeed complicated:

+------------------+---------------------+
| This is          | a table in ReST     |
+==================+=====================+
| It includes the  | But these are only  |
| ability to span  | easy to construct   |
| contents across  | if you have a table |
| multiple rows or | capable editor like |
| columns.         | emacs or vim        |
+------------------+---------------------+

Personally (being a vimmie) I rather like these, because they fulfil goal 1 of the ReST project. However, I can well understand why people not accustomed to emacs or vim find them fiendishly difficult to construct. There's also the "simple table":

=====  =====  ======
   Inputs     Output
------------  ------
  A      B    A or B
=====  =====  ======
False  False  False
True   False  True
False  True   True
True   True   True
=====  =====  ======

However, these are also (rightly) considered too complex due to the alignment requirement. The two table types no-one seems aware of (probably because they're buried in the directives docs away from the obvious "Tables" section) are the ludicrously simple CSV table:

.. csv-table::

    This is,a table,that
    I constructed,in Excel,then copied
    and pasted,into my,ReST doc

And the slightly bizarre list table:

.. list-table:: Frozen Delights!
   :widths: 15 10 30
   :header-rows: 1

   * - Treat
     - Quantity
     - Description
   * - Albatross
     - 2.99
     - On a stick!
   * - Crunchy Frog
     - 1.49
     - If we took the bones out, it wouldn't be
       crunchy, now would it?
   * - Gannet Ripple
     - 1.99
     - On a stick!

The observant will note from the docs that you could easily copy and paste a GFM table with csv-table by adding :delim: | as an option.

Personally I'm not so enamoured of csv-table simply because it violates goal 1 of ReST (the table isn't as readable "raw" which means it's not as readable to command line help readers). Still, at least it's present so authors have a means of constructing tables almost as simply as they can in GFM.

Conclusion

As mentioned above, I'm a fan of MD for simple documents. However, my opinion is that comprehensive documentation for a Python project goes beyond what MD can easily achieve (bearing in mind that the presumed reason for the selection of MD is its very simplicity).

A quick summary of the two systems:

  • Inline markup: For basic things (paragraphs, unordered lists, inline emphasis, headings) there's very little difference, and hence no real usability difference, between MD and ReST.
  • Block markup: Admonitions (hints, warnings) are simpler in ReST (at least all the extensions I've seen for doing admonitions in MD are similar to ReST but I don't think people are generally aware of them as I've not seen them used extensively in practice).
  • Tables: As noted above, ReST tables can be made almost as simple as GFM.
  • Links: External document links are admittedly more complex in ReST (e.g. See the Python home page http://www.python.org_ for info.) but then internal (and intersphinx) links are considerably simpler. In my experience you'll use a lot more internal links that external links in package documentation.
  • Code: Code blocks are almost as simple in ReST as they are in MD (indented but with a :: leader on the line above), although they include considerably more options in ReST (external file inclusion, line highlighting, and manual syntax selection which occasionally comes in handy). GFM has rather nice unindented code blocks but firstly these aren't as clear in the raw as an indented block, and secondly I'm not aware of any editors other than Notepad than can't block indent so it's not a serious imposition.
  • Images: Images are arguably similar in complexity between the two (although very different in syntax). That said, sphinx does have a nice feature permitting different versions of the same image to be used for different targets (e.g. PNG for HTML output, EPS for PDF output); a feature I use quite extensively by using SVG for the source format, and having a Makefile spit out the relevant formats at build time.

Finally, generation of different types of documentation (online, offline, command line) appears considerably simpler with ReST's sphinx tooling, but then I may not be aware of other options with MD here (please feel free to educate me!).

Anyway, my thanks to any reader that makes it through this mammoth screed. I await your consideration!

Beta 2

Let's get a second beta out this week. Here's what's to be done:

  • #43 Mandatory pin on PWMOutputDevice?
  • #45 Change PWM interface from 0-100 to 0-1
  • #40 Change RGBLED interface from 0-100 to 0-255
  • #41 Decide on generic ADC interface and specific analogue interfaces like Potentiometer
  • Update docs accordingly
  • #47 Motor interface has inconsistent interface

Motor interface has inconsistent optional arg

I gave the Motor class's methods an optional argument for the number of seconds to be on for, e.g:

motor.on(5)

is equivalent to:

motor.on()
sleep(5)
motor.off()

Should we remove this, or add a similar interface to other classes? e.g. LED

API design

This comment will be updated as API design is agreed.

.xx() denotes method, .xx denotes property.

LED:

  • is_active
  • on()
  • off()
  • blink()
  • toggle()

Buzzer:

  • is_active
  • on()
  • off()
  • toggle()
  • flash()

Motor:

  • on()
  • off()

Robot

  • forwards()
  • backwards()
  • left()
  • right()
  • stop()

Button:

  • is_pressed (is it currently pressed?)
  • when_pressed (callback)
  • when_released (callback)
  • wait_for_press() (wait for edge)

MotionSensor:

  • motion_detected

LightSensor:

  • value

TemperatureSensor:

  • value

MCP3008 / Potentiometer

I've incorporated @martinohanlon's MCP3008 class, and added a couple of examples to the recipes in the docs, including a cool one for controlling an RGB LED with 3 pots.

MCP3008 could be used for a range of analogue inputs. Is this sufficient an interface, or should we provide wrappers for specific components?

Provide wrappers for LED groups on add-on boards

fish = FishDish()

fish.lights_on()
fish.lights_off()
fish.toggle_lights()
fish.blink_lights()

should become:

fish = FishDish()

fish.lights.on()
fish.lights.off()
fish.lights.toggle()
fish.lights.blink()

by use of the TrafficLights class. Same applies to TrafficHat.

Suggestion - add relay class?

I've been hacking up a thing I'll be blogging about in a day or two. It uses a small arduino relay board that triggers when a port is 0 and is off when a port is 1. I've been using the LED class to drive it, but obviously have to invert the logic. It would be nice to have an inverted logic class so that you could address a relay as e.g. lamp.on() for it to be on instead of lamp.off() when you wanted it switched on.

It would certainly make things easier for kids. The only other way round it is to wire up the lamp to the NC terminal but then it's always on unless actively switched off, which isn't ideal either. It's a suggested addition that I think would be very worthwhile.

Introduce toggle method

I'd like to introduce a toggle method for any output device which can be turned on or off. If it's on, toggle will turn it off. If it's off, toggle would turn it on. Applying toggle to a group of components would invert their state.

Would it be easier to maintain state within the object or check it using GPIO.input(self.pin)?

InputDevice hierarchy doesn't include LightSensor

I'm guessing LightSensor doesn't descend from InputDevice because you don't want things like wait_for_input available for it (given the complexities of calculating its value). However, a slightly cleaner way of rejigging it might be:

![InputDevice hierarchy](http://g.gravizo.com/g?
digraph G {
graph [rankdir=LR];
node [shape=rect,style=filled,color="%234477bb",fontname=Sans,fontsize=10];
LightSensor->InputDevice;
Button->WaitableInputDevice;
WaitableInputDevice->InputDevice;
MotionSensor->InputDevice;
TemperatureSensor;
})

In other words, shove stuff like wait_for_input and add_callback in a new WaitableInputDevice class below InputDevice and bung Button below that (and everything else, except TemperatureSensor) off InputDevice. Happy to bung together a PR if you want!

pin property accessible?

led = LED(2)
led.on()  # it works
led.pin = 3
led.off()  # error

Users can do this. Should I care? @waveform80

Alternatively, the pin property could be prefixed with an underscore.

Adding other helpful functions to GPIOZero

If your going down the path of blinkin LEDs threading, then maybe worth considering other often needed functions.

Ultrasonic is 1st that springs to mind.

Motor wheel encoder counting is another

GetIP would be a non-gpio thingy worth doing?

Merge "blink" and "flash"

The blink() and flash() methods should be merged into one, with the following arguments:

  • on_time=1
  • off_time=1
  • background=True
  • n=1

There should be a name for this method. Maybe flash or blink. Maybe something else.

The Buzzer class should use a domain specific alias for this method. A name is also to be decided.

Can't recreate a Button object

Running the following code in a shell:

>>> button = Button(15)
>>> button = Button(15)

The second line causes a RuntimeError raised by GPIO.add_event_detect()

Oddly, trying a couple more times, it eventually lets you.

I also managed to get a Segfault doing this once too many times! (Probably a RPi.GPIO problem, not gpizero)

Introduce flash method

I want to add a flash method to blinkable output devices. flash would blink once, e.g:

def flash():
    self.on()
    sleep(1)
    self.off()

Maybe throw in optional arguments:

def flash(on_time=1, off_time=1, n=1):
    for i in range(n):
        self.on()
        sleep(on_time)
        self.off()
        sleep(off_time)

Components, boards and accessories to add

Components:

  • Potentiometer
  • RGB LED
  • Ultrasonic sensor (HC - SR04)

Boards & accessories:

Longer-term additions:

  • Energenie (see #69)
  • LCD screens
  • Servos (see Grandpa Scarer resource for RPi.GPIO examples)
  • DHT (waiting on kernel module)
  • Ph sensor?
  • Quadrature rotation encoder motor (e.g.)
  • Line follower

Not including things which already have decent libraries, like Pibrella and Explorer HAT.

Missing init param descriptions in documentation

I added descriptions of initialisation options to the docs yesterday. Filled most of them in but I'm afraid I couldn't complete some of them. @waveform80 could you take a look and fill in the gaps where I've left ??? (and maybe check the sensor ones I've attempted to write).

Sorry/thanks

Why is pin optional?

If pin is a mandatory argument to the constructor InputDevice why not simply make it a mandatory argument rather than checking for None in the constructor? Or is this an attempt to provide the friendliest possible error message in the event that a user forgets the one mandatory argument (i.e. instead of the usual "expected 2 arguments instead of 1" stuff)?

Should RGB LED values be 0-100 like PWM or 0-255?

The RGBLED class I implemented yesterday comprises of three values, for red, green and blue. The way PWM works is that you set the duty cycle from 0 to 100, from off to dim to bright. If the interface allowed the user to pass in values on a scale from 0 to 255, this would be more compatible with usual colour codes like in CSS and in the Sense HAT library.

Using blink as primitive

I think making a LED blink is the 1st real program step in physical programming and having a command that does it is over-simplfying things too far.

Simplification should be used for complicated things like driving Neopixels/H-bridge motors etc

I think its also bit debatable whether to use Led() straight out of the box just on simple things
I'd prefer a
LEDA = gpio17
while true:
LedA(On)
Wait(1)
LedA(Off)
wait(1)

type approach

Heisenbug in add_event_detect

The one issue I've come across in practice with RPi.GPIO (which annoyingly happened during the demo too the other day!) is that sometimes (not often - it's a Heisenbug) the library fails to add edge detection when requested. It happens particularly with Button and LightSensor which both use add_event_detect. I haven't yet tied down if there's any pre-requisites to re-produce but it's something I need to look into as when it manifests the only option is to shut down the interpreter and try again.

So, first step: mitigation. Ensure all resources allocated in all constructors are cleaned up in the event the constructor fails (in particular cleaning up the allocation of the GPIO pin and pull-up). Second step: dig into the C source code and find out what on earth is causing add_event_detect to actually fail on rare occasions. I'm leaving this as the second step as it's going to be Hard (tm); probably some subtle race condition or something like that.

RPi.GPIO Problems on Raspberry PI 2

I've been facing many problems using the RPi.GPIO library at the PI 2, so far the solutions was to use the gpio lib that uses the standard linux sysfs interface to deal with it. Wouldn't be a good approach to use it on the gpiozero lib?

Energenie

It was suggested in #66 that we add an Energenie class.

I maintain the energenie module, which provides a simple interface to the Energenie Pi-mote. It's just a case of turning pins on and off in sequence.

Seeing as I'm the maintainer and it's not going to upset anyone, should we consider incorporating Energenie functionality into GPIO Zero?

I'd consider this low priority, would rather concentrate on other things before the 1.0 release, but wanted to start a thread now.

Change "Blink" to "Buzz" for buzzers.

While not critical when writing my tutorial for TrafficHAT Involving buzzing the buzzer it felt a bit weird explaining to blink the buzzer. Where as being able to buzz the buzzer seems much more friendly.

Public beta for teachers

I think we're close to being ready for a public beta, to get some feedback from teachers.

I'm fairly certain all the main stuff is complete, and perfectly usable. Some of the sensor stuff needs more work, and only basic motor functionality has been added so far, but examples using LEDs, buzzers and buttons will be fine.

I need to double check there are no missing docstrings (particularly in inherited methods), and I need to document the usage of all the completed components, but otherwise I think we're set.

I'll also fill in more info on the google doc - that'll be handy for teachers. And create some recipes and example projects - and look at converting more of the code in our resources as further examples.

@waveform80 any lingering thoughts?

Should LED extend PWMOutputDevice instead of DigitalOutputDevice?

Making LED a PWM device by default would enable a brightness setting (if we aliased .value as .brightness):

>>> led = LED(2)
>>> led.on()
>>> led.off()
>>> led.brightness = 0.5

Any reason not to? The alternative is leave it as it is, and people can manually create the led as a PWMOutputDevice object.

We would need to ensure #57 is fixed first.

Blink does not work for PWMOutputDevice

When you try to blink a PWMOutputDevice, it flickers on and off quickly once, then stays off apart from random short flashes, even after turning off!

It may be caused by blink definition being inherited from DigitalOutputDevice, and it calling super's on and off, but I'm not sure.

RuntimeWarning: A physical pull up resistor is fitted on this channel!

A RuntimeWarning is raised when setting up GPIO pins 2 or 3 because they have physical pull-up resistors on them.

  1. Is it possible to suppress this warning when it won't make a difference? e.g. an LED
  2. Is it possible to not allow setup on these pins when it won't work? e.g. when pull_up=False is provided on a Button setup

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.