A Flask-based web application for controlling Raspberry Pi GPIO pins to interact with a Aluprof DC313
- Clone/Download the project
- Create virtual environment
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
# Activate virtual environment
source venv/bin/activate
# Start the application
python3 main.pyThe application will:
- Start on
http://0.0.0.0:4000(accessible from local network) - Load previous state from
storage - Initialize GPIO (on Raspberry Pi) or run in simulation mode
- GET /state - Get current display state
- POST /sync - Manually sync state:
{"value": 5} - POST /actions - Execute commands:
[{"nr": 5, "action": "UP"}] - GET / - Web interface
Access the web interface at http://[raspberry-pi-ip]:4000 to:
- View current state
- Sync state manually
- Execute single or batch actions
- Monitor API responses
Edit src/config.py to modify:
- GPIO pin mappings
- Timing parameters
- Relay configuration (active high/low)
- Maximum display value
The application supports development mode:
- Automatically detects if running on non-Pi environment
- Simulates GPIO operations with console output
- All functionality works without actual GPIO hardware
Default BCM pin mapping:
- Pin 2: DECREASE (decrements display value)
- Pin 3: MOVE_UP (cursor movement)
- Pin 4: STOP (stop action)
- Pin 14: INCREASE (increments display value)
- Pin 15: GO_DOWN (cursor movement)
- Automatic GPIO cleanup on shutdown
- Thread-safe state management
- Error handling and validation
- Graceful fallback to simulation mode
- Persistent state across restarts