How lds133/weather_landscape works
Project Type and Purpose
• This project is a hybrid full-stack system that combines image generation (using Python and Pillow) with an embedded hardware component (ESP32 controlling an E-Ink display).
• Its purpose is to retrieve weather data from OpenWeather, encode weather conditions as landscape imagery, and then display the weather information in a calming, intuitive visual format.
Main Components
A. Weather Image Generation (Python Application)
• p_weather Module: Includes components (like draw_weather.py, openweathermap.py, and sprites) that:
• Query weather data from the OpenWeather API.
• Process the data and map weather parameters to specific visual elements in the landscape.
• Use a template and sprite images to compose the final BMP image.
• run_test.py: For testing the image generation.
• run_server.py: Likely serving the image generation functionality in a continuous server mode.
• requirements.txt & environment scripts (makevenv.bat/sh): Define the environment and dependencies.
B. Hardware Integration (ESP32 Module)
• esp32 Directory: Contains MicroPython code targeted for the ESP32 board.
• The board subdirectory includes files like boot.py, main.py, and various utility modules (wifi.py, eink.py, led.py, etc.) that manage:
▫ Board-specific configurations.
▫ E-Ink display control.
▫ Peripheral interfaces such as WiFi and LED controls.
• The “esp32/pic” folder with test bitmap files is used for hardware testing.
• README.md within the ESP32 folder provides additional hardware-focused instructions.
C. External Dependencies and Data Flow
• OpenWeather API: An external service providing weather forecast data.
• Pillow Library: Used for image processing and drawing.
• The final BMP image is distributed to the E-Ink display via the ESP32. Data is exchanged between the weather image generator and the hardware component – either by serving an image via run_server.py or by storing the file on disk for ESP32 retrieval.
Component Relationships and Data Flow
• The p_weather image generation logic processes this data using Pillow and sprite assets to create the BMP image; this is tested by run_test.py and/or served by run_server.py.
• A connection is established (or in planned design, to be established) between this generation layer and the ESP32 hardware. The ESP32 code (in esp32/board) then retrieves the image – either through a direct network call to the local server or via file transfer – and displays it on the connected 2.9-inch E-Ink screen.
• Configuration values, like API keys and geographic coordinates, are maintained in secrets.py.
Architectural Patterns and Technologies
• Modular Design: Separation of concerns between image generation and hardware display.
• Client-Server Pattern: The image generator can run as a server (using run_server.py) and may serve images to the ESP32 device.
• Use of MicroPython on the ESP32 for lightweight, embedded control.
• Utilization of third-party libraries, such as Pillow, for handling image processing.
• Software back-end and image processing
• Hardware and embedded systems.
b. Label Components Clearly:
• Under the Software section, include components like:
▫ Weather Image Generator (with modules p_weather, run_test.py, run_server.py)
▫ External Weather Data (OpenWeather API)
• Under the Hardware section, detail:
▫ ESP32 Microcontroller (with its board-specific MicroPython scripts: boot.py, main.py, etc.)
▫ E-Ink Display Module
• Image processing flow from p_weather through to the output BMP file.
e. Build/Deployment Tools:
• Environment preparation (makevenv scripts, requirements.txt) and testing steps (run_test.py) as peripheral elements in the design.