# jrsola/pico-project architecture

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

- Interactive diagram: https://gitdiagram.com/jrsola/pico-project
- Repository: https://github.com/jrsola/pico-project

## Overview

##### Main Components
- Main Application (main.cpp): This is the entry point. It is responsible for initializing the system, setting up drivers, and coordinating the overall clock operation and any additional functionality.
- Hardware Abstraction / Library Modules (located in the project_libraries folder):
– bootsel.cpp/h: Likely manages boot selection or mode handling for the device.
– myled.cpp/h: Manages LED control – could be used for status indication.
– myscreen.cpp/h: Handles the display functionality using the Pimoroni Display Pack 2.0.
- SDK and External Dependencies:
– Raspberry Pi Pico SDK: Provides core functionality for the Pico hardware.
– Pimoroni Pico SDK: Supplies additional drivers or utilities for the Pimoroni hardware.
– lwIP options file (lwipopts.h): Indicates the project may leverage networking features or configures the lightweight IP stack.
– Project build files (CMakeLists.txt, pico_sdk*.cmake, etc.): Tie all of these together and set up the build environment.
- External Hardware:
– Raspberry Pi Pico W microcontroller.
– Pimoroni Display Pack 2.0.
– Possibly other peripherals (e.g., LEDs).

##### Component Interactions
- The main application (main.cpp) initializes the system by setting up the Pico SDK environment and integrating the Pimoroni SDK components.
- The libraries abstract the hardware interactions, forming a layer between the low-level SDK calls and the application’s business logic.
- The lwIP configuration (lwipopts.h) may indicate interactions with network components if the clock supports any web updates or remote control.

##### Architectural Patterns and Design Principles
- Modular design – separation of concerns where each hardware-specific feature is encapsulated in its own module/library.
- Hardware abstraction – libraries encapsulate device-specific functionality, making the main application code cleaner.
- Dependency management via CMake – clear division between external libraries (Pico SDK, Pimoroni SDK) and custom project libraries.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Application & Build Layer
    subgraph "Application & Build"
        MainApp["Main Application (main.cpp)"]:::app
        Build["Build & Integration (CMake)"]:::build
    end

    %% Custom Libraries Layer
    subgraph "Custom Libraries"
        Bootsel["Boot Selection Module"]:::library
        LED["LED Control Module"]:::library
        Display["Display/Screen Module"]:::library
        Color["Color Management Module"]:::library
    end

    %% SDK Layer
    subgraph "SDK Layer"
        SDK1["Raspberry Pi Pico SDK"]:::sdk
        SDK2["Pimoroni Pico SDK"]:::sdk
        lwip["lwIP Configuration (lwipopts.h)"]:::sdk
    end

    %% Hardware Layer
    subgraph "Hardware Layer"
        HW1["Raspberry Pi Pico W"]:::hardware
        HW2["Pimoroni Display Pack 2.0"]:::hardware
        HW3["LED Circuit"]:::hardware
    end

    %% Connections from Application to Custom Libraries
    MainApp -->|"calls"| Bootsel
    MainApp -->|"calls"| LED
    MainApp -->|"calls"| Display
    MainApp -->|"calls"| Color
    Build -->|"configures"| MainApp

    %% Connections from Custom Libraries to SDK Layer
    Bootsel -->|"uses"| SDK1
    Bootsel -->|"uses"| SDK2
    LED -->|"uses"| SDK1
    LED -->|"uses"| SDK2
    Display -->|"uses"| SDK1
    Display -->|"uses"| SDK2
    Color -->|"uses"| SDK1
    Color -->|"uses"| SDK2

    %% Connections from Custom Libraries to Hardware
    LED -->|"controls"| HW3
    Display -->|"drives"| HW2

    %% Connections from SDK Layer to Hardware
    SDK1 -->|"interfaces"| HW1
    SDK2 -->|"interfaces"| HW2
    lwip -->|"configures"| HW1

    %% Styles
    classDef app fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef build fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef library fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef sdk fill:#FFB6C1,stroke:#333,stroke-width:2px;
    classDef hardware fill:#FFDAB9,stroke:#333,stroke-width:2px;

    %% Click Events
    click MainApp "https://github.com/jrsola/pico-project/blob/main/main.cpp"
    click Bootsel "https://github.com/jrsola/pico-project/blob/main/project_libraries/bootsel.cpp"
    click LED "https://github.com/jrsola/pico-project/blob/main/project_libraries/myled.cpp"
    click Display "https://github.com/jrsola/pico-project/blob/main/project_libraries/myscreen.cpp"
    click Color "https://github.com/jrsola/pico-project/blob/main/project_libraries/color.cpp"
    click lwip "https://github.com/jrsola/pico-project/blob/main/lwipopts.h"
    click Build "https://github.com/jrsola/pico-project/blob/main/CMakeLists.txt"
```
