How ale-giustina/e-ink-buddy works
Project Type and Purpose
• This is an embedded IoT firmware project (PlatformIO) for a microcontroller that fetches real-time transport and weather data, parses it, and renders it on an e-ink display.
• Key objectives:
• Fetch bus arrival times from the Trentino transport API
• Fetch multiple modes of weather data (24h, 5d, precipitation) from Open-Meteo
• Parse JSON responses
• Render text and graphs on an e-ink display
• Manage timing, Wi-Fi connectivity, and user input (buttons)
File Structure
• Top-level files:
• platformio.ini → build and deployment config
• Sample_calls/ → JSON examples for testing
• / directory: headers for each module:
• tr_api.h, weather.h → transport & weather fetch & parse
• graphics.h → drawing routines for e-ink
• helpers.h → utility functions (JSON helpers, debug)
• secrets_example.h → Wi-Fi credentials template
• src/ directory: implementation of each module and main.cpp
• lib/ and test/ directories for external libraries and tests
README for Additional Insights
• Defines main modules (tr_api, weather, graphics, helpers)
• Mentions timing/scheduler, resilient Wi-Fi error handling, and task manager
• Specifies features like state switching via buttons and buffer optimizations
Main Components
a. Hardware Layer
• Microcontroller (e.g., ESP32/ESP8266)
• E-ink Display (SPI interface)
• Button Inputs
• Wi-Fi Radio
b. Software Modules (on MCU)
• Task Scheduler / Timing Module (NTP sync)
• Wi-Fi & HTTP Client
• Transport API Module
• Weather API Module
• JSON Parser & Data Structures
• Graphics Renderer Module
• Helpers / Utility Module
• State Machine (handles button events and display modes)
c. External Services
• NTP Server (time synchronization)
• Trentino Transport REST API
• Open-Meteo Weather REST API
Relationships and Data Flows
• Scheduler triggers periodic tasks:
• NTP sync → sets system clock
• Transport fetch → HTTP GET → JSON → parse → store data
• Weather fetch → HTTP GET → JSON → parse → store data
• State Machine reads button events → selects display mode
• Graphics Renderer pulls parsed data → issues SPI drawing commands to e-ink
• Helpers provide logging/debugging hooks and common utilities
• Wi-Fi module underpins all external HTTP calls; error handler manages retries
Architectural Patterns and Design Principles
• Separation of concerns: networking vs. parsing vs. rendering
• Modular design: each API in its own module (tr_api, weather)
• Single-responsibility modules: helpers are generic utilities, graphics is purely rendering
• Task-driven loop or lightweight scheduler for periodic operations