Metadata-Version: 2.4
Name: fastpluggy-rpi-gpio
Version: 0.1.13
Summary: Raspberry Pi GPIO plugin for FastPluggy
Author: FastPluggy Team
License-Expression: MIT
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: FastPluggy>=0.4.115
Requires-Dist: RPi.GPIO>=0.7.0
Requires-Dist: gpiozero>=1.6.2
Provides-Extra: tests
Requires-Dist: pytest>=7.0; extra == "tests"
Requires-Dist: pytest-cov>=4.0; extra == "tests"
Provides-Extra: e2e
Requires-Dist: fastpluggy-cli; extra == "e2e"
Dynamic: license-file

# Raspberry Pi GPIO Plugin for FastPluggy

![RPi GPIO](https://img.shields.io/badge/FastPluggy-RPi%20GPIO-blue)
[![Release](https://gitlab.ggcorp.fr/open/fastpluggy/plugins/fastpluggy-rpi-gpio/-/badges/release.svg)](https://gitlab.ggcorp.fr/open/fastpluggy/plugins/fastpluggy-rpi-gpio/-/releases)
[![Pipeline Status](https://gitlab.ggcorp.fr/open/fastpluggy/plugins/fastpluggy-rpi-gpio/badges/main/pipeline.svg?key_text=CI)](https://gitlab.ggcorp.fr/open/fastpluggy/plugins/fastpluggy-rpi-gpio/-/pipelines?ignore_skipped=true)
[![Coverage](https://gitlab.ggcorp.fr/open/fastpluggy/plugins/fastpluggy-rpi-gpio/badges/main/coverage.svg)](https://gitlab.ggcorp.fr/open/fastpluggy/plugins/fastpluggy-rpi-gpio/-/pipelines)

This plugin provides an interface to control and monitor Raspberry Pi GPIO pins through the FastPluggy framework.

## Features

- [x] Control GPIO pins (set mode, read/write values)
- [x] Real-time monitoring of pin state changes
- [x] Web-based dashboard for visualizing and controlling GPIO pins
- [x] Configuration options for pin behavior

## Features Implemented

The following features have been fully implemented:

### GPIO Control
- GPIO pin mode control (input/output)
- GPIO pin value control (high/low)
- Support for all Raspberry Pi GPIO pins (BCM numbering)
- Error handling for invalid pins, modes, and values

### Real-time Monitoring
- WebSocket support for real-time pin state updates
- Configurable polling interval
- Automatic fallback to polling if WebSocket is not available

### Web Interface
- Interactive dashboard for visualizing pin states
- Pin details panel for controlling individual pins
- Settings page for configuring plugin behavior
- Real-time updates of pin states in the UI

### Configuration
- Default pin mode setting
- Polling interval configuration
- Interrupt-based monitoring toggle
- WebSocket notifications toggle

## Installation

1. Install the plugin:
   ```bash
   pip install fastpluggy-rpi-gpio
   ```

2. Enable the plugin in your FastPluggy configuration.

## Requirements

- Raspberry Pi hardware
- Python 3.8 or higher
- FastPluggy framework
- Need gcc

## Configuration

The plugin provides the following configuration options:

- `default_pin_mode`: Default mode for GPIO pins (input or output)
- `polling_interval_ms`: Interval in milliseconds for polling pin states
- `enable_interrupts`: Enable interrupt-based GPIO monitoring
- `enable_websocket_notifications`: Enable websocket notifications for pin state changes

## Usage

### Web Interface

The plugin provides a web interface with the following pages:

- **GPIO Dashboard**: Visualize and control GPIO pins
- **GPIO Settings**: Configure plugin settings

### API

The plugin provides the following API endpoints:

- `GET /gpio/api/pins`: Get the status of all GPIO pins
- `POST /gpio/api/pins/{pin_number}/mode`: Set the mode of a GPIO pin
- `POST /gpio/api/pins/{pin_number}/value`: Set the value of a GPIO pin

## Development

To set up the development environment:

1. Clone the repository
2. Install dependencies:
   ```bash
   pip install -e .
   ```

### Testing

Run the tests with pytest:

```bash
pytest
```

### CI/CD

This project supports both GitHub Actions and GitLab CI/CD for continuous integration and deployment:

#### GitHub Actions
- Tests are automatically run on multiple Python versions (3.8, 3.9, 3.10, 3.11)
- When a new tag is pushed (format: `v*`), the package is automatically built and published to PyPI
- The CI/CD pipeline is triggered only when changes are made to files in the plugin directory

#### GitLab CI/CD
- Tests are run on multiple Python versions (3.8, 3.9, 3.10, 3.11)
- Package is built and published to PyPI when a tag is pushed (format: `v*`)
- CI/CD pipeline includes caching for faster builds
- The pipeline is triggered only when changes are made to files in the plugin directory

## License


Released under the MIT License, see [LICENSE](LICENSE).
