> ## Documentation Index
> Fetch the complete documentation index at: https://darkgrade.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Get started with Darkgrade Slate in minutes

## Basic Usage

```typescript theme={null}
import { Camera } from '@darkgrade/slate'

const camera = new Camera()
await camera.connect()
try {
    const { controls } = await camera.getCapabilities()
    if (controls.iso?.writable && controls.iso.allowedValues?.includes('ISO 800')) {
        const observed = await camera.setControl('iso', 'ISO 800')
        console.log(observed.value)
    }
    const { data } = await camera.captureImage()
    if (!data) throw new Error('No image data returned')
} finally {
    await camera.disconnect()
}
```

The `Camera` class automatically detects your camera's brand and uses the appropriate vendor-specific implementation. The example assumes the body advertises those controls and remote capture; camera model, USB mode, and shooting mode can change the available surface.

For application UIs, use the [shared control model](https://darkgrade.com/docs/slate/getting_started/controls.md):
`getCapabilities()` exposes current choices across vendors, and `shutterSpeed`
covers exposure duration and shutter angle without implicit mode changes. Multiple USB
bodies require an explicit device filter.

For a generic or Olympus body, inspect the live standard-property inventory first:

```typescript theme={null}
const properties = await camera.getStandardPropertyStates()
const iso = properties.find(property => property.name === 'ExposureIndex')
if (iso?.writable) await camera.setStandardProperty('ExposureIndex', 'ISO 800')
```

This prevents an application from presenting ISO, aperture, or focus controls solely because it recognizes a vendor name. For example, the physically tested Olympus E-PL5 MTP mode publishes battery and camera date/time but no exposure or remote-capture property.

## How It Works

When you call `connect()`, Darkgrade Slate:

1. Scans for connected USB devices
2. Identifies the camera's vendor ID
3. Selects the appropriate vendor-specific implementation:
   * **Sony ⍺ Series** → `SonyCamera` with live view, video recording, SDIO
   * **Nikon Z Series** → `NikonCamera` with extended properties
   * **Canon EOS R Series** → `CanonCamera` with remote control
   * **Olympus and other PTP cameras** → `GenericCamera` with a capability-driven standard-property inventory
4. Opens that driver's session. Read `getCapabilities()` for current controls and write guards.

## Common Examples

### Camera Settings

```typescript theme={null}
// Get current settings
const currentIso = await camera.getIso()
const currentShutter = await camera.getShutterSpeed()
const currentAperture = await camera.getAperture()

// Set new values
await camera.setIso('1600')
await camera.setShutterSpeed('1/500')
await camera.setAperture('f/4.0')
```

### Event Handling

```typescript theme={null}
// Listen for camera events
camera.on(camera.getInstance().registry.events.ObjectAdded, event => {
    console.log('New object added:', event.ObjectHandle)
})

camera.on(camera.getInstance().registry.events.DevicePropChanged, event => {
    console.log('Property changed:', event.DevicePropCode)
})

// Remove event listeners
camera.off(camera.getInstance().registry.events.ObjectAdded)
```

### Live View

Capture live view on supported Sony, Nikon or Canon bodies:

```typescript theme={null}
const { data: liveViewFrame } = await camera.captureLiveView()
if (!liveViewFrame) throw new Error('No live-view image returned')
fs.writeFileSync('liveview.jpg', liveViewFrame)
```

### Video Recording

Start and stop video recording on supported Sony, Nikon or Canon bodies with usable media:

```typescript theme={null}
await camera.startRecording()
// ... record for some duration ...
await camera.stopRecording()
```

### File Management

List and download files from the camera:

```typescript theme={null}
const objects = await camera.listObjects()

for (const [storageId, storage] of Object.entries(objects)) {
    console.log(`Storage ${storageId}: ${storage.info.storageDescription}`)
    
    for (const [handle, info] of Object.entries(storage.objects)) {
        console.log(`  - ${info.filename} (${info.objectCompressedSize} bytes)`)
        
        // Download a specific object
        const fileData = await camera.getObject(Number(handle), info.objectCompressedSize)
        fs.writeFileSync(info.filename, fileData)
    }
}
```

### Advanced Property Access

Access vendor-specific properties directly:

```typescript theme={null}
const registry = camera.getInstance().registry

// Get property with type safety
const propValue = await camera.get(registry.properties.ExposureIndex)

// Set property
await camera.set(registry.properties.ExposureIndex, '3200')
```

## Advanced Usage

### Typed protocol access

Applications instantiate `Camera` and use its shared control model. Protocol work can
use the existing typed definitions without maintaining an application vendor map:

```typescript theme={null}
import { Camera, genericOperationRegistry } from '@darkgrade/slate'

const camera = new Camera()
await camera.connect()
try {
    const reply = await camera.send(genericOperationRegistry.GetDeviceInfo, {})
    console.log(reply.data)
} finally {
    await camera.disconnect()
}
```

### Manual Configuration

Specify device filters and logging options:

```typescript theme={null}
import { Camera, VendorIDs } from '@darkgrade/slate'

const camera = new Camera({
    device: {
        usb: {
            filters: [{ vendorId: VendorIDs.SONY }], // VendorIDs.NIKON, VendorIDs.CANON
        },
    },
    logger: {
        renderInTerminal: true,
        captureConsole: false,
        expanded: true, // Show detailed logging
    },
})

await camera.connect()
```

## Next Steps

* Learn about [PTP](https://darkgrade.com/docs/slate/getting_started/what-is-ptp.md) - Understanding the protocol
* Check [Feature Compatibility](https://darkgrade.com/docs/slate/getting_started/feature-compatibility.md) - See what your camera supports
* Explore the [Camera API](https://darkgrade.com/docs/slate/getting_started/camera.md) - Complete API reference


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.