# gyverlibs/gyveroled architecture

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

- Interactive diagram: https://gitdiagram.com/gyverlibs/gyveroled
- Repository: https://github.com/gyverlibs/gyveroled

## Overview

##### Project Type and Purpose
- This project is an Arduino library called “GyverOLED” designed for driving OLED displays. The library supports multiple OLED models (SSD1306, SSH1106) and connection protocols (I2C and SPI). It provides a suite of drawing routines (for text, graphics, images, etc.), buffer management options, and various display manipulation features.
- The examples include Arduino sketches (.ino files) that demonstrate usage of the library functions, and there’s an “Image converter” to help generate the bitmaps for display.

##### Analyzing the File Structure
- Top-Level Directories/Files:
- “src”: Contains the core header files (GyverOLED.h, charMap.h, icons_7x7.h, icons_8x8.h) that encapsulate the library’s functionality.
- “Image converter”: Likely a companion tool for converting images into a format compatible with the OLED library.
- Other supporting files (library.properties, keywords.txt, .gitignore, etc.) are present for Arduino integration and version control.
- This suggests a modular design with a clear separation between core library logic, demonstration/example code, and ancillary tools.

##### Examining the README for Architectural Insights
- The README gives sample initialization code, function lists, and examples showing different operational modes (with / without buffer, I2C vs. SPI, etc.). It also clearly defines how the developer can choose different parameters and modes.
- It explains the different layers: basic drawing functions, text handling, buffer management, and how these interact with the underlying OLED hardware.
- External dependencies (Arduino built-in functions, microWire library for I2C, and potentially PlatformIO integration) are also mentioned.

a. Main Components:
- Library Core Module (GyverOLED class)
- Interfaces: Functions for initialization, drawing (lines, circles, rectangles, Bezier curves), text operations, and bitmap handling.
- Sub-modules: Buffer Manager (handling software buffer vs. no buffer), Graphics Engine (rendering primitives), and Display Control (contrast, inversion, orientation).
- Communication/Interface Modules:
- I2C and SPI interfaces for communication with OLED hardware.
- Optionally, the microWire abstraction for I2C.
- Hardware Target:
- OLED display hardware (support for SSD1306 and SSH1106).
- The physical connection mapping (pins, protocol standards).
- Auxiliary Tools:
- Image Converter (a companion tool for converting bitmaps to the required format).
- Example Application Layer:
- Demonstration sketches that use the library functions to illustrate its capabilities (text output, graphical rendering, etc.).

b. Relationships and Interactions:
- The Example Layer (Arduino sketches in the “examples” directory) calls functions provided by the Library Core Module.
- The Library Core Module interacts with the I2C/SPI Communication Modules to send drawing commands to the OLED hardware.
- The Buffer Manager in the core module processes graphical commands and, when applicable, maintains a local buffer for optimized display updates.
- The Image Converter tool (outside core runtime) is used to generate compatible bitmaps that the demos and library functions can display.
- Dependencies (like Arduino’s built-in functions or microWire for I2C) are external and are assumed to be available within the target environment.

c. Architectural Patterns and Design Principles:
- Modularity: The core library is modular, where each function (text, graphics, display control) is separated clearly.
- Abstraction Layers: There’s a clear abstraction between the high-level drawing API presented to the user and the lower-level communication with the OLED hardware.
- Flexibility: The option to select various buffer modes shows a flexible design that can be adapted based on the hardware’s memory and speed constraints.
- Configurability: Pre-processor defines allow compile-time customization for different hardware needs and performance tuning.

d. Relevant Technologies, Frameworks, or Libraries:
- The library is built on standard Arduino functions and is compatible with PlatformIO.
- It optionally uses the microWire library for I2C communication.
- It supports multiple display protocols (I2C and SPI) and display types (SSD1306/SSH1106).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Example Application Layer
    EX["Example Sketches"]:::examples

    %% Core Library Components Subgraph
    subgraph "GyverOLED Core Components"
        GY["GyverOLED Core"]:::library
        BM["Buffer Manager"]:::library
        GE["Graphics Engine"]:::library
        DC["Display Control"]:::library
        CM["Character Map"]:::library
        IC7["Icons 7x7"]:::library
        IC8["Icons 8x8"]:::library
    end

    %% Communication and Hardware Modules
    COM["I2C/SPI Communication"]:::communication
    HW["OLED Display (SSD1306/SSH1106)"]:::hardware

    %% Auxiliary Tool
    IMG["Image Converter Tool"]:::tools

    %% Connections
    EX -->|"calls"| GY
    GY -->|"uses"| BM
    GY -->|"uses"| GE
    GY -->|"uses"| DC
    GY -->|"includes"| CM
    GY -->|"includes"| IC7
    GY -->|"includes"| IC8
    GY -->|"sends_commands"| COM
    COM -->|"communicates_with"| HW

    IMG -->|"generates_bitmaps"| EX

    %% Click Events
    click GY "https://github.com/gyverlibs/gyveroled/blob/main/src/GyverOLED.h"
    click CM "https://github.com/gyverlibs/gyveroled/blob/main/src/charMap.h"
    click IC7 "https://github.com/gyverlibs/gyveroled/blob/main/src/icons_7x7.h"
    click IC8 "https://github.com/gyverlibs/gyveroled/blob/main/src/icons_8x8.h"
    click EX "https://github.com/gyverlibs/gyveroled/tree/main/examples"
    click IMG "https://github.com/gyverlibs/gyveroled/tree/main/Image converter"

    %% Styles
    classDef library fill:#bbf,stroke:#333,stroke-width:2px;
    classDef communication fill:#e5ccff,stroke:#333,stroke-width:2px;
    classDef examples fill:#fbb,stroke:#333,stroke-width:2px;
    classDef hardware fill:#bfb,stroke:#333,stroke-width:2px;
    classDef tools fill:#ff9,stroke:#333,stroke-width:2px;
```
