# eserandour/minitel1b_hard architecture

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

- Interactive diagram: https://gitdiagram.com/eserandour/minitel1b_hard
- Repository: https://github.com/eserandour/minitel1b_hard

## Overview

##### Project Type and Purpose
- This is an Arduino hardware‐interface library (“Minitel1B_Hard”) that implements the Minitel 1B teletext protocol over a HardwareSerial port.
- It provides a C++ API (in Minitel1B_Hard.h/.cpp) for Arduino sketches to control a Minitel terminal (display text, graphics, handle keyboard input, modem commands, etc.).
- The `examples/` folder contains Arduino sketches that demonstrate usage of the API on ATmega1284P, ATmega2560 (Arduino Mega), and ESP32‐WROOM‐32E boards, often with a “3615” shield.

##### File Structure Analysis
- Top level:
- Minitel1B_Hard.h / .cpp – core library code implementing all Minitel functions (writeCode, getKeyCode, identifyDevice, reset, graphic, etc.)
- README.md/.txt – documentation and changelog
- LICENSE
- `examples/` – sample Arduino sketches grouped into subfolders, each folder containing a single `.ino` that uses the library.
- No build scripts or sub‐modules; relies on Arduino IDE/Cli build system and the built‐in HardwareSerial class.

##### Key Insights from README
- Library supports multiple MCUs via Arduino HardwareSerial (ATmega1284P, ATmega2560, ESP32).
- Implements both text and graphic teletext modes, supports character encoding (UTF-8 handling), modem/connection commands, cursor controls, etc.
- Users interact by including `#include <Minitel1B_Hard.h>` and invoking its methods in their `.ino` sketch.

##### Main Components
a. Application Layer (User Sketches)
– Arduino `.ino` files (examples like HelloWorld, Portrait, Tweet_3615, etc.)
– Calls high‐level library functions (print, writeCode, graphic, getKeyCode)
b. Library Layer (Minitel1B_Hard)
– C++ classes & methods in Minitel1B_Hard.h/.cpp
– Implements protocol per Minitel 1B spec PDF
– Encapsulates character encoding, teletext packet construction, mode switching
c. HAL / Framework Layer
– Arduino Core / HardwareSerial API
– Serial ports (Serial, Serial1, etc.) on the MCU
d. Hardware Layer
– Microcontroller (ATmega1284P, ATmega2560, or ESP32-WROOM-32E)
– Shield 3615 or direct wiring to Minitel 1B terminal
– Minitel 1B hardware (screen, keyboard, modem interface)
e. External Resources
– Teletext specification document (stum1b.pdf) for reference
– Optional power supply, connectors, GPS clock, etc.

##### Relationships and Data Flows
- Sketch → calls → Library API → constructs teletext sequences → writes to → HardwareSerial port → drives → Minitel terminal
- Minitel keyboard input / status lines → read from → HardwareSerial → passed back to → Library.getKeyCode() → returned to → Sketch
- Optional “identifyDevice()” and modem commands stage control signals between MCU and Minitel hardware.

##### Architectural Patterns and Design Principles
- Layered architecture (Application → Library → HAL → Hardware)
- Hardware abstraction: library only depends on Arduino’s Serial interface, making it portable across boards
- Separation of concerns: encoding and protocol logic isolated in library; user code only deals with high‐level functions
- Extensibility: new functions (graphics, keyboard handling) are added by extending the API in the .h/.cpp

##### Elements
- Component labels and brief responsibilities
- Notes on board variants (ATmega vs. ESP32) if relevant.
- Extensibility points: user can add new sketches that call the same API.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Application Layer
    subgraph "Application Layer" 
        HelloWorld["HelloWorld.ino"]:::software
        Demo["Demo.ino"]:::software
        Portrait["Portrait.ino"]:::software
        TestCaracteresSpeciaux["TestCaracteresSpeciaux.ino"]:::software
        Tweet3615["Tweet_3615.ino"]:::software
    end

    %% Library Layer
    subgraph "Library Layer"
        MinitelHeader["Minitel1B_Hard.h"]:::software
        MinitelCpp["Minitel1B_Hard.cpp"]:::software
    end

    %% HAL / Framework Layer
    ArduinoCore["Arduino Core / HardwareSerial"]:::software

    %% Hardware Layer
    subgraph "Hardware Layer"
        MCU["Microcontroller\n(ATmega1284P, ATmega2560,\nESP32-WROOM-32E)"]:::hardware
        Shield3615["Shield 3615"]:::hardware
        MinitelTerminal["Minitel 1B Terminal"]:::hardware
    end

    %% External Resources
    subgraph "External Resources"
        SpecDoc["Teletext Spec (stum1b.pdf)"]:::external
        READMEmd["README.md"]:::external
        READMExtxt["README.txt"]:::external
        LICENSE["LICENSE"]:::external
    end

    %% Data Flows
    HelloWorld -->|"calls API"| MinitelHeader
    Demo -->|"calls API"| MinitelHeader
    Portrait -->|"calls API"| MinitelHeader
    TestCaracteresSpeciaux -->|"calls API"| MinitelHeader
    Tweet3615 -->|"calls API"| MinitelHeader

    MinitelHeader -->|"implements protocols"| MinitelCpp
    MinitelCpp -->|"uses"| ArduinoCore
    ArduinoCore -->|"serial TX/RX"| MCU
    MCU -->|"drives signals"| Shield3615
    Shield3615 -->|"connects to"| MinitelTerminal
    MinitelTerminal -->|"keyboard/status"| MCU
    MCU -->|"serial RX/TX"| ArduinoCore
    ArduinoCore -->|"getKeyCode()"| MinitelCpp
    MinitelCpp -->|"returns key code"| HelloWorld

    SpecDoc -.->|"reference for API"| MinitelHeader
    READMEmd -.-> MinitelHeader
    READMExtxt -.-> MinitelHeader
    LICENSE -.-> MinitelHeader

    %% Click Events
    click HelloWorld "https://github.com/eserandour/minitel1b_hard/blob/master/examples/HelloWorld/HelloWorld.ino"
    click Demo "https://github.com/eserandour/minitel1b_hard/blob/master/examples/Demo/Demo.ino"
    click Portrait "https://github.com/eserandour/minitel1b_hard/blob/master/examples/Portrait/Portrait.ino"
    click TestCaracteresSpeciaux "https://github.com/eserandour/minitel1b_hard/blob/master/examples/TestCaracteresSpeciaux/TestCaracteresSpeciaux.ino"
    click Tweet3615 "https://github.com/eserandour/minitel1b_hard/blob/master/examples/Tweet_3615/Tweet_3615.ino"
    click MinitelHeader "https://github.com/eserandour/minitel1b_hard/blob/master/Minitel1B_Hard.h"
    click MinitelCpp "https://github.com/eserandour/minitel1b_hard/blob/master/Minitel1B_Hard.cpp"
    click READMEmd "https://github.com/eserandour/minitel1b_hard/blob/master/README.md"
    click READMExtxt "https://github.com/eserandour/minitel1b_hard/blob/master/README.txt"
    click LICENSE "https://github.com/eserandour/minitel1b_hard/tree/master/LICENSE"

    %% Styles
    classDef software fill:#D0E6FF,stroke:#1E70BF,color:#000
    classDef hardware fill:#DFFFD0,stroke:#3C8F00,color:#000
    classDef external fill:#F0F0F0,stroke:#888,color:#333
```
