TofuPilotTofuPilot

Progress

Progress indicator bar.

You can create a progress bar with progress:

ui:
  components:
    - key: download_progress
      type: progress
      label: "Firmware Download"
      description: "Downloading firmware to device"
      value: 0
      max: 100

Properties

Display

You can configure how the progress bar appears to the operator.

PropertyTypeRequiredDescription
keystringYesUnique identifier for updating the value
typestringYesMust be "progress"
labelstringNoDisplay label above the progress bar
descriptionstringNoHelper text displayed below the label

Value

You can set default values and update them dynamically from Python.

PropertyTypeRequiredDescription
valuenumberNoInitial progress value
minnumberNoMinimum value (default: 0)
maxnumberNoMaximum value (default: 100)

Examples

Firmware Download

We'll show progress while downloading firmware to the device:

phases:
  - name: Firmware Update
    python:
      module: update_firmware
    ui:
      components:
        - key: download_progress
          type: progress
          label: "Firmware Download"
          description: "Downloading firmware to device"
          value: 0
          max: 100
import time

def update_firmware(run, device):
    firmware_size = 2048  # KB
    chunk_size = 64  # KB
    downloaded = 0

    log.info("Starting firmware download")

    while downloaded < firmware_size:
        chunk = min(chunk_size, firmware_size - downloaded)
        device.write_firmware_chunk(chunk)
        downloaded += chunk

        progress = int((downloaded / firmware_size) * 100)
        run.ui.download_progress = progress

        time.sleep(0.1)

    log.info("Firmware download complete")

Multi-Stage Progress

We'll track progress across multiple test stages:

phases:
  - name: Multi-Stage Test
    python:
      module: multi_stage_test
    ui:
      components:
        - key: overall_progress
          type: progress
          label: "Overall Progress"
          description: "Total progress across all stages"
          value: 0
          max: 100

        - key: stage_name
          type: text
          label: "Current Stage"
          value: ""

        - key: stage_progress
          type: progress
          label: "Stage Progress"
          description: "Progress within current stage"
          value: 0
          max: 100
import time

def multi_stage_test(run):
    stages = [
        ("Initialization", 10),
        ("Calibration", 20),
        ("Testing", 50),
        ("Cleanup", 10)
    ]

    total_progress = 0

    for stage_name, stage_steps in stages:
        run.ui.stage_name = stage_name
        log.info(f"Starting: {stage_name}")

        for step in range(stage_steps + 1):
            stage_progress = int((step / stage_steps) * 100)
            run.ui.stage_progress = stage_progress

            overall = total_progress + (step / stage_steps) * (stage_steps / 100)
            run.ui.overall_progress = int(overall)

            time.sleep(0.1)

        total_progress += stage_steps

How is this guide?