mirror of
https://github.com/KevinMidboe/python-gpiozero.git
synced 2025-12-08 20:39:01 +00:00
Catch SPI conflicts properly
Also handle SPI flags in pigpio implementation more elegantly (just store the flags and manipulate them instead of keeping separate fields)
This commit is contained in:
@@ -89,12 +89,6 @@ class LocalPiHardwareSPI(SPI, Device):
|
||||
self._interface.open(port, device)
|
||||
self._interface.max_speed_hz = 500000
|
||||
|
||||
def _conflicts_with(self, other):
|
||||
return not (
|
||||
isinstance(other, LocalPiHardwareSPI) and
|
||||
(self._port, self._device) != (other._port, other._device)
|
||||
)
|
||||
|
||||
def close(self):
|
||||
if self._interface:
|
||||
try:
|
||||
@@ -165,6 +159,12 @@ class LocalPiSoftwareSPI(SPI, OutputDevice):
|
||||
self.close()
|
||||
raise
|
||||
|
||||
def _conflicts_with(self, other):
|
||||
return not (
|
||||
isinstance(other, LocalPiSoftwareSPI) and
|
||||
(self.pin.number != other.pin.number)
|
||||
)
|
||||
|
||||
def close(self):
|
||||
if self._bus:
|
||||
self._bus.close()
|
||||
|
||||
Reference in New Issue
Block a user