A Flask-based web application designed for creating and managing pixel art, specifically optimized for driving WS2812 LED matrices via an ESP32 microcontroller.
- Web-based Drawing Interface: Create pixel art on a custom grid (default 32x16).
- User Authentication: Secure registration and login system.
- Display Configuration: Support for multiple display sizes via
displays.json. - Image Management:
- Save drawings as BMP files.
- Upload existing images (automatically converted to BMP).
- Manage uploaded images.
- ESP32 Integration:
- API endpoint optimized for microcontrollers (
/api/image/<id>/rgb). - Returns pixel data in a simple JSON format.
- API endpoint optimized for microcontrollers (
-
Clone the repository:
git clone <repository-url> cd fpac
-
Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Start the application:
python app.py
The server will start on
http://0.0.0.0:5000by default. -
Open your web browser and navigate to
http://localhost:5000. -
Register a new account or log in if you already have one.
-
Use the "Draw" page to create pixel art or "Upload" to add existing images.
Display configurations are stored in displays.json. You can modify this file to match your LED matrix setup.
Example displays.json:
[
{
"name": "Standard 32x16",
"width": 32,
"height": 16,
"max_width": 64,
"max_height": 32
}
]The application exposes several API endpoints for integration with external devices like ESP32.
Endpoint: GET /api/images
Returns a list of all available images with metadata.
Response Example:
{
"images": [
{
"id": 1,
"filename": "drawing_1_1623456789.bmp",
"width": 32,
"height": 16,
"url": "http://localhost:5000/static/uploads/drawing_1_1623456789.bmp",
"display_name": "Standard 32x16",
"scroll_direction": "none",
"scroll_speed": 0
}
]
}Endpoint: GET /api/image/<id>/rgb
Returns the pixel data for a specific image in a format easy to process by microcontrollers, including scrolling information.
Response Example:
{
"width": 32,
"height": 16,
"display_name": "Standard 32x16",
"scroll_direction": "none",
"scroll_speed": 0,
"pixels": [
[255, 0, 0], [0, 255, 0], [0, 0, 255], ...
]
}Each pixel is represented as an array of [Red, Green, Blue] values (0-255).
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request