# mchobby/micropython-oled-menu architecture

> Architecture diagram of the GitHub repository mchobby/micropython-oled-menu, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mchobby/micropython-oled-menu
- Repository: https://github.com/mchobby/micropython-oled-menu

## Overview

OLED MENU is a non-blocking MicroPython menu for a 128×64 I²C OLED and rotary encoder. The main workflow is an application creating and updating the menu, responding to selected entries, and optionally handing control to range, combo, or application-drawn screen controls. The graph reflects the single sampled runtime module and the README; internal wiring not shown in the excerpts is left out.

Main entry points: [`lib/oledmenu.py`](https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py) (Menu runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_menu["Menu runtime"]
  node_menu_runtime["Menu runtime<br/>[oledmenu.py]"]
  node_menu_items["Menu entries<br/>[oledmenu.py]"]
  node_navigation["Focus navigation<br/>[oledmenu.py]"]
  node_menu_rendering["Menu rendering<br/>[oledmenu.py]"]
end

subgraph group_controls["Entry controls"]
  node_range_control["Range control<br/>[oledmenu.py]"]
  node_combo_control["Combo control<br/>[oledmenu.py]"]
  node_screen_control["Screen control<br/>[oledmenu.py]"]
end

subgraph group_hardware["Display and input"]
  node_oled_driver["SSD1306 driver"]
  node_oled_display["128×64 OLED"]
  node_encoder_driver["I²C encoder driver"]
  node_rotary_encoder["Rotary encoder"]
end

node_application(("Main application"))

node_application -->|"creates and updates"| node_menu_runtime
node_menu_runtime -->|"returns selection"| node_application
node_menu_runtime -->|"adds entries"| node_menu_items
node_menu_runtime -->|"updates focus"| node_navigation
node_menu_runtime -->|"draws menu"| node_menu_rendering
node_menu_runtime -->|"dispatches updates"| node_range_control
node_menu_runtime -->|"dispatches updates"| node_combo_control
node_menu_runtime -->|"starts control"| node_screen_control
node_range_control -->|"draws range"| node_oled_driver
node_combo_control -->|"creates submenu entries"| node_menu_items
node_screen_control -->|"calls screen hooks"| node_application
node_screen_control -->|"clears display"| node_oled_driver
node_menu_rendering -->|"draws entries"| node_oled_driver
node_oled_driver -->|"renders pixels"| node_oled_display
node_menu_runtime -->|"reads encoder state"| node_encoder_driver
node_range_control -->|"reads and resets"| node_encoder_driver
node_combo_control -->|"resets encoder"| node_encoder_driver
node_screen_control -->|"resets encoder"| node_encoder_driver
node_encoder_driver -->|"reads input"| node_rotary_encoder

click node_menu_runtime "https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py"
click node_menu_items "https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py"
click node_navigation "https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py"
click node_menu_rendering "https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py"
click node_range_control "https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py"
click node_combo_control "https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py"
click node_screen_control "https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_menu_runtime,node_menu_items,node_navigation,node_menu_rendering toneBlue
class node_range_control,node_combo_control,node_screen_control toneAmber
class node_oled_driver,node_oled_display,node_encoder_driver,node_rotary_encoder toneMint
class node_application toneIndigo
```

## Components

### Menu runtime

- [Menu runtime](https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py): `lib/oledmenu.py`
- [Menu entries](https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py): `lib/oledmenu.py`
- [Focus navigation](https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py): `lib/oledmenu.py`
- [Menu rendering](https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py): `lib/oledmenu.py`

### Entry controls

- [Range control](https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py): `lib/oledmenu.py`
- [Combo control](https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py): `lib/oledmenu.py`
- [Screen control](https://github.com/mchobby/micropython-oled-menu/blob/main/lib/oledmenu.py): `lib/oledmenu.py`

### Display and input

- **SSD1306 driver**
- **128×64 OLED**
- **I²C encoder driver**
- **Rotary encoder**

### Other components

- **Main application**

## Connections

- Main application → Menu runtime: creates and updates
- Menu runtime → Main application: returns selection
- Menu runtime → Menu entries: adds entries
- Menu runtime → Focus navigation: updates focus
- Menu runtime → Menu rendering: draws menu
- Menu runtime → Range control: dispatches updates
- Menu runtime → Combo control: dispatches updates
- Menu runtime → Screen control: starts control
- Range control → SSD1306 driver: draws range
- Combo control → Menu entries: creates submenu entries
- Screen control → Main application: calls screen hooks
- Screen control → SSD1306 driver: clears display
- Menu rendering → SSD1306 driver: draws entries
- SSD1306 driver → 128×64 OLED: renders pixels
- Menu runtime → I²C encoder driver: reads encoder state
- Range control → I²C encoder driver: reads and resets
- Combo control → I²C encoder driver: resets encoder
- Screen control → I²C encoder driver: resets encoder
- I²C encoder driver → Rotary encoder: reads input
