Also tell a whole load of lies about what's a keyword-only arg. In the
vast majority of cases, pin_factory (and other args) *aren't*
keyword-only ... but we'd really like them to be, it's just difficult
while maintaining py2 compatibility.
This implements the proposal discussed in the re-opened #279 to add a
pin_factory argument at the device level and remove the ability to
specify a pin instance to device constructors (they now only accept a
pin specification).
Note: there's still a couple of bits to tidy up (tests on "real" Pis,
and pin_factory.release_all needs refinement) but the test suite is now
at least capable of passing on a PC.
This is a minimal change which re-orders some bits of CompositeDevice's
constructor to ensure that all exceptions get raised *before* we store a
reference to the contained devices. Hopefully this'll be enough to sort
out 2.x but I'm not sure it will be for pypy (might still require an
explicit close there).
Also updated StatusBoard and StatusZero to reject duplicate identifiers
(namedtuple doesn't pick 'em up because they're passed in a dict and
thus the dups are squashed prior to the call). Added tests for all the
relevant stuff.
Permit replacement of pin_factory without closing old factory. However,
continue closing devices associated with extant pin factory at script
termination.
Factor out hardware SPI pin numbers; this is a effectively a rebase (and
minor modification) of @lurch's original patch which conflicted after
the merge of the remote-spi branch.
Ensure SourceMixin descendents shut down the source prior to closing.
Furthermore, make sure devices are closed before pin factory shuts down,
and that pins have a strong reference to their owning factory (to
prevent losing the factory before the pins).
Wrong classname in the software implementation and for some reason I'd
reverted a change on spi_flags somewhere... Also removed the clause
skipping remote pigpiod tests
Tested this commit with hardware and software SPI remotely - working
nicely
Also renamed GPIOZERO_INPUT_PIN to GPIOZERO_TEST_INPUT_PIN, and fixed up
the pigpio factory so it actually raises an exception if the connection
fails and we don't try and control the daemon anymore.
The real pin tests were broken by the new factory stuff. This commit
fixes them up, and fixes up a few other bits besides (like why the
pigpio PWM tests were failing, why RPi.GPIO sometimes segfaulted on PWM
tests, etc.)
It also causes the real pin tests to run against MockPin (thanks to
@lurch for the suggestion!). This required some tweaks to MockPin to
make it emulate physically pulled up pins itself (which in turn
necessitated changing quite a few pin numbers in the main test suite
because we were using 2 and 3 everywhere), and to allow one MockPin to
drive another. Anyway, everything's working now including all the tests
on a Pi (haven't tried RPIO yet, but only because I'm on a Pi3 -
everything else works with overall coverage of 88% :).
Some fairly major changes to ensure that the Pin.when_changed property
doesn't keep references to the objects owning the callbacks that are
assigned. This is vaguely tricky given that ordinary weakref's can't be
used with bound methods (which are ephemeral), so I've back-ported
weakref.WeakMethod from Py3.4.
This solves a whole pile of things like Button instances not
disappearing when they're deleted, and makes composite devices
containing Buttons much easier to construct as we don't need to worry
about partially constructed things not getting deleted.
Ensure LEDCollection cleans up upon construction failure, rename some
internals to be a bit more obvious, rename PinGPIOUnsupported to
PinUnsupported, and some other stuff I've forgotten!
Sorry! Dave's messing around with the pin implementations again.
Hopefully the last time. The pin_factory is now really a factory object
which can be asked to produce individual pins or pin-based interfaces
like SPI (which can be supported properly via pigpio).