forked from platypush/platypush
Completed documentation for backends
This commit is contained in:
parent
8a0ca64e4d
commit
7398107570
13 changed files with 111 additions and 6 deletions
|
@ -22,4 +22,9 @@ Backends
|
|||
platypush/backend/redis.rst
|
||||
platypush/backend/scard.rst
|
||||
platypush/backend/sensor.rst
|
||||
platypush/backend/sensor.ir.zeroborg.rst
|
||||
platypush/backend/sensor.leap.rst
|
||||
platypush/backend/sensor.mcp3008.rst
|
||||
platypush/backend/sensor.serial.rst
|
||||
platypush/backend/weather.forecast.rst
|
||||
|
||||
|
|
6
docs/source/platypush/backend/sensor.ir.zeroborg.rst
Normal file
6
docs/source/platypush/backend/sensor.ir.zeroborg.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
``platypush.backend.sensor.ir.zeroborg``
|
||||
========================================
|
||||
|
||||
.. automodule:: platypush.backend.sensor.ir.zeroborg
|
||||
:members:
|
||||
|
7
docs/source/platypush/backend/sensor.leap.rst
Normal file
7
docs/source/platypush/backend/sensor.leap.rst
Normal file
|
@ -0,0 +1,7 @@
|
|||
``platypush.backend.sensor.leap``
|
||||
=================================
|
||||
|
||||
.. automodule:: platypush.backend.sensor.leap
|
||||
:members:
|
||||
|
||||
|
8
docs/source/platypush/backend/sensor.mcp3008.rst
Normal file
8
docs/source/platypush/backend/sensor.mcp3008.rst
Normal file
|
@ -0,0 +1,8 @@
|
|||
``platypush.backend.sensor.mcp3008``
|
||||
====================================
|
||||
|
||||
.. automodule:: platypush.backend.sensor.mcp3008
|
||||
:members:
|
||||
|
||||
|
||||
|
|
@ -4,4 +4,3 @@
|
|||
.. automodule:: platypush.backend.sensor
|
||||
:members:
|
||||
|
||||
|
||||
|
|
6
docs/source/platypush/backend/sensor.serial.rst
Normal file
6
docs/source/platypush/backend/sensor.serial.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
``platypush.backend.sensor.serial``
|
||||
===================================
|
||||
|
||||
.. automodule:: platypush.backend.sensor.serial
|
||||
:members:
|
||||
|
6
docs/source/platypush/backend/weather.forecast.rst
Normal file
6
docs/source/platypush/backend/weather.forecast.rst
Normal file
|
@ -0,0 +1,6 @@
|
|||
``platypush.backend.weather.forecast``
|
||||
======================================
|
||||
|
||||
.. automodule:: platypush.backend.weather.forecast
|
||||
:members:
|
||||
|
|
@ -7,6 +7,20 @@ from platypush.message.event.sensor.ir import IrKeyUpEvent, IrKeyDownEvent
|
|||
|
||||
|
||||
class SensorIrZeroborgBackend(Backend):
|
||||
"""
|
||||
This backend will read for events on the infrared sensor of a ZeroBorg
|
||||
(https://www.piborg.org/motor-control-1135/zeroborg) circuitry for
|
||||
Raspberry Pi. You can see the codes associated to an IR event from any
|
||||
remote by running the scan utility::
|
||||
|
||||
python -m platypush.backend.sensor.ir.zeroborg.scan
|
||||
|
||||
Triggers:
|
||||
|
||||
* :class:`platypush.message.event.sensor.ir.IrKeyDownEvent` when a key is pressed
|
||||
* :class:`platypush.message.event.sensor.ir.IrKeyUpEvent` when a key is released
|
||||
"""
|
||||
|
||||
last_message =None
|
||||
last_message_timestamp = None
|
||||
|
||||
|
@ -18,10 +32,6 @@ class SensorIrZeroborgBackend(Backend):
|
|||
self.logger.info('Initialized Zeroborg infrared sensor backend')
|
||||
|
||||
|
||||
def send_message(self, message):
|
||||
pass
|
||||
|
||||
|
||||
def run(self):
|
||||
super().run()
|
||||
|
||||
|
|
|
@ -20,6 +20,14 @@ class SensorLeapBackend(Backend):
|
|||
Also, you'll need the Leap driver and utils installed on your OS (follow
|
||||
instructions at https://www.leapmotion.com/setup/) and the `leapd` daemon
|
||||
running to recognize your controller.
|
||||
|
||||
Triggers:
|
||||
|
||||
* :class:`platypush.message.event.sensor.leap.LeapFrameEvent` when a new frame is received
|
||||
* :class:`platypush.message.event.sensor.leap.LeapFrameStartEvent` when a new sequence of frame starts
|
||||
* :class:`platypush.message.event.sensor.leap.LeapFrameStopEvent` when a sequence of frame stops
|
||||
* :class:`platypush.message.event.sensor.leap.LeapConnectEvent` when a Leap Motion device is connected
|
||||
* :class:`platypush.message.event.sensor.leap.LeapDisconnectEvent` when a Leap Motion device disconnects
|
||||
"""
|
||||
|
||||
def __init__(self,
|
||||
|
@ -30,6 +38,23 @@ class SensorLeapBackend(Backend):
|
|||
],
|
||||
position_tolerance=0.0, # Position variation tolerance in %
|
||||
*args, **kwargs):
|
||||
"""
|
||||
:param position_ranges: It specifies how wide the hand space (x, y and z axes) should be in millimiters.
|
||||
|
||||
Default::
|
||||
|
||||
[
|
||||
[-300.0, 300.0], # x axis
|
||||
[25.0, 600.0], # y axis
|
||||
[-300.0, 300.0], # z axis
|
||||
]
|
||||
|
||||
:type position_ranges: list[list[float]]
|
||||
|
||||
:param position_tolerance: % of change between a frame and the next to really consider the next frame as a new one (default: 0)
|
||||
:type position_tolerance: float
|
||||
"""
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.position_ranges = position_ranges
|
||||
|
|
|
@ -3,7 +3,18 @@ from platypush.context import get_plugin
|
|||
|
||||
|
||||
class SensorMcp3008Backend(SensorBackend):
|
||||
"""
|
||||
Backend to poll analog sensor values from an MCP3008 chipset
|
||||
(https://learn.adafruit.com/raspberry-pi-analog-to-digital-converters/mcp3008)
|
||||
|
||||
Requires:
|
||||
|
||||
* ``adafruit-mcp3008`` (``pip install adafruit-mcp3008``)
|
||||
* The :mod:`platypush.plugins.gpio.sensor.mcp3008` plugin configured
|
||||
"""
|
||||
|
||||
def get_measurement(self):
|
||||
""" get_measurement implementation """
|
||||
plugin = get_plugin('gpio.sensor.mcp3008')
|
||||
return plugin.get_data().output
|
||||
|
||||
|
|
|
@ -3,7 +3,17 @@ from platypush.context import get_plugin
|
|||
|
||||
|
||||
class SensorSerialBackend(SensorBackend):
|
||||
"""
|
||||
This backend listens for new events from sensors connected through a serial
|
||||
interface (like Arduino) acting as a wrapper for the ``serial`` plugin.
|
||||
|
||||
Requires:
|
||||
|
||||
* The :mod:`platypush.plugins.serial` plugin configured
|
||||
"""
|
||||
|
||||
def get_measurement(self):
|
||||
""" Implemnetation of ``get_measurement`` """
|
||||
plugin = get_plugin('serial')
|
||||
return plugin.get_data().output
|
||||
|
||||
|
|
|
@ -7,6 +7,18 @@ from platypush.message.event.weather import NewWeatherConditionEvent
|
|||
|
||||
|
||||
class WeatherForecastBackend(Backend):
|
||||
"""
|
||||
Weather forecast backend - listens and propagates new weather events.
|
||||
|
||||
Triggers:
|
||||
|
||||
* :class:`platypush.message.event.weather.NewWeatherConditionEvent` when there is a weather condition update
|
||||
|
||||
Requires:
|
||||
|
||||
* The :mod:`platypush.plugins.weather.forecast` plugin configured
|
||||
"""
|
||||
|
||||
def __init__(self, poll_seconds, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.poll_seconds = poll_seconds
|
||||
|
|
|
@ -11,7 +11,7 @@ from platypush.plugins import Plugin
|
|||
class CameraPiPlugin(Plugin):
|
||||
"""
|
||||
Plugin to control a Pi camera.
|
||||
It acts as a wrapper around the :ref:`platypush.backend.camera.pi` backend
|
||||
It acts as a wrapper around the :mod:`platypush.backend.camera.pi` backend
|
||||
to programmatically control the status.
|
||||
"""
|
||||
|
||||
|
|
Loading…
Reference in a new issue