# highvaper/heater-controller architecture

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

- Interactive diagram: https://gitdiagram.com/highvaper/heater-controller
- Repository: https://github.com/highvaper/heater-controller

## Overview

##### Project Type Analysis
This is an embedded systems project running on a Raspberry Pi Pico, implementing a PID-controlled heater system with various hardware interfaces.

##### Main Components

A. Hardware Layer:
- Raspberry Pi Pico (central controller)
- Input Devices (Rotary Encoder, Button)
- Output Devices (LED, Display, Heater Coils)
- Sensors (MAX6675 Thermocouple, DS18X20)

B. Software Layer:
- Core Control System (main.py)
- Hardware Interface Modules
- User Interface System
- PID Control System

##### Physical Layer (Bottom)
**[Sensors] ←→ [Raspberry Pi Pico] ←→ [Output Devices]**
- ↑            ↑    ↑    ↑           ↑
**[MAX6675]  [Button] | [Rotary]  [SSD1306 Display]**
- [Heater Coils]
- [DS18X20]

##### Software Layer (Middle)
**[Hardware Drivers]**
- ↓
**[Core Control Logic]**
- ↓
**[User Interface]**

##### Control Flow Layer (Top)
**[Input Handler] → [Menu System] → [PID Controller] → [Heater Control]**

##### Component Relationships

A. Hardware Interface Modules:
- rotary_irq_rp2.py ↔ Rotary Encoder
- max6675_utime.py ↔ Thermocouple
- ssd1306.py ↔ OLED Display

B. Control Modules:
- inputhandler.py → menusystem.py
- heaters.py ← simple_pid
- thermocouple.py → PID Controller
- displaymanager.py → SSD1306

C. Core Logic:
- main.py (central orchestrator)
- customtimer.py (timing control)
- errormessage.py (error handling)

##### Control Flow
**[Sensor Input] → [PID Processing] → [Heater Control] → [Display Update]**

##### State Management
**[Input Handler] → [Menu System] → [System State] → [Display Manager]**

##### Hardware Abstraction
**[Physical Hardware] → [Driver Layer] → [Control Layer] → [User Interface]**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Hardware
        PICO[Raspberry Pi Pico]
        
        subgraph Inputs
            ROT[Rotary Encoder]:::input
            BTN[Button]:::input
            MAX[MAX6675 Thermocouple]:::sensor
            DS[DS18X20 Sensor]:::sensor
        end
        
        subgraph Outputs
            DISP[SSD1306 Display]:::output
            HEAT[Heater Coils]:::output
            LED[LED]:::output
        end
    end
    
    subgraph "Software Layer"
        MAIN[Main Control System]:::core
        
        subgraph "Hardware Interfaces"
            ROT_DRV[Rotary Driver]:::driver
            DISP_DRV[Display Driver]:::driver
            THERM_DRV[Thermocouple Driver]:::driver
        end
        
        subgraph "Control Systems"
            PID[PID Controller]:::control
            HEAT_CTRL[Heater Control]:::control
            THERM_CTRL[Thermocouple Management]:::control
        end
        
        subgraph "User Interface"
            INPUT[Input Handler]:::ui
            MENU[Menu System]:::ui
            DISPM[Display Manager]:::ui
        end
        
        subgraph "Support Systems"
            TIMER[Timer Control]:::support
            ERROR[Error Handler]:::support
        end
    end
    
    %% Hardware Connections
    ROT --> PICO
    BTN --> PICO
    MAX --> PICO
    DS --> PICO
    PICO --> DISP
    PICO --> HEAT
    PICO --> LED
    
    %% Software Connections
    MAIN --> PID
    MAIN --> HEAT_CTRL
    MAIN --> INPUT
    MAIN --> MENU
    
    ROT_DRV --> INPUT
    THERM_DRV --> THERM_CTRL
    THERM_CTRL --> PID
    PID --> HEAT_CTRL
    HEAT_CTRL --> HEAT
    
    INPUT --> MENU
    MENU --> DISPM
    DISPM --> DISP_DRV
    DISP_DRV --> DISP
    
    TIMER --> MAIN
    ERROR --> MAIN
    
    %% Click Events
    click MAIN "https://github.com/highvaper/heater-controller/blob/main/main.py"
    click PID "https://github.com/highvaper/heater-controller/blob/main/lib/simple_pid/pid.py"
    click DISP_DRV "https://github.com/highvaper/heater-controller/blob/main/lib/ssd1306.py"
    click ROT_DRV "https://github.com/highvaper/heater-controller/blob/main/rotary_irq_rp2.py"
    click THERM_DRV "https://github.com/highvaper/heater-controller/blob/main/max6675_utime.py"
    click HEAT_CTRL "https://github.com/highvaper/heater-controller/blob/main/heaters.py"
    click DISPM "https://github.com/highvaper/heater-controller/blob/main/displaymanager.py"
    click INPUT "https://github.com/highvaper/heater-controller/blob/main/inputhandler.py"
    click MENU "https://github.com/highvaper/heater-controller/blob/main/menusystem.py"
    click THERM_CTRL "https://github.com/highvaper/heater-controller/blob/main/thermocouple.py"
    click TIMER "https://github.com/highvaper/heater-controller/blob/main/customtimer.py"
    click ERROR "https://github.com/highvaper/heater-controller/blob/main/errormessage.py"
    
    %% Styles
    classDef input fill:#6495ED
    classDef output fill:#FF6B6B
    classDef sensor fill:#90EE90
    classDef core fill:#FFD700
    classDef driver fill:#A9A9A9
    classDef control fill:#DDA0DD
    classDef ui fill:#87CEEB
    classDef support fill:#D3D3D3
    
    %% Legend
    subgraph Legend
        L1[Input Components]:::input
        L2[Output Components]:::output
        L3[Sensor Components]:::sensor
        L4[Core System]:::core
        L5[Hardware Drivers]:::driver
        L6[Control Systems]:::control
        L7[User Interface]:::ui
        L8[Support Systems]:::support
    end
```
