How sampli1/e-mit works
Main Components
• Hardware/Platform: ESP32
• Operating System & Scheduler: FreeRTOS (used for multi-threading)
• Firmware Entry Point: The “main” directory (with main.cpp and its CMake configuration)
• Communication Subsystems:
• Client Component: Manages external API communications (including OAuth2, HTTPS in C and C++ located in components/client)
• Server Component: Implements the embedded HTTP server for configuration and static asset delivery (components/server)
• & Graphics:
• Screen Component: Handles rendering and updating the e-paper display (components/screen)
• Graphics Libraries: Adafruit-GFX (components/Adafruit-GFX) and CalEPD (components/CalEPD)
• Environment & Configuration:
• Environment Variable Handler: Reads and processes .env data (components/env_var)
• SPIFFS Storage: Stores assets and certificates required for HTTPS in the “spiffs” folder
• Additional Modules:
• Peripherals: Stub/placeholder for sensor handling (modules in components/peripherals)
• Utilities: Common helper functions and wrappers (components/utils)
Relationships and Data Flows
• The firmware (main) initializes the ESP32 hardware while configuring FreeRTOS for multi-threaded operation.
• The Display Subsystem (screen, augmented by Adafruit-GFX and CalEPD libraries) is responsible for drawing on the E-Paper based on data received.
• The Client module makes outbound HTTPS requests to external APIs. It handles OAuth2 authentication (via modules in the client directory) and drives data retrieval (such as weather and calendar events).
• The Server module provides a configuration interface (frontend built with HTML/CSS/JavaScript) that runs on the ESP32 to modify settings and view current configurations, reading from SPIFFS for assets.
• The Env_Var component reads configuration parameters from the .env file (generated via feth.py) and passes them to the various modules.
• The Utilities module provides shared functions (e.g., JSON parsing using jsmn, non-volatile storage (NVS) utilities, Wi-Fi handling) that are used across the project.
Architectural Patterns and Design Principles
• Separation of Concerns: There is a clear separation between hardware interfacing (screen, peripherals), network communication (client, server), and configuration management (env_var, SPIFFS).
• Layered Architecture: At the base, you have the hardware and operating system, and then layered software components for external communication, display logic, and support utilities.
• FreeRTOS/Multi-threading: Indicate that tasks are managed concurrently, with separate threads for handling HTTP client/server, display updates, and sensor data.
• Integration with External Services: Highlight that components like the client module interact with Google Calendar API, transit API (GTT), and possibly weather services.
Final Recommendations for the Principal Software Engineer
• Decompose this central module into the software components outlined (client, server, screen, env_var, utils, peripherals).
• Where FreeRTOS is responsible for orchestrating concurrent threads.
• Notes (or sidebar annotations) indicating integration points such as SPIFFS use, configuration files (like .env) management, and dependency on external libraries.