---
jupytext:
  formats: md:myst
  text_representation:
    extension: .md
    format_name: myst
    format_version: 0.13
    jupytext_version: 1.11.5
kernelspec:
  display_name: Python 3
  language: python
  name: python3
---

# Saleae MSO API Documentation

Welcome to the documentation for the Saleae Mixed Signal Oscilloscope (MSO) API.

```{image} saleae_logo.jpg
:alt: Saleae Logo
:width: 150px
:align: center
```

## Overview

This API provides programmatic access to Saleae Mixed Signal Oscilloscopes, allowing you to:

- Configure and run analog, digital, or mixed-signal captures
- Ingest the resulting binary data files into memory-mapped Numpy arrays, and
- Some other things, like simple plotting of those captures

The MSO API runs on Windows, Linux, and Mac computers, see <project:installation.md> for the exact versions of each supported.

## Installation

See <project:installation.md> for detailed installation instructions.

## Quick Example

The following demonstrates how to configure and execute a series of simple timed captures with
the `saleae-mso-api` and a Logic MSO.

```{code-cell} python
from pathlib import Path
import numpy as np
from saleae import mso_api

mso = mso_api.MSO()

capture_config = mso_api.CaptureConfig(
    enabled_channels=[mso_api.AnalogChannel(channel=0, name="clock")],
    analog_settings=mso_api.AnalogSettings(sample_rate=100e6),
    capture_settings=mso_api.TimedCapture(capture_length_seconds=0.1),
)

for n in range(3):
    save_dir = Path('my-captures') / f'{n:02d}'
    capture = mso.capture(capture_config, save_dir=save_dir)
    avg_voltage = np.mean(capture.analog_data["clock"].voltages)
    print(f"Capture {n:02d} in {save_dir} avg voltage: {avg_voltage:.3f} V")
```

Learn more about how this example is structured by reading the following:

 - <project:api/capture_config.md> for configuring captures
 - <project:api/mso.md> for running them on an attached Logic MSO

:::{warning}
This is package is currently under heavy development, some significant features
are missing and others may be evolving quickly. Things may change!
:::

## More

* {ref}`genindex`
* {ref}`modindex`
* {ref}`search` 
