Skip to main content
WorkflowsChecks before a shoot

Before a long take or an unattended job, find out what would stop it: a battery that won't last, a full card, a setting the camera won't accept. Each question has one call in Darkgrade Slate, and each call returns a plain result you can show or log.

QuestionUse
Will the battery last the take?assessCameraPower
Is there a card with room?getCardStatus()
Can the camera record right now?getCapabilities().operations
Does this setting really change, and change back?qualifyCameraSetting
Has Darkgrade tested this model?isValidatedModel

Battery

assessCameraPower turns a battery reading (a CameraPower) and a planned recording length into pass, warn or fail, with a sentence that says why.

import {
    Camera,
    assessCameraPower,
    type CameraPower,
} from '@darkgrade/slate'

const camera = new Camera()
await camera.connect()

// assessCameraPower takes a CameraPower: getBattery()'s reading
// plus when and where it was read.
const battery = await camera.getBattery()
const power: CameraPower = {
    observedAt: new Date().toISOString(),
    source: 'getBattery',
    powerSource: battery.powerSource,
    percent: battery.percent,
    level: battery.level,
    remainingMinutes: battery.minutesRemaining,
    batteryPresent: battery.batteryPresent,
    raw: {},
}

// A 45-minute take, with 5 minutes in reserve.
const check = assessCameraPower(power, 45)
console.log(check.status, check.summary)
// 'pass' 'Camera estimates 62 min battery · 5 min reserve covered'
assessCameraPower(
    power: CameraPower | undefined,
    plannedMinutes: number,
    reserveMinutes?: number // default 5
): CameraPowerAssessment

The result, a CameraPowerAssessment, has status, summary, reserveMinutes, and runtimeVerified: true only when the camera's own minutes-remaining estimate covers the plan and the reserve.

StatusWhen
passThe camera estimates at least plannedMinutes + reserveMinutes remaining, and the battery is not low.
warnThe estimate covers the plan but not the reserve. Or the camera reports no estimate: a percentage or a level alone never passes. Or the reading is missing, has lastRefreshError, or is more than two minutes old. Or the camera is on DC or PoE power with a backup battery that is absent, low, or at 25% or below.
failThe estimate is shorter than the plan, the battery is at 10% or below, or the camera reports it low or empty. A low battery fails even when the estimate covers the plan, except on DC or PoE power, where it warns.

Runtime is never worked out from the percentage. Only a minutes-remaining figure from the camera counts, and getBattery() returns one only on cameras that report it.

assessCameraPower throws unless plannedMinutes is above zero and reserveMinutes is zero or more.

Settings

A setting can be listed as writable and still not stick in the camera's current mode. qualifyCameraSetting proves it: it writes a different value, reads the camera to confirm, then puts the original back and confirms that too.

It covers the four exposure settings in qualificationSettings: iso, aperture, shutterSpeed and whiteBalance.

import {
    Camera,
    qualifyCameraSetting,
    type QualificationCamera,
} from '@darkgrade/slate'

const camera = new Camera()
await camera.connect()

const target: QualificationCamera = {
    read: async () => {
        const { controls } = await camera.getCapabilities()
        return { controls }
    },
    set: (setting, value) => camera.setControl(setting, String(value)),
}

const report = await qualifyCameraSetting(target, 'iso', 'ISO 800')
console.log(report.passed, report.restored)
Report fieldMeaning
passedThe camera read back the target, and then read back the original.
restoredThe original value is back, confirmed by a fresh read.
setting, original, targetWhat was tested.
observed, restoredValueWhat the camera read back after each write.
error, restorationErrorWhy the write or the restoration was not confirmed.

If restored is false, the camera may be left on the test value. Show restorationError and check the camera.

The original is always written back, even when the test write fails. Before it writes anything, the function throws when the test would prove nothing: the setting is not readable and writable now, the target or the current value is not in the camera's list, or the target equals the current value.

To see whether a test is possible without running it, cameraControlContract summarises the same four settings from one read:

import { cameraControlContract } from '@darkgrade/slate'

const { controls } = await camera.getCapabilities()
const contract = cameraControlContract({ controls })
console.log(contract.iso)
// { present: true, writable: true, value: 'ISO 400',
//   choices: […], status: 'ready' }

status is 'ready', 'absent', 'read-only-in-current-mode' or 'no-alternative-advertised' (fewer than two choices).

Bench models

Darkgrade runs Slate on physical cameras on its own test benches. validatedCameraModels lists those bench bodies by the model name each camera reports, and isValidatedModel checks a name against it, ignoring case and extra spaces. It is not the list of supported cameras: Darkgrade works with 97 Sony, Canon and Nikon cameras, all in Camera compatibility.

import {
    Camera,
    isValidatedModel,
    validatedCameraModels,
} from '@darkgrade/slate'

const camera = new Camera()
await camera.connect()
const { model } = await camera.getInfo()

console.log(isValidatedModel(model)) // true for 'ILCE-6700'
console.log(validatedCameraModels)
// ['ILCE-6700', 'ILME-FX2', 'Z6_3', 'Z5_2',
//  'Canon EOS R6 Mark III', 'Canon EOS R8 Mark II']

A model outside the list is not refused, and Slate treats it no differently: it tries each operation and reports what the camera can't do through getCapabilities().

isVerifiedFeature(feature, model) answers the same question for three vendor features confirmed on specific bodies: 'sony-wireless', 'sony-card-fallback' and 'nikon-wireless-status'. The bodies for each are in verifiedFeatureModels.

⌘I