strand_cam_types/lib.rs
1// Copyright (C) The Strand-Braid Authors
2// SPDX-License-Identifier: MIT OR Apache-2.0
3
4//! Core types for camera control and configuration in the [Strand
5//! Camera](https://strawlab.org/strand-cam) ecosystem.
6
7use serde::{Deserialize, Serialize};
8use strand_cam_enum_iter::EnumIter;
9
10/// Automatic control mode for camera features.
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
12pub enum AutoMode {
13 /// Automatic control is disabled.
14 Off,
15 /// Automatic control runs once then stops.
16 Once,
17 /// Automatic control runs continuously.
18 #[default]
19 Continuous,
20}
21
22// use Debug to impl Display
23impl std::fmt::Display for AutoMode {
24 fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::result::Result<(), std::fmt::Error> {
25 std::fmt::Debug::fmt(self, fmt)
26 }
27}
28
29impl EnumIter for AutoMode {
30 fn variants() -> Vec<Self> {
31 vec![AutoMode::Off, AutoMode::Once, AutoMode::Continuous]
32 }
33}
34
35/// Camera trigger enable state.
36#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
37pub enum TriggerMode {
38 /// Triggering is disabled.
39 Off,
40 /// Triggering is enabled.
41 On,
42}
43
44/// Camera trigger type selector.
45#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
46#[non_exhaustive]
47pub enum TriggerSelector {
48 /// Trigger for starting image acquisition.
49 AcquisitionStart,
50 /// Trigger for starting frame capture.
51 FrameStart,
52 /// Trigger for starting a burst of frames.
53 FrameBurstStart,
54 /// Trigger for exposure timing.
55 ExposureActive,
56}
57
58/// Camera acquisition mode.
59#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
60pub enum AcquisitionMode {
61 /// Continuous frame acquisition.
62 Continuous,
63 /// Single frame acquisition.
64 SingleFrame,
65 /// Multiple frame acquisition.
66 MultiFrame,
67}