Created topic-based documentation: - basics.rst: core concepts and fundamental usage - cyclic_programming.rst: PLC-style programming with Cycletools - event_programming.rst: event-driven patterns and callbacks - advanced.rst: gateway IOs, replace_io_file, watchdog management - installation.rst and quickstart.rst: getting started guides Added complete API reference in docs/api/: - All device classes including ModularBaseConnect_4_5 and GatewayMixin - I/O, helper, and main class documentation Enhanced Sphinx configuration with RTD theme and improved autodoc settings. Removed auto-generated modules.rst and revpimodio2.rst.
2.7 KiB
API Reference
Complete API reference for RevPiModIO2 Python library.
Table of Contents
Overview
RevPiModIO provides several main classes for programming Revolution Pi hardware:
:class:`~revpimodio2.modio.RevPiModIO` - Main class for managing all devices and IOs
System Message: ERROR/3 (<stdin>, line 18); backlink
Unknown interpreted text role "class".
:class:`~revpimodio2.modio.RevPiModIOSelected` - Manage specific devices only
System Message: ERROR/3 (<stdin>, line 19); backlink
Unknown interpreted text role "class".
:class:`~revpimodio2.modio.RevPiModIODriver` - Write data to virtual device inputs
System Message: ERROR/3 (<stdin>, line 20); backlink
Unknown interpreted text role "class".
:class:`~revpimodio2.io.IOList` - Container for accessing IOs
System Message: ERROR/3 (<stdin>, line 21); backlink
Unknown interpreted text role "class".
:class:`~revpimodio2.io.IOBase` - Base class for all IO objects
System Message: ERROR/3 (<stdin>, line 22); backlink
Unknown interpreted text role "class".
:class:`~revpimodio2.helper.Cycletools` - Toolkit for cyclic programming
System Message: ERROR/3 (<stdin>, line 23); backlink
Unknown interpreted text role "class".
:class:`~revpimodio2.helper.EventCallback` - Event handler class
System Message: ERROR/3 (<stdin>, line 24); backlink
Unknown interpreted text role "class".
Quick Examples
Basic Usage
import revpimodio2 # Initialize rpi = revpimodio2.RevPiModIO(autorefresh=True) # Read input and control output if rpi.io.button.value: rpi.io.led.value = True # Cleanup rpi.exit()
Cyclic Programming
import revpimodio2 rpi = revpimodio2.RevPiModIO(autorefresh=True) def main_cycle(ct: revpimodio2.Cycletools): if ct.first: ct.var.counter = 0 if ct.changed(ct.io.sensor): ct.var.counter += 1 rpi.cycleloop(main_cycle)
Event-Driven Programming
import revpimodio2 rpi = revpimodio2.RevPiModIO(autorefresh=True) def on_change(ioname, iovalue): print(f"{ioname} = {iovalue}") rpi.io.button.reg_event(on_change) rpi.handlesignalend() rpi.mainloop()
Constants
Edge Detection
System Message: ERROR/3 (<stdin>, line 86)
Unknown directive type "py:data".
.. py:data:: revpimodio2.RISING :type: int Detect low-to-high transitions
System Message: ERROR/3 (<stdin>, line 91)
Unknown directive type "py:data".
.. py:data:: revpimodio2.FALLING :type: int Detect high-to-low transitions
System Message: ERROR/3 (<stdin>, line 96)
Unknown directive type "py:data".
.. py:data:: revpimodio2.BOTH :type: int Detect any transition
LED Colors
System Message: ERROR/3 (<stdin>, line 104)
Unknown directive type "py:data".
.. py:data:: revpimodio2.OFF :type: int LED off
System Message: ERROR/3 (<stdin>, line 109)
Unknown directive type "py:data".
.. py:data:: revpimodio2.GREEN :type: int Green LED
System Message: ERROR/3 (<stdin>, line 114)
Unknown directive type "py:data".
.. py:data:: revpimodio2.RED :type: int Red LED
IO Types
System Message: ERROR/3 (<stdin>, line 122)
Unknown directive type "py:data".
.. py:data:: INP :type: int :value: 300 Input type
System Message: ERROR/3 (<stdin>, line 128)
Unknown directive type "py:data".
.. py:data:: OUT :type: int :value: 301 Output type
System Message: ERROR/3 (<stdin>, line 134)
Unknown directive type "py:data".
.. py:data:: MEM :type: int :value: 302 Memory type
See Also
:doc:`../installation` - Installation guide
System Message: ERROR/3 (<stdin>, line 143); backlink
Unknown interpreted text role "doc".
:doc:`../quickstart` - Quick start guide
System Message: ERROR/3 (<stdin>, line 144); backlink
Unknown interpreted text role "doc".
:doc:`../basics` - Core concepts
System Message: ERROR/3 (<stdin>, line 145); backlink
Unknown interpreted text role "doc".
:doc:`../cyclic_programming` - Cyclic programming patterns
System Message: ERROR/3 (<stdin>, line 146); backlink
Unknown interpreted text role "doc".
:doc:`../event_programming` - Event-driven programming patterns
System Message: ERROR/3 (<stdin>, line 147); backlink
Unknown interpreted text role "doc".
:doc:`../advanced` - Advanced topics
System Message: ERROR/3 (<stdin>, line 148); backlink
Unknown interpreted text role "doc".