# Menu Driver - Overview

## Purpose

<p class="callout info"><span style="white-space: pre-wrap;">The menu driver is a </span>**page-based UI framework**<span style="white-space: pre-wrap;"> for an embedded display (ILI9341). </span></p>

It defines:

- how UI is structured into pages
- how state is stored per page
- how navigation works
- how rendering is organized

## Architecture Position

```
[ Application Logic ]        
↓[ Menu Driver ]        
↓[ ILI9341 Driver ]        
↓[ SPI / Hardware ]
```

<span style="white-space: pre-wrap;">It </span>**does not**:

- own the main loop
- schedule tasks
- interpret input fully

<span style="white-space: pre-wrap;">It </span>**does**:

- define UI structure
- manage page lifecycle
- coordinate rendering

---

## 1.3 Design Model

Everything revolves around:

> “A UI is a collection of pages with lifecycle and state.”

Each page has:

- state
- init/update/render/destruct
- parent relationship

```
         Input / System Events
                  │
                  ▼
        ┌─────────────────────┐
        │   menu_manager_t    │
        │─────────────────────│
        │ active_page_id      │
        │ pages[]             │
        │ get_input()         │
        └─────────┬───────────┘
                  │ selects active page
                  ▼
      ┌──────────────────────────────────┐
      │          Active Page             │
      │──────────────────────────────────│
      │ state pointer                    │
      │ init()       ─┐                  │
      │ update()      ├─ custom page     │
      │ render()      ┤  behavior        │
      │ destruct()    ┘                  │
      └────────────────┬─────────────────┘
                       │ reads/writes
                       ▼
              ┌──────────────────┐
              │   Page State     │
              │──────────────────│
              │ selection        │
              │ cached values    │
              │ render flags     │
              │ page-local data  │
              └──────────────────┘
```