This project provides a FastAPI server to interact with an e-ink display, enabling the display of images, text, weather forecasts, quotes, and QR codes for Wi-Fi and SSH access. It is designed for Raspberry Pi or similar hardware with an e-ink display, requiring an OPEN_WEATHER_API key for weather functionality.
- Image Display: Render images from local storage or uploaded files on the e-ink display.
- Text Rendering: Display customizable text with specified position, size, color, and centering.
- Weather Forecasts: Fetch and display weather data using OpenWeatherMap API, with visual forecast images.
- Daily Quotes: Retrieve and display inspirational quotes from ZenQuotes API.
- QR Code Generation: Generate QR codes for Wi-Fi credentials or SSH public keys.
- IP Address Display: Show the device’s IP address as text on the display.
- RESTful API: Control the display via HTTP GET and POST requests.
- Clear and Reset: Initialize, clear, or reset the display with optional sleep mode.
-
Clone the Repository:
git clone https://github.com/dazemc/ink_manager.git cd ink_manager -
Set Up using uv (recommended):
uv sync
-
Configure Environment Variables:
- Set the
OPEN_WEATHER_APIkey for weather functionality in .env:OPEN_WEATHER_API='your_openweathermap_api_key' - Obtain a free API key from OpenWeatherMap.
- Set the
-
Run the Server:
./start.sh
- Access the API at
http://<device-ip>:8000.
- Access the API at
Check uv.lock for full dependency list and versions.
- Description: Home endpoint.
- Response:
"Nothing here yet".
- Description: Runs a test sequence: displays an image, draws text ("hello", "world", "goodbye world") with lines, and clears the display.
- Response:
"Success".
- Description: Renders text on the display with customizable parameters.
- Request Body (JSON, using
Textmodel):text(str): Text to display.color(str): Hex color code (e.g.,"FF0000"for red).pos(str): Position asx,y(e.g.,"10,20").size(int): Font size in points.center(bool): Center the text iftrue.
- Example:
curl -X POST "http://<device-ip>:8000/text" -H "Content-Type: application/json" -d '{"text":"Hello","color":"FF0000","pos":"5,0","size":24,"center":false}'
- Response:
"Success".
- Description: Displays the current drawing on the e-ink screen.
- Response:
"Success".
- Description: Resets the display to a blank image.
- Response:
"Success".
- Description: Displays the device’s IP address on the screen, fetched via
get_ip.sh. - Response: IP address as a string (e.g.,
"192.168.1.100").
- Description: Uploads an image file, converts it to BMP, and displays it.
- Request: Multipart form-data with a file.
- Example:
curl -X POST "http://<device-ip>:8000/upload_image" -F "file=@/path/to/image.jpg"
- Response: JSON with
{"filename": "<filename>", "message": "File uploaded and displaying"}.
- Description: Fetches weather data via OpenWeatherMap and displays a forecast image.
- Weather Icons: See OpenWeatherMap Icon List.
- Response:
"Success".
- Description: Clears the display and optionally puts it to sleep.
- Query Parameters:
sleep(bool, default:true): Iftrue, puts the display to sleep.
- Example:
curl "http://<device-ip>:8000/clear?sleep=false" - Response:
"Success".
- Description: Fetches a daily quote from ZenQuotes API and displays it with the author.
- Response:
"Success".
- Description: Generates and displays a QR code for Wi-Fi credentials (SSID and PSK) using
iwgetidandget_psk.sh. - Notes: Requires plaintext PSK in Wi-Fi configuration (Raspberry Pi Imager’s hashed PSK won’t work).
- Response:
"Success".
- Description: Generates and displays a QR code for the SSH public key from
/home/daze/.ssh/id_rsa.pub. - Response:
"Success".
- Environment Variables:
OPEN_WEATHER_API: Required for/update_weather. Sign up at OpenWeatherMap.
- Logging: Configured via
logging.json. SetDEBUG = Trueinapp.pyfor verbose logs. - Fonts: Uses
Inktype.ttfin./assets/fonts/. - Uploads: Stores uploaded images in
./assets/images/uploads/.
app.py: Main FastAPI application.assets/:images/: Test images, weather forecasts, and uploads.fonts/: Font files (e.g.,Inktype.ttf).scripts/: Shell scripts (e.g.,get_ip.sh,get_psk.sh).
logging.json: Logging configuration.requirements.txt: Python dependencies.InkDisplay.py: Custom e-ink display library (not included; ensure compatibility).WeatherData.py: Custom weather data library.utils.py: Helper functions (e.g.,center_text).
- Logs are output to the console and configured via
logging.json. - Enable
DEBUG = Trueinapp.pyfor detailed logging of API requests, errors, and operations.
- E-Ink Hardware: Ensure your e-ink display is compatible with the
ink_displaylibrary. Follow hardware-specific setup instructions (e.g., Waveshare e-Paper). - Wi-Fi QR Code: The
/qr-code/wifiendpoint requires a plaintext PSK in/etc/wpa_supplicant/wpa_supplicant.conf. If using Raspberry Pi Imager, manually set the PSK to avoid hashing. - SSH QR Code: Ensure
/home/daze/.ssh/id_rsa.pubexists for/qr-code/ssh. - Performance: E-ink displays are slow to refresh. Endpoints include sleep calls to manage power and refresh cycles.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch (
git checkout -b feature/YourFeature). - Commit changes (
git commit -m 'Add YourFeature'). - Push to the branch (
git push origin feature/YourFeature). - Open a pull request.
Please open an issue to discuss proposed changes or report bugs.
For questions or support, open an issue on the GitHub repository.