class platypush.plugins.sensor.pmw3901.Rotation(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: IntEnum

Enumerates the possible rotations of the sensor.

class platypush.plugins.sensor.pmw3901.SPISlot(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#

Bases: Enum

Enumeration for the possible SPI slot positions of the sensor on the Breakout Garden (front or back).

class platypush.plugins.sensor.pmw3901.SensorPmw3901Plugin(*_, **__)[source]#

Bases: SensorPlugin

Plugin to interact with an PMW3901 optical flow and motion sensor


  • pmw3901 (pip install pmw3901)


__init__(rotation=0, spi_slot='front', spi_port=0, poll_interval=0.01, **kwargs)[source]#
  • rotation (int) – Rotation angle for the captured optical flow. Possible options: 0, 90, 180, 270 (default: 0)

  • spi_slot (int) – SPI slot where the sensor is connected if you’re using a Breakout Garden interface. Possible options: ‘front’, ‘back’ (default: ‘front’)

  • spi_port – SPI port (default: 0)

get_measurement(*_, **__)[source]#

dict. Example:

output = {
    "motion_x": 3,   # Detected motion vector X-coord
    "motion_y": 4,   # Detected motion vector Y-coord
    "motion_mod": 5  # Detected motion vector module
    "motion_events_per_sec": 7  # Number of motion events detected in the last second
transform_entities(entities: Dict[str, int | float]) List[Device][source]#

This method takes a list of entities in any (plugin-specific) format and converts them into a standardized collection of Entity objects. Since this method is called by publish_entities() before entity updates are published, you may usually want to extend it to pre-process the entities managed by your extension into the standard format before they are stored and published to all the consumers.