# m5stack/m5paper_factorytest architecture

> Architecture diagram of the GitHub repository m5stack/m5paper_factorytest, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/m5stack/m5paper_factorytest
- Repository: https://github.com/m5stack/m5paper_factorytest

## Overview

##### Project type and purpose
- This is an embedded-firmware project (“M5Paper_FactoryTest”) written in C++/Arduino using PlatformIO.
- It targets the M5Paper e-paper hardware (an ESP32-based device with an e-ink display) and implements a factory-test GUI with multiple screens (“frames”).

##### File structure
- Top-level files:
- platformio.ini     → build/deployment config for PlatformIO
- README.md          → project description
- M5Paper_FactoryTest.ino → entry point for Arduino compatibility
- src/
- main.cpp          → app entry, system initialization, main loop
- systeminit.*      → hardware and peripheral setup (Wi-Fi, display, storage)
- global_setting.*  → persistent settings (language, wallpaper, etc.)
- epdgui/           → GUI library: widgets (buttons, switches, textboxes), base classes
- frame/            → screen controllers: each frame_*.cpp/.h implements a test or UI screen
- resources/        → binary resources: fonts, images
- / and lib/   → third-party or shared libraries and headers
- Configuration: .travis.yml, .gitignore, .gitattributes for CI and VCS

##### README for additional insights
- Sparse README—no architecture drawn, but mentions “PlatformIO Project for M5Paper.”
- The filenames imply a widget/UI layer (epdgui) and a set of “frame” modules each representing a screen in the factory test suite.

##### Elements
– Clear labels: name each module (systeminit, epdgui, frame_factorytest, etc.)

