# titaniumc-wwt/3.7inch-eink architecture

> Architecture diagram of the GitHub repository titaniumc-wwt/3.7inch-eink, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/titaniumc-wwt/3.7inch-eink
- Repository: https://github.com/titaniumc-wwt/3.7inch-eink

## Overview

##### Project Type and Core Purpose
- This is an embedded hardware project centered around a handheld electronic book device. It combines hardware design (PCB, 3D printed parts, BOM) with embedded firmware development (code for ESP32, display drivers, sensor interfacing).
- The README details that the device includes an ESP32 (WROOM32UE), an e-ink display, audio amplifier, clock chip (RX8025), temperature/humidity sensor (SHT30), and user input (physical buttons).

##### File Structure to Determine Key Modules
- There are separate directories for:
– PCB and 3D printing files (“PCB_Make_Dir” and “3D_PrintFile”) that represent the physical hardware design.
– Source code (“Code” folder and the compressed archive Code.7z) which contains the firmware (main.cpp, peripheral headers like WifiConnect.h, SDcardcontrol.h, and display fonts/assets).
– Additional ZIP files that bundle PCB design (Altium files, ProProject...) and hardware libraries (mhetesp32devkit.7z).
- The presence of BOM.xlsx reinforces the details of component selection, vital for the hardware sub-architecture.

##### Out the Main Components
a. Hardware Platform:
– ESP32 WROOM32UE: The central microcontroller managing device logic.
– Peripheral Circuits: Include audio (MAX98357 amplifier and the 1511 speaker), clock (RX8025T), environmental sensor (SHT30), e-ink display (OKRA 3.7-inch black/white), battery management (TP4055 with battery), and user input (three physical buttons).
b. Firmware/Software:
– Main application code (main.cpp) which orchestrates system behavior.
– Peripheral driver modules (captured in files like SDcardcontrol.h, WifiConnect.h) that facilitate hardware interfacing.
– Graphics and font rendering (referenced from _u8g2_font_wqy15_t_gb2312.c and img.h).
c. Supporting Assets:
– PCB design files (from PCB_Make_Dir, Altium zip) and 3D printing files for the casing.
– BOM that acts as a blueprint for component selection and physical layout.

##### Relationships and Interactions in the Architecture
– Data/control lines to the e-ink display (graphics update, refresh signals).
– Audio controls feeding into the MAX98357 amplifier and out to the speaker.
– Communication with the RX8025T RTC module for timekeeping.
– Sensor data reading from the SHT30.
– Battery management circuits and charging module communications (TP4055, battery status).
– Physical input devices (the three buttons) interacting with the ESP32.
- Additionally, denote how the firmware components interact with these hardware interfaces. For example, illustrate that main.cpp calls routines in WifiConnect.h (if WiFi features are used), SDcardcontrol.h (for storage access), and display routines linked to the graphics library.

##### Architectural Patterns and Design Principles
– Physical hardware components versus the firmware software stack.
– Modular design of the code (how drivers and main application logic are separated).
- Design choices that optimize power (long standby in clock mode) and the integration of multiple roles (ebook display, audio playback, sensor monitoring).

##### Detailed Elements
- For the firmware side, include modules such as a “Display Driver,” “Audio Module,” “Sensor and RTC Controller,” and “System Manager/Main Loop.”
- External files and design documents (PCB designs, 3D printing files, BOM) as ancillary documentation modules or layers that support the physical assembly.

