# Menu Driver - Overview Page

## Introduction

<span style="white-space: pre-wrap;">The </span>**List Page**<span style="white-space: pre-wrap;"> is a navigation-oriented page type within the menu driver. It provides a structured interface for selecting between multiple entries, typically representing:</span>

- subpages
- actions
- system modules

<span style="white-space: pre-wrap;">It is the primary mechanism for </span>**user-driven navigation**<span style="white-space: pre-wrap;"> within the menu system.</span>

## Purpose

The list page exists to answer:

> **“Where do you want to go next?”**

It is not responsible for displaying system state in detail. Instead, it:

- presents a bounded set of selectable entries
- tracks the current selection
- provides visual feedback for navigation
- enables transitions to other pages

<span style="white-space: pre-wrap;">In practice, it functions as the </span>**entry point and routing layer**<span style="white-space: pre-wrap;"> of the UI.</span>

## Architectural Role

The list page sits at the intersection of:

- **input handling**<span style="white-space: pre-wrap;"> (user navigation)</span>
- **menu structure**<span style="white-space: pre-wrap;"> (page hierarchy)</span>
- **visual rendering**<span style="white-space: pre-wrap;"> (icons and labels)</span>

```
[ Input ] → [ List Page ] → [ Page Transition ]
```

<span style="white-space: pre-wrap;">It does not consume system data (like overview pages), but rather controls </span>**flow through the interface**.

## Data Model

The list page is backed by the following state structure:

```c
typedef struct {
  uint8_t num_entries;
  uint8_t selected_index;
  uint8_t entry_ids[MAX_LIST_ENTRIES];
  const uint8_t (*entry_icons)[MENU_DRIVER_ICON_BYTE_SIZE];
  bool first_render;
} page_list_state;
```

### Entry Management

`<span class="editor-theme-code">num_entries</span>`

Defines how many entries are currently active.

<span style="white-space: pre-wrap;">This value must not exceed </span>`<span class="editor-theme-code">MAX_LIST_ENTRIES</span>`.

`<span class="editor-theme-code">entry_ids</span>`

Maps each visible entry to a logical identifier.

These IDs are typically used to:

- determine which page to switch to
- associate actions with selections

`<span class="editor-theme-code">entry_icons</span>`

Pointer to icon data associated with each entry.

- Icons are rendered alongside entries
- Each icon is a fixed-size bitmap
- Icons are stored in flash as static data

### Selection State

#### `<span class="editor-theme-code">selected_index</span>`

Indicates which entry is currently selected.

This is the central piece of state for navigation.

All rendering and transitions depend on this value.

### Render Control

`<span class="editor-theme-code">first_render</span>`

Indicates whether the page is being rendered for the first time.

Used to:

- trigger full initial draw
- avoid redundant rendering of static UI elements

## Rendering Model

<span style="white-space: pre-wrap;">The list page uses a </span>**focused rendering strategy**, rather than displaying all entries simultaneously.

### Visible Entries

Only three entries are rendered at any time:

- previous entry
- current (selected) entry
- next entry

This creates a scrolling effect without requiring full list rendering.

### Rendering Optimization

The only expensive draw of the list page is the initial one which draws the selection border, all initial entries (both icons and names).

<span style="white-space: pre-wrap;">After that the only thing that gets redrawn are the icons and the texts. There is also heavier optimization done for minimal font redrawing by keeping track of previously rendered text widths. </span>

<p class="callout info">This is critical for SPI-driven displays, where bandwidth is limited.</p>

## Interaction Model

The list page assumes an abstract input interface:

```
menu_input (*get_input)(void);
```

The page does not interpret physical inputs directly. Instead, it operates on abstract input values, allowing it to remain independent of hardware specifics.

Expected interactions include:

- move selection up
- move selection down
- confirm selection

## Relationship to Menu System

The list page enables hierarchical navigation through:

- `<span class="editor-theme-code">entry_ids</span>`<span style="white-space: pre-wrap;"> → target page identifiers</span>
- `<span class="editor-theme-code">parent_id</span>`<span style="white-space: pre-wrap;"> (in </span>`<span class="editor-theme-code">menu_page_t</span>`) → upward navigation

<p class="callout info"><span style="white-space: pre-wrap;">This allows the menu system to behave as a </span>**tree of pages**, rather than a flat structure.</p>

## Performance Considerations

The list page is designed for constrained environments:

- partial rendering minimizes SPI usage
- static memory avoids allocation overhead
- limited visible entries reduce draw complexity