##### Final advice
- Persistence: show connection to flash/SPIFFS for settings and resources.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Hardware Layer
    subgraph "Hardware" 
        style Hardware fill:#eeeeee,stroke:#888,stroke-width:1px
        ESP32["ESP32 MCU"]:::hardware
        EInk["E-Ink Display"]:::hardware
        Buttons["Buttons/Touch"]:::hardware
        Storage["SPIFFS/SD Card"]:::hardware
        WiFi["Wi-Fi Module"]:::hardware
    end

    %% Firmware Layers
    subgraph "Firmware"
        style Firmware fill:none,stroke:#444,stroke-width:1px

        subgraph "Hardware Abstraction" 
            style Hardware_Abstraction fill:#bbdefb,stroke:#444
            SysInit["systeminit"]:::init
        end

        subgraph "Core Services"
            style Core_Services fill:#dcedc8,stroke:#444
            GlobalSetting["global_setting"]:::service
            ResourceMgr["Resource Manager"]:::service
        end

        subgraph "GUI Framework"
            style GUI_Framework fill:#ffe082,stroke:#444
            EPDGUI["epdgui"]:::gui
        end

        subgraph "Application Screens"
            style App_Screens fill:#ffcc80,stroke:#444
            FrameBase["frame_base"]:::app
            FrameCompare["frame_compare"]:::app
            FrameFactory["frame_factorytest"]:::app
            FrameFileIndex["frame_fileindex"]:::app
            FrameHome["frame_home"]:::app
            FrameKeyboard["frame_keyboard"]:::app
            FrameLifeGame["frame_lifegame"]:::app
            FrameMain["frame_main"]:::app
            FramePicViewer["frame_pictureviewer"]:::app
            FrameSetting["frame_setting"]:::app
            FrameLang["frame_setting_language"]:::app
            FrameWall["frame_setting_wallpaper"]:::app
            FrameTxt["frame_txtreader"]:::app
            FrameWiFiPass["frame_wifipassword"]:::app
            FrameWiFiScan["frame_wifiscan"]:::app
        end

        Main["main.cpp"]:::init
        Entry["M5Paper_FactoryTest.ino"]:::init
    end

    %% Build / Toolchain
    subgraph "Build & CI" 
        style Build fill:#f0f0f0,stroke:#888
        PIO["platformio.ini"]:::build
        Include["include/"]:::build
        Lib["lib/"]:::build
        Travis[".travis.yml"]:::build
        GitIgnore[".gitignore"]:::build
        Gitattributes[".gitattributes"]:::build
    end

    %% Connections
    Entry -->|"compiles"| Main
    Main -->|"init"| SysInit
    SysInit --> ESP32
    ESP32 --> EInk
    ESP32 --> Buttons
    ESP32 --> Storage
    ESP32 --> WiFi

    Main -->|"dispatch"| FrameMain
    FrameMain -->|"init frames"| FrameBase
    FrameBase --> FrameCompare
    FrameBase --> FrameFactory
    FrameBase --> FrameFileIndex
    FrameBase --> FrameHome
    FrameBase --> FrameKeyboard
    FrameBase --> FrameLifeGame
    FrameBase --> FramePicViewer
    FrameBase --> FrameSetting
    FrameSetting --> FrameLang
    FrameSetting --> FrameWall
    FrameBase --> FrameTxt
    FrameBase --> FrameWiFiScan
    FrameBase --> FrameWiFiPass

    FrameBase -->|"uses GUI"| EPDGUI
    EPDGUI -->|"draw"| EInk
    FrameBase -->|"load resource"| ResourceMgr
    ResourceMgr --> Storage

    FrameBase <-->|"read/write"| GlobalSetting
    GlobalSetting --> Storage

    Main --> PIO
    PIO --> Include
    PIO --> Lib
    PIO --> Travis
    PIO --> GitIgnore
    PIO --> Gitattributes

    %% Click Events
    click Entry "https://github.com/m5stack/m5paper_factorytest/blob/main/M5Paper_FactoryTest.ino"
    click PIO "https://github.com/m5stack/m5paper_factorytest/blob/main/platformio.ini"
    click Main "https://github.com/m5stack/m5paper_factorytest/blob/main/src/main.cpp"
    click SysInit "https://github.com/m5stack/m5paper_factorytest/blob/main/src/systeminit.cpp"
    click SysInit "https://github.com/m5stack/m5paper_factorytest/blob/main/src/systeminit.h"
    click GlobalSetting "https://github.com/m5stack/m5paper_factorytest/blob/main/src/global_setting.cpp"
    click GlobalSetting "https://github.com/m5stack/m5paper_factorytest/blob/main/src/global_setting.h"
    click EPDGUI "https://github.com/m5stack/m5paper_factorytest/tree/main/src/epdgui/"
    click FrameBase "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_base.cpp"
    click FrameBase "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_base.h"
    click FrameCompare "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_compare.cpp"
    click FrameCompare "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_compare.h"
    click FrameFactory "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_factorytest.cpp"
    click FrameFactory "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_factorytest.h"
    click FrameFileIndex "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_fileindex.cpp"
    click FrameFileIndex "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_fileindex.h"
    click FrameHome "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_home.cpp"
    click FrameHome "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_home.h"
    click FrameKeyboard "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_keyboard.cpp"
    click FrameKeyboard "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_keyboard.h"
    click FrameLifeGame "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_lifegame.cpp"
    click FrameLifeGame "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_lifegame.h"
    click FrameMain "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_main.cpp"
    click FrameMain "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_main.h"
    click FramePicViewer "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_pictureviewer.cpp"
    click FramePicViewer "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_pictureviewer.h"
    click FrameSetting "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_setting.cpp"
    click FrameSetting "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_setting.h"
    click FrameLang "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_setting_language.cpp"
    click FrameLang "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_setting_language.h"
    click FrameWall "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_setting_wallpaper.cpp"
    click FrameWall "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_setting_wallpaper.h"
    click FrameTxt "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_txtreader.cpp"
    click FrameTxt "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_txtreader.h"
    click FrameWiFiPass "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_wifipassword.cpp"
    click FrameWiFiPass "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_wifipassword.h"
    click FrameWiFiScan "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_wifiscan.cpp"
    click FrameWiFiScan "https://github.com/m5stack/m5paper_factorytest/blob/main/src/frame/frame_wifiscan.h"
    click ResourceMgr "https://github.com/m5stack/m5paper_factorytest/tree/main/src/resources/"
    click Include "https://github.com/m5stack/m5paper_factorytest/tree/main/include/"
    click Lib "https://github.com/m5stack/m5paper_factorytest/tree/main/lib/"
    click Travis "https://github.com/m5stack/m5paper_factorytest/blob/main/.travis.yml"
    click GitIgnore "https://github.com/m5stack/m5paper_factorytest/blob/main/.gitignore"
    click Gitattributes "https://github.com/m5stack/m5paper_factorytest/blob/main/.gitattributes"

    %% Styles
    classDef hardware fill:#dddddd,stroke:#666,stroke-width:1px;
    classDef init fill:#bbdefb,stroke:#444,stroke-width:1px;
    classDef service fill:#dcedc8,stroke:#444,stroke-width:1px;
    classDef gui fill:#ffe082,stroke:#444,stroke-width:1px;
    classDef app fill:#ffcc80,stroke:#444,stroke-width:1px;
    classDef build fill:#f0f0f0,stroke:#888,stroke-dasharray: 5 5;
```
