Slot enum mapping fix

This commit is contained in:
Fabio Manganiello 2019-09-23 23:48:26 +02:00
parent f76e45dda9
commit 63d222d2ee

View file

@ -16,7 +16,7 @@ class Rotation(enum.IntEnum):
class SPISlot(enum.Enum): class SPISlot(enum.Enum):
FRONT = 'front', FRONT = 'front'
BACK = 'back' BACK = 'back'
@ -59,7 +59,10 @@ class GpioSensorMotionPwm3901Plugin(GpioSensorPlugin):
if isinstance(spi_slot, str): if isinstance(spi_slot, str):
spi_slot = [s for s in SPISlot if s.value == spi_slot][0] spi_slot = [s for s in SPISlot if s.value == spi_slot][0]
self.spi_slot = BG_CS_FRONT_BCM if spi_slot == SPISlot.FRONT else BG_CS_BACK_BCM if spi_slot == SPISlot.FRONT:
self.spi_slot = BG_CS_FRONT_BCM
else:
self.spi_slot = BG_CS_BACK_BCM
except IndexError: except IndexError:
raise ValueError('{} is not a valid value for spi_slot - possible values: {}'.format( raise ValueError('{} is not a valid value for spi_slot - possible values: {}'.format(
spi_slot, [s.value for s in SPISlot])) spi_slot, [s.value for s in SPISlot]))