– Begin by outlining the overall project: a small handheld eBook device combining embedded hardware with firmware functions.
– Detail every major hardware module (ESP32, display, sensors, audio, power management, input) and map out the firmware layers/modules contained in the Code directory.
– Separate hardware and software, but also illustrate how design files (PCB, 3D printing) and BOM contribute to the system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Components
    subgraph "Hardware Components"
        direction TB
        ESP32["ESP32 Module"]:::hardware
        Display["E-ink Display"]:::hardware
        Audio["Audio Circuit (MAX98357 & Speaker)"]:::hardware
        RTC["Clock Chip (RX8025T)"]:::hardware
        Sensor["Env Sensor (SHT30)"]:::hardware
        Battery["Battery & Charging (TP4055)"]:::hardware
        Buttons["Physical Buttons"]:::hardware
    end

    %% Firmware Modules
    subgraph "Firmware Modules"
        direction TB
        MainApp["Main Application (main.cpp)"]:::firmware
        Wifi["WiFi Driver (WifiConnect)"]:::firmware
        SDCard["SD Card Driver (SDcardcontrol)"]:::firmware
        RTC_Drv["RTC Driver (RX8025)"]:::firmware
        DisplayDrv["Display Driver & Font Rendering"]:::firmware
        OtherHdr["Additional Headers (GB2312 etc.)"]:::firmware
    end

    %% Documentation & Assets
    subgraph "Documentation & Assets"
        direction TB
        subgraph "Hardware Assets"
            PCB["PCB Design Files"]:::documentation
            PrintFiles["3D Printing Files"]:::documentation
            BOMNode["BOM.xlsx"]:::documentation
            AltiumNode["Altium Design Archive"]:::documentation
            ProProjectNode["ProProject Archive"]:::documentation
            DevKitNode["Hardware Dev Kit Archive"]:::documentation
            CodeArchiveNode["Firmware Code Archive (Code.7z)"]:::documentation
        end
        subgraph "Firmware Assets"
            MainCpp["main.cpp"]:::documentation
            RX8025["RX8025.h"]:::documentation
            SDcardCtrl["SDcardcontrol.h"]:::documentation
            WifiNode["WifiConnect.h"]:::documentation
            FontNode["Font Rendering (_u8g2_font_wqy15_t_gb2312.c)"]:::documentation
            ImgNode["Image Asset (img.h)"]:::documentation
            GB2312Node["GB2312.h"]:::documentation
            FirmwareReadme["Firmware README (Code/README.md)"]:::documentation
            RootReadme["Root README"]:::documentation
        end
    end

    %% Interconnections within Hardware
    ESP32 -->|"controls"| Display
    ESP32 -->|"controls"| Audio
    ESP32 -->|"syncs_with"| RTC
    ESP32 -->|"reads"| Sensor
    ESP32 -->|"monitors"| Battery
    ESP32 -->|"reads_from"| Buttons

    %% Interconnections within Firmware
    MainApp -->|"calls"| Wifi
    MainApp -->|"calls"| SDCard
    MainApp -->|"calls"| DisplayDrv
    MainApp -->|"calls"| RTC_Drv
    MainApp -->|"includes"| OtherHdr

    %% Interaction between Firmware and Hardware
    MainApp -->|"runs_on"| ESP32

    %% Styles
    classDef hardware fill:#f9c,stroke:#333,stroke-width:2px;
    classDef firmware fill:#ccf,stroke:#333,stroke-width:2px;
    classDef documentation fill:#cfc,stroke:#333,stroke-width:2px;

    %% Click Events for Hardware Assets
    click PCB "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/PCB_Make_Dir/3.7寸墨水屏Geber.zip"
    click PrintFiles "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/3D_PrintFile/家庭打印机食用.7z"
    
    %% Click Events for Supporting Documentation
    click BOMNode "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/BOM.xlsx"
    click AltiumNode "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/Altium_3.7寸墨水屏 音频 小说 温湿度 ESP32_2023-06-24.zip"
    click ProProjectNode "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/ProProject_3.7寸墨水屏 音频 小说 温湿度 ESP32_2023-06-24.zip"
    click DevKitNode "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/mhetesp32devkit.7z"
    click CodeArchiveNode "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/Code.7z"

    %% Click Events for Firmware Assets
    click MainCpp "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/Code/main.cpp"
    click RX8025 "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/Code/RX8025.h"
    click SDcardCtrl "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/Code/SDcardcontrol.h"
    click WifiNode "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/Code/WifiConnect.h"
    click FontNode "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/Code/_u8g2_font_wqy15_t_gb2312.c"
    click ImgNode "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/Code/img.h"
    click GB2312Node "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/Code/GB2312.h"
    click FirmwareReadme "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/Code/README.md"
    click RootReadme "https://github.com/titaniumc-wwt/3.7inch-eink/blob/main/README.md"
```
