How gyverlibs/gyveroled works
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).