From ddfcfc91cfb83f207bd7312301f10c014d96bc9f Mon Sep 17 00:00:00 2001 From: Baku Hashimoto Date: Fri, 6 Oct 2023 22:51:35 +0900 Subject: [PATCH] Update README and JSDocs --- README.md | 96 ++++++++++++++++++++++++-------------------------- src/configs.ts | 8 +++++ 2 files changed, 54 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 4c613d6..1120e4e 100644 --- a/README.md +++ b/README.md @@ -56,11 +56,9 @@ const cam = cameras[0] await cam.init() await cam.get('model') -await cam.getModel() // -> 'Lumix S5' await cam.set('shutterSpeed', '1/1000') -await cam.setShutterSpeed('1/1000') const exposureModeDesc = await cam.getDesc('exposureMode') console.log(exposureModeDesc) @@ -103,64 +101,62 @@ await cam.close() This is a list of ConfigName and their value types: -| ConfigName | ConfigType | Example | -| -------------------- | ---------------------- | ----------------------------------------------------------- | -| aperture | `Aperture` | `2.2`, `5.6`, `'auto'` | -| batteryLevel | `BatteryLevel` | `50`, `100`, `'ac'`, `'low'` (Represented in range `0-100`) | -| burstInterval | `number` | | -| burstNumber | `number` | | -| canRunAutoFocus | `boolean` | | -| canRunManualFocus | `boolean` | | -| canStartLiveview | `boolean` | | -| canTakePicture | `boolean` | | -| captureDelay | `number` | | -| colorMode | `string` | `V-Log`, `Teal and Orange`, `CineV`... (vendor-specific) | -| colorTemperature | `number` | `2600`, `5500` | -| contrast | `number` | | -| dateTime | `Date` | | -| destinationToSave | `string` | 'camera', 'pc', 'camera,pc' | -| digitalZoom | `number` | | -| driveMode | `DriveMode` | `'normal'`, `'burst'`, `'interval'` | -| exposureComp | `string` | `'-1 1/3'` `'-1/2'`, `'0'`, `'+2 1/3'` | -| exposureMeteringMode | `ExposureMeteringMode` | `'average'`, '`multi-spot'`, `'center-spot'`... | -| exposureMode | `ExposureMode` | `'P'`, `'A'`, `'S'`, `'M'` | -| facingMode | `string` | `'user'`, `'environemnt'`... (Webcam fallback only) | -| flashMode | `FlashMode` | `'auto'`, `'off'`, `'fill'`... | -| focalLength | `FocalLength` | `35`, `55`, `105`, `'spherical'` (= Theta S, Insta360) | -| focusDistance | `number` | | -| focusMeteringMode | `FocusMeteringMode` | `'center-spot'`, `'multi-spot'` | -| focusMode | `FocusMode` | | -| functionalMode | `FunctionalMode` | `'standard'`, `'sleep'` | -| imageAspect | `string` | `'16:9'`, `'3:2'`, `'a size'` | -| imageQuality | `string` | `'fine'`, `'raw,fine'`, `'raw'` (comma-separated) | -| imageSize | `string` | `'L'`, `'M'`, `'S'`, `'1024x768'` | -| iso | `ISO` | `160`, `3200`, `'auto'` | -| liveviewEnabled | `boolean` | | -| liveviewMagnifyRatio | `number` | | -| liveviewSize | `string` | | -| manualFocusOptions | `ManualFocusOption[]` | `['near:2', 'near:1', 'far:1', 'far:2']` (`3` at max speed) | -| model | `string` | | -| sharpness | `number` | | -| shutterSpeed | `string` | `'30'`, `'1.5'`, `'1/200'`, `'1/6400'` | -| timelapseInterval | `number` | | -| timelapseNumber | `number` | | -| whiteBalance | `WhiteBalance` | `'auto'`, `'cloud'`, `'daylight'`... | +| ConfigName | ConfigType | Example | +| -------------------- | ---------------------- | ------------------------------------------------------------------------------------------ | +| aperture | `Aperture` | `2.2`, `5.6`, `'auto'` | +| autoFocusFrameCenter | `Vec2` | The center of auto focus frame. Normalized from [0, 0] (top-left) to [1, 1] (bottom-right) | +| autoFocusFrameSize | `string` | `large`, `medium`, `small`, `64x64` | +| batteryLevel | `BatteryLevel` | `50`, `100`, `'ac'`, `'low'` (Represented in range `0-100`) | +| burstInterval | `number` | | +| burstNumber | `number` | | +| canRunAutoFocus | `boolean` | | +| canRunManualFocus | `boolean` | | +| canStartLiveview | `boolean` | | +| canTakePicture | `boolean` | | +| captureDelay | `number` | | +| colorMode | `string` | `V-Log`, `Teal and Orange`, `CineV`... (vendor-specific) | +| colorTemperature | `number` | `2600`, `5500` | +| contrast | `number` | | +| dateTime | `Date` | | +| destinationToSave | `string` | 'camera', 'pc', 'camera,pc' | +| digitalZoom | `number` | | +| driveMode | `DriveMode` | `'normal'`, `'burst'`, `'interval'` | +| exposureComp | `string` | `'-1 1/3'` `'-1/2'`, `'0'`, `'+2 1/3'` | +| exposureMeteringMode | `ExposureMeteringMode` | `'average'`, '`multi-spot'`, `'center-spot'`... | +| exposureMode | `ExposureMode` | `'P'`, `'A'`, `'S'`, `'M'` | +| facingMode | `string` | `'user'`, `'environemnt'`... (Webcam fallback only) | +| flashMode | `FlashMode` | `'auto'`, `'off'`, `'fill'`... | +| focalLength | `FocalLength` | `35`, `55`, `105`, `'spherical'` (= Theta S, Insta360) | +| focusDistance | `number` | | +| focusMeteringMode | `FocusMeteringMode` | `'center-spot'`, `'multi-spot'` | +| focusMode | `FocusMode` | | +| functionalMode | `FunctionalMode` | `'standard'`, `'sleep'` | +| imageAspect | `string` | `'16:9'`, `'3:2'`, `'a size'` | +| imageQuality | `string` | `'fine'`, `'raw,fine'`, `'raw'` (comma-separated) | +| imageSize | `string` | `'L'`, `'M'`, `'S'`, `'1024x768'` | +| iso | `ISO` | `160`, `3200`, `'auto'` | +| liveviewEnabled | `boolean` | | +| liveviewMagnifyRatio | `number` | | +| liveviewSize | `string` | | +| manualFocusOptions | `ManualFocusOption[]` | `['near:2', 'near:1', 'far:1', 'far:2']` (`3` at max speed) | +| model | `string` | | +| sharpness | `number` | | +| shutterSpeed | `string` | `'30'`, `'1.5'`, `'1/200'`, `'1/6400'` | +| timelapseInterval | `number` | | +| timelapseNumber | `number` | | +| whiteBalance | `WhiteBalance` | `'auto'`, `'cloud'`, `'daylight'`... | The `configName` mentioned in the subsequent sample code can be replaced with the names shown above. ### Getter/Setter -You can retrieve and modify configs by two methods outlined below: +You can retrieve and modify configs like code shown below: ```ts // 1. Specify a name of config as the first argument tethr.get('configName'): Promise tethr.set('configName', value): Promise -// 2. Directly call a getter/setter methods defined per config -tethr.getConfigName(): Promise -tethr.setConfigName(): Promise - // Setters return the following object: interface OperationResult { status: 'ok' | 'unsupported' | 'invalid parameter' | 'busy' | 'general error' @@ -169,7 +165,7 @@ interface OperationResult { ### Config Descriptor -If you want to obtain information about a config, such as its writability and a list of valid values, you can use the `tethr.getDesc('configName')` or `tethr.getConfigNameDesc` methods. These methods return a descriptor object. +If you want to obtain information about a config, such as its writability and a list of valid values, you can use the `cam.getDesc('configName')` methods. These methods return a descriptor object. ```ts interface ConfigDesc { diff --git a/src/configs.ts b/src/configs.ts index d112e08..68157a7 100644 --- a/src/configs.ts +++ b/src/configs.ts @@ -1,8 +1,16 @@ import {BiMap} from 'bim' import {Vec2} from 'linearly' +/** + * Aperture value. `'auto'` means auto aperture. + * @example `'auto', 5.6, 9` + */ export type Aperture = 'auto' | number +/** + * Battery level represented as a number between `0` and `100`. `100` means full battery. + * . `'ac'` means AC power, `'low'` means low battery. + */ export type BatteryLevel = 'ac' | 'low' | number export type DriveMode = 'normal' | 'burst' | 'timelapse'