brilliant-msg 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,36 @@
1
+ export { BrilliantMsg, StdLua } from './brilliant-msg';
2
+ export { AsyncQueue } from './async-queue';
3
+ export { TxPlainText } from './tx/plain-text';
4
+ export type { TxPlainTextOptions } from './tx/plain-text';
5
+ export { TxCaptureSettings } from './tx/capture-settings';
6
+ export type { TxCaptureSettingsOptions } from './tx/capture-settings';
7
+ export { TxCode } from './tx/code';
8
+ export type { TxCodeOptions } from './tx/code';
9
+ export { TxImageSpriteBlock } from './tx/image-sprite-block';
10
+ export type { TxImageSpriteBlockOptions } from './tx/image-sprite-block';
11
+ export { TxManualExpSettings } from './tx/manual-exp-settings';
12
+ export type { TxManualExpSettingsOptions } from './tx/manual-exp-settings';
13
+ export { TxAutoExpSettings } from './tx/auto-exp-settings';
14
+ export type { TxAutoExpSettingsOptions } from './tx/auto-exp-settings';
15
+ export { TxSprite } from './tx/sprite';
16
+ export type { TxSpriteOptions } from './tx/sprite';
17
+ export { TxSpriteCoords } from './tx/sprite-coords';
18
+ export type { TxSpriteCoordsOptions } from './tx/sprite-coords';
19
+ export { TxTextSpriteBlock } from './tx/text-sprite-block';
20
+ export type { TxTextSpriteBlockOptions } from './tx/text-sprite-block';
21
+ export { RxAudio, RxAudioBitDepth, RxAudioSampleRate } from './rx/audio';
22
+ export type { RxAudioOptions } from './rx/audio';
23
+ export { RxIMU, IMUData } from './rx/imu';
24
+ export type { RxIMUOptions, IMURawData } from './rx/imu';
25
+ export { RxMeteringData } from './rx/metering-data';
26
+ export type { RxMeteringDataOptions, MeteringData } from './rx/metering-data';
27
+ export { RxAutoExpResult } from './rx/auto-exp-result';
28
+ export type { BrightnessDetails, BrightnessData, AutoExpResultData, RxAutoExpResultOptions } from './rx/auto-exp-result';
29
+ export { RxPhoto } from './rx/photo';
30
+ export type { RxPhotoOptions, JpegQuality } from './rx/photo';
31
+ export { RxTap } from './rx/tap';
32
+ export type { RxTapOptions } from './rx/tap';
33
+ export { RxClick, ClickType } from './rx/click';
34
+ export type { RxClickOptions } from './rx/click';
35
+ export { TxTextPage, RectangularTextLayout, CircularTextLayout, PageData } from './tx/text-page';
36
+ export type { TextLayout, TxTextPageOptions } from './tx/text-page';
@@ -0,0 +1,129 @@
1
+ import { BrilliantMsg } from '../brilliant-msg';
2
+ import { AsyncQueue } from '../async-queue';
3
+ /**
4
+ * Defines the supported audio sample rates.
5
+ */
6
+ export declare enum RxAudioSampleRate {
7
+ /** Sample rate of 8000 Hz. */
8
+ SAMPLE_RATE_8KHZ = 8000,
9
+ /** Sample rate of 16000 Hz. */
10
+ SAMPLE_RATE_16KHZ = 16000
11
+ }
12
+ /**
13
+ * Defines the supported audio bit depths.
14
+ */
15
+ export declare enum RxAudioBitDepth {
16
+ /** Bit depth of 8 bits per sample. */
17
+ BIT_DEPTH_8 = 8,
18
+ /** Bit depth of 16 bits per sample. */
19
+ BIT_DEPTH_16 = 16
20
+ }
21
+ /**
22
+ * Configuration options for the RxAudio class.
23
+ */
24
+ export interface RxAudioOptions {
25
+ /** Optional msgCode indicating a non-final audio chunk. Defaults to 0x05. */
26
+ nonFinalChunkMsgCode?: number;
27
+ /** Optional msgCode indicating the final audio chunk. Defaults to 0x06. */
28
+ finalChunkMsgCode?: number;
29
+ /** Optional msgCode to enable streaming mode. Defaults to false (clip mode). */
30
+ streaming?: boolean;
31
+ /** Optional audio sample rate. Defaults to 8000 Hz. */
32
+ sampleRate?: RxAudioSampleRate;
33
+ /** Optional audio bit depth. Defaults to 8 bits. */
34
+ bitDepth?: RxAudioBitDepth;
35
+ }
36
+ /**
37
+ * RxAudio class handles audio data streaming and processing.
38
+ * It can operate in two modes: streaming and single-clip mode.
39
+ * In streaming mode, it processes audio data in real-time.
40
+ * In single-clip mode, it accumulates audio data until a final chunk is received.
41
+ * The class provides methods to attach and detach from a BrilliantMsg instance,
42
+ * and to convert PCM data to WAV format.
43
+ * Depending on how it is constructed, it will return samples as either
44
+ * signed 8 or signed 16 bit integers, and the source bit depth in Lua should match.
45
+ */
46
+ export declare class RxAudio {
47
+ private nonFinalChunkMsgCode;
48
+ private finalChunkMsgCode;
49
+ private streaming;
50
+ private bitDepth;
51
+ private sampleRate;
52
+ /**
53
+ * Asynchronous queue for processed audio data chunks.
54
+ * Each chunk is an Int8Array or Int16Array, or null to signal the end of a stream/clip.
55
+ */
56
+ queue: AsyncQueue<Int8Array | Int16Array | null> | null;
57
+ /** @internal Buffer to accumulate audio chunks in non-streaming (clip) mode. */
58
+ private _audioBuffer;
59
+ /**
60
+ * Constructs an instance of the RxAudio class.
61
+ * @param options Configuration options for the audio handler.
62
+ */
63
+ constructor(options?: RxAudioOptions);
64
+ /**
65
+ * @internal Concatenates all audio chunks in the `_audioBuffer`.
66
+ * Used in non-streaming mode to assemble the complete audio clip.
67
+ * @returns A single Uint8Array containing all accumulated audio data.
68
+ */
69
+ private concatenateAudioData;
70
+ /**
71
+ * Handles incoming raw audio data chunks.
72
+ * This method is typically called by a `BrilliantMsg` instance when new audio data is received.
73
+ * It processes the data based on the configured mode (streaming or clip) and bit depth,
74
+ * then places the processed audio chunk (Int8Array or Int16Array) onto the `queue`.
75
+ * A null is placed on the queue to signal the end of a stream or clip.
76
+ * @param data A Uint8Array containing the raw audio data, prefixed with a msgCode byte.
77
+ */
78
+ handleData(data: Uint8Array): void;
79
+ /**
80
+ * Attaches this RxAudio instance to a BrilliantMsg object to receive audio data.
81
+ * It initializes the audio queue and registers a handler for incoming data.
82
+ * @param frame The BrilliantMsg instance to attach to.
83
+ * @returns A Promise that resolves to the `AsyncQueue` where audio chunks will be placed.
84
+ */
85
+ attach(frame: BrilliantMsg): Promise<AsyncQueue<Int8Array | Int16Array | null>>;
86
+ /**
87
+ * Detaches this RxAudio instance from a BrilliantMsg object.
88
+ * It unregisters the data handler and clears the audio queue.
89
+ * @param frame The BrilliantMsg instance to detach from.
90
+ */
91
+ detach(frame: BrilliantMsg): void;
92
+ /**
93
+ * @internal Helper function to write a string to a DataView.
94
+ * Used for constructing WAV file headers.
95
+ * @param view The DataView to write to.
96
+ * @param offset The offset at which to start writing.
97
+ * @param str The string to write.
98
+ */
99
+ private static writeString;
100
+ /**
101
+ * Converts raw PCM audio data to WAV file format (as a Uint8Array).
102
+ * @param pcmData The raw PCM data. For 8-bit, assumes signed samples that will be converted to unsigned for WAV.
103
+ * @param sampleRate The sample rate of the audio (e.g., 8000 Hz). Defaults to 8000.
104
+ * @param bitsPerSample The number of bits per sample (e.g., 8 or 16). Defaults to 8.
105
+ * @param channels The number of audio channels (e.g., 1 for mono). Defaults to 1.
106
+ * @returns A Uint8Array containing the WAV file data.
107
+ */
108
+ static toWavBytes(pcmData: Uint8Array, sampleRate?: number, bitsPerSample?: number, channels?: number): Uint8Array;
109
+ /**
110
+ * Converts signed 8-bit PCM data (provided as a Uint8Array) to a Float32Array.
111
+ * The samples are scaled to the range [-1.0, 1.0].
112
+ * Note: Assumes input samples are signed bytes. Reinterprets Uint8Array as Int8Array.
113
+ * Samples are scaled by 1/64 (instead of 1/128) and clamped to [-1.0, 1.0]
114
+ * to account for typical microphone dynamic range usage.
115
+ * @param pcmData The Uint8Array containing signed 8-bit PCM data.
116
+ * @returns A Float32Array with samples scaled to [-1.0, 1.0].
117
+ */
118
+ static pcm8BitToFloat32(pcmData: Uint8Array): Float32Array<ArrayBuffer>;
119
+ /**
120
+ * Converts signed 16-bit PCM data (provided as a Uint8Array) to a Float32Array.
121
+ * The samples are scaled to the range [-1.0, 1.0].
122
+ * Note: Assumes input Uint8Array contains little-endian signed 16-bit samples.
123
+ * Samples are scaled by 1/16384 (instead of 1/32768) and clamped to [-1.0, 1.0]
124
+ * to account for typical microphone dynamic range usage.
125
+ * @param pcmData The Uint8Array containing signed 16-bit PCM data (little-endian).
126
+ * @returns A Float32Array with samples scaled to [-1.0, 1.0].
127
+ */
128
+ static pcm16BitToFloat32(pcmData: Uint8Array): Float32Array<ArrayBuffer>;
129
+ }
@@ -0,0 +1,85 @@
1
+ import { BrilliantMsg } from '../brilliant-msg';
2
+ import { AsyncQueue } from '../async-queue';
3
+ /**
4
+ * Interface for the detailed brightness metrics (matrix or spot).
5
+ */
6
+ export interface BrightnessDetails {
7
+ /** Red channel brightness component. */
8
+ r: number;
9
+ /** Green channel brightness component. */
10
+ g: number;
11
+ /** Blue channel brightness component. */
12
+ b: number;
13
+ /** Average brightness across R, G, B channels. */
14
+ average: number;
15
+ }
16
+ /**
17
+ * Interface for the overall brightness data structure.
18
+ */
19
+ export interface BrightnessData {
20
+ /** Center-weighted average brightness of the scene. */
21
+ center_weighted_average: number;
22
+ /** Overall scene brightness. */
23
+ scene: number;
24
+ /** Detailed brightness metrics using matrix metering. */
25
+ matrix: BrightnessDetails;
26
+ /** Detailed brightness metrics using spot metering. */
27
+ spot: BrightnessDetails;
28
+ }
29
+ /**
30
+ * Interface for the structured auto exposure result data.
31
+ */
32
+ export interface AutoExpResultData {
33
+ /** The error value from the auto exposure algorithm. */
34
+ error: number;
35
+ /** The calculated shutter speed (exposure time). */
36
+ shutter: number;
37
+ /** The calculated analog gain. */
38
+ analog_gain: number;
39
+ /** The red channel gain. */
40
+ red_gain: number;
41
+ /** The green channel gain. */
42
+ green_gain: number;
43
+ /** The blue channel gain. */
44
+ blue_gain: number;
45
+ /** Detailed brightness data used for auto exposure. */
46
+ brightness: BrightnessData;
47
+ }
48
+ /**
49
+ * Options for RxAutoExpResult constructor.
50
+ */
51
+ export interface RxAutoExpResultOptions {
52
+ /** Optional message code to identify auto exposure result packets. Defaults to 0x11. */
53
+ msgCode?: number;
54
+ }
55
+ /**
56
+ * RxAutoExpResult class handles processing of auto exposure result data packets.
57
+ */
58
+ export declare class RxAutoExpResult {
59
+ private msgCode;
60
+ /** Asynchronous queue for received auto exposure result data. Null if not attached. */
61
+ queue: AsyncQueue<AutoExpResultData | null> | null;
62
+ /**
63
+ * Initialize receive handler for processing auto exposure result data.
64
+ * @param options Configuration options for the handler.
65
+ * Includes `msgCode` (default: 0x11)
66
+ */
67
+ constructor(options?: RxAutoExpResultOptions);
68
+ /**
69
+ * Process incoming auto exposure result data packets.
70
+ * @param data Uint8Array containing auto exposure result data with a msgCode byte prefix,
71
+ * followed by 16 little-endian floats (64 bytes).
72
+ */
73
+ handleData(data: Uint8Array): void;
74
+ /**
75
+ * Attach the receive handler to the Frame data response.
76
+ * @param frame The BrilliantMsg instance.
77
+ * @returns A promise that resolves to an AsyncQueue that will receive AutoExpResultData objects.
78
+ */
79
+ attach(frame: BrilliantMsg): Promise<AsyncQueue<AutoExpResultData | null>>;
80
+ /**
81
+ * Detach the receive handler from the Frame data response and clean up resources.
82
+ * @param frame The BrilliantMsg instance.
83
+ */
84
+ detach(frame: BrilliantMsg): void;
85
+ }
@@ -0,0 +1,50 @@
1
+ import { BrilliantMsg } from '../brilliant-msg';
2
+ import { AsyncQueue } from '../async-queue';
3
+ /**
4
+ * Enum representing the types of tap/click detected by the Frame device.
5
+ */
6
+ export declare enum ClickType {
7
+ /** A single tap/click. */
8
+ SINGLE = 1,
9
+ /** A double tap/click. */
10
+ DOUBLE = 2,
11
+ /** A long press. */
12
+ LONG = 3
13
+ }
14
+ /**
15
+ * Options for RxClick constructor.
16
+ */
17
+ export interface RxClickOptions {
18
+ /** Optional msgCode to identify click data packets. Defaults to 0x0B. */
19
+ clickFlag?: number;
20
+ }
21
+ /**
22
+ * RxClick handles incoming tap/click events from the Frame device.
23
+ * It processes raw BLE data and enqueues typed ClickType values.
24
+ */
25
+ export declare class RxClick {
26
+ private clickFlag;
27
+ /** Asynchronous queue for received ClickType values. Null if not attached. */
28
+ queue: AsyncQueue<ClickType | null> | null;
29
+ /**
30
+ * Constructs an instance of the RxClick class.
31
+ * @param options Configuration options for the click handler.
32
+ */
33
+ constructor(options?: RxClickOptions);
34
+ /**
35
+ * Process incoming click data packets.
36
+ * @param data Uint8Array containing click data: [clickFlag, clickType].
37
+ */
38
+ handleData(data: Uint8Array): void;
39
+ /**
40
+ * Attach the click handler to the Frame data response.
41
+ * @param frame The BrilliantMsg instance.
42
+ * @returns A promise that resolves to an AsyncQueue that will receive ClickType values.
43
+ */
44
+ attach(frame: BrilliantMsg): Promise<AsyncQueue<ClickType | null>>;
45
+ /**
46
+ * Detach the click handler from the Frame data response and clean up resources.
47
+ * @param frame The BrilliantMsg instance.
48
+ */
49
+ detach(frame: BrilliantMsg): void;
50
+ }
@@ -0,0 +1,77 @@
1
+ import { BrilliantMsg } from '../brilliant-msg';
2
+ import { AsyncQueue } from '../async-queue';
3
+ /**
4
+ * Interface for raw IMU data.
5
+ */
6
+ export interface IMURawData {
7
+ /** Raw compass data as a tuple: `[x, y, z]`. */
8
+ compass: [number, number, number];
9
+ /** Raw accelerometer data as a tuple: `[x, y, z]`. */
10
+ accel: [number, number, number];
11
+ }
12
+ /**
13
+ * Class for processed IMU data.
14
+ * Contains smoothed compass and accelerometer data, and optionally the raw data.
15
+ * Also provides calculated pitch and roll values.
16
+ */
17
+ export declare class IMUData {
18
+ /** Smoothed compass data as a tuple: `[x, y, z]`. */
19
+ compass: [number, number, number];
20
+ /** Smoothed accelerometer data as a tuple: `[x, y, z]`. */
21
+ accel: [number, number, number];
22
+ /** Optional raw IMU data. */
23
+ raw?: IMURawData;
24
+ /**
25
+ * Constructs an instance of IMUData.
26
+ * @param compass Smoothed compass data `[x, y, z]`.
27
+ * @param accel Smoothed accelerometer data `[x, y, z]`.
28
+ * @param raw Optional raw IMU data.
29
+ */
30
+ constructor(compass: [number, number, number], accel: [number, number, number], raw?: IMURawData);
31
+ /** Calculated pitch in degrees. */
32
+ get pitch(): number;
33
+ /** Calculated roll in degrees. */
34
+ get roll(): number;
35
+ }
36
+ /**
37
+ * Options for RxIMU constructor.
38
+ */
39
+ export interface RxIMUOptions {
40
+ /** Optional msgCode to identify IMU data packets. Defaults to 0x0A. */
41
+ msgCode?: number;
42
+ /** Optional number of samples to average for smoothing. Defaults to 1 (no smoothing). */
43
+ smoothingSamples?: number;
44
+ }
45
+ /**
46
+ * RxIMU class handles IMU data processing.
47
+ * It processes magnetometer and accelerometer data, providing smoothed values.
48
+ */
49
+ export declare class RxIMU {
50
+ private msgCode;
51
+ private smoothingSamples;
52
+ /** Asynchronous queue for received IMUData objects. Null if not attached. */
53
+ queue: AsyncQueue<IMUData | null> | null;
54
+ private compassBuffer;
55
+ private accelBuffer;
56
+ /**
57
+ * Constructs an instance of the RxIMU class.
58
+ * @param options Configuration options for the IMU handler.
59
+ */
60
+ constructor(options?: RxIMUOptions);
61
+ /**
62
+ * Process incoming IMU data packets.
63
+ * @param data Uint8Array containing IMU data with msgCode byte prefix.
64
+ */
65
+ handleData(data: Uint8Array): void;
66
+ /**
67
+ * Attach the IMU handler to the Frame data response.
68
+ * @param frame The BrilliantMsg instance.
69
+ * @returns A promise that resolves to an AsyncQueue that will receive IMUData objects.
70
+ */
71
+ attach(frame: BrilliantMsg): Promise<AsyncQueue<IMUData | null>>;
72
+ /**
73
+ * Detach the IMU handler from the Frame data response and clean up resources.
74
+ * @param frame The BrilliantMsg instance.
75
+ */
76
+ detach(frame: BrilliantMsg): void;
77
+ }
@@ -0,0 +1,56 @@
1
+ import { BrilliantMsg } from '../brilliant-msg';
2
+ import { AsyncQueue } from '../async-queue';
3
+ /**
4
+ * Interface for the structured metering data.
5
+ */
6
+ export interface MeteringData {
7
+ /** Spot metering red channel value. */
8
+ spot_r: number;
9
+ /** Spot metering green channel value. */
10
+ spot_g: number;
11
+ /** Spot metering blue channel value. */
12
+ spot_b: number;
13
+ /** Matrix metering red channel value. */
14
+ matrix_r: number;
15
+ /** Matrix metering green channel value. */
16
+ matrix_g: number;
17
+ /** Matrix metering blue channel value. */
18
+ matrix_b: number;
19
+ }
20
+ /**
21
+ * Options for RxMeteringData constructor.
22
+ */
23
+ export interface RxMeteringDataOptions {
24
+ /** Optional message code to identify metering data packets. Defaults to 0x12. */
25
+ msgCode?: number;
26
+ }
27
+ /**
28
+ * RxMeteringData class handles processing of metering data packets.
29
+ */
30
+ export declare class RxMeteringData {
31
+ private msgCode;
32
+ /** Asynchronous queue for received MeteringData objects. Null if not attached. */
33
+ queue: AsyncQueue<MeteringData | null> | null;
34
+ /**
35
+ * Constructs an instance of the RxMeteringData class.
36
+ * @param options Configuration options for the metering data handler.
37
+ */
38
+ constructor(options?: RxMeteringDataOptions);
39
+ /**
40
+ * Process incoming metering data packets.
41
+ * @param data Uint8Array containing metering data with a msgCode byte prefix,
42
+ * followed by 6 unsigned bytes (spot r,g,b, matrix r,g,b).
43
+ */
44
+ handleData(data: Uint8Array): void;
45
+ /**
46
+ * Attach the receive handler to the Frame data response.
47
+ * @param frame The BrilliantMsg instance.
48
+ * @returns A promise that resolves to an AsyncQueue that will receive MeteringData objects.
49
+ */
50
+ attach(frame: BrilliantMsg): Promise<AsyncQueue<MeteringData | null>>;
51
+ /**
52
+ * Detach the receive handler from the Frame data response and clean up resources.
53
+ * @param frame The BrilliantMsg instance.
54
+ */
55
+ detach(frame: BrilliantMsg): void;
56
+ }
@@ -0,0 +1,81 @@
1
+ import { BrilliantMsg } from '../brilliant-msg';
2
+ import { AsyncQueue } from '../async-queue';
3
+ /** Defines the available JPEG quality settings. */
4
+ export type JpegQuality = 'VERY_LOW' | 'LOW' | 'MEDIUM' | 'HIGH' | 'VERY_HIGH';
5
+ /**
6
+ * Configuration options for the RxPhoto class.
7
+ */
8
+ export interface RxPhotoOptions {
9
+ /** Optional msgCode indicating a non-final photo data chunk. Defaults to 0x07. */
10
+ nonFinalChunkMsgCode?: number;
11
+ /** Optional msgCode indicating the final photo data chunk. Defaults to 0x08. */
12
+ finalChunkMsgCode?: number;
13
+ /** Optional msgCode to rotate the image to be upright. Defaults to true. */
14
+ upright?: boolean;
15
+ /** Optional msgCode indicating if the photo data is raw (headerless JPEG). Defaults to false. */
16
+ isRaw?: boolean;
17
+ /** Optional JPEG quality setting. Required for raw images if header is not cached. */
18
+ quality?: JpegQuality | null;
19
+ /** Optional photo resolution (e.g., height in pixels). Must be an even number between 100 and 720. Required for raw images if header is not cached. */
20
+ resolution?: number | null;
21
+ }
22
+ /**
23
+ * RxPhoto class handles JPEG image data streaming and processing.
24
+ * It can process JPEG images with or without a header ("raw" mode), although at least one
25
+ * compatible JPEG header must be cached before using raw mode.
26
+ * It can also rotate images 90 degrees counter-clockwise to upright (default behavior).
27
+ * Different JPEG qualities and resolutions can be specified.
28
+ */
29
+ export declare class RxPhoto {
30
+ private static _jpegHeaderMap;
31
+ private nonFinalChunkMsgCode;
32
+ private finalChunkMsgCode;
33
+ private upright;
34
+ private isRaw;
35
+ private quality;
36
+ private resolution;
37
+ /** Asynchronous queue for received photo data (Uint8Array). Null if not attached. */
38
+ queue: AsyncQueue<Uint8Array> | null;
39
+ private _imageDataChunks;
40
+ /**
41
+ * Constructs an instance of the RxPhoto class.
42
+ * @param options Configuration options for the photo handler.
43
+ */
44
+ constructor(options?: RxPhotoOptions);
45
+ /**
46
+ * Checks if a JPEG header is cached for the given quality and resolution.
47
+ * @param quality The JPEG quality.
48
+ * @param resolution The photo resolution.
49
+ * @returns True if a header is cached, false otherwise.
50
+ */
51
+ static hasJpegHeader(quality: JpegQuality, resolution: number): boolean;
52
+ private concatenateImageData;
53
+ /**
54
+ * Handles incoming raw photo data chunks.
55
+ * This method is typically called by a `BrilliantMsg` instance when new photo data is received.
56
+ * It accumulates chunks and, upon receiving the final chunk, processes the complete image.
57
+ * The processed image (as a Uint8Array) is then placed onto the `queue`.
58
+ * @param data A Uint8Array containing the raw photo data chunk, prefixed with a msgCode byte.
59
+ */
60
+ handleData(data: Uint8Array): void;
61
+ private _processCompleteImage;
62
+ /**
63
+ * Attaches this RxPhoto instance to a BrilliantMsg object to receive photo data.
64
+ * It initializes the photo data queue and registers a handler for incoming data chunks.
65
+ * @param frame The BrilliantMsg instance to attach to.
66
+ * @returns A Promise that resolves to the `AsyncQueue` where complete photo data (Uint8Array) will be placed.
67
+ */
68
+ attach(frame: BrilliantMsg): Promise<AsyncQueue<Uint8Array>>;
69
+ /**
70
+ * Detaches this RxPhoto instance from a BrilliantMsg object.
71
+ * It unregisters the data handler and clears the photo data queue and any pending chunks.
72
+ * @param frame The BrilliantMsg instance to detach from.
73
+ */
74
+ detach(frame: BrilliantMsg): void;
75
+ /**
76
+ * Rotates a JPEG image 90 degrees counter-clockwise using an offscreen canvas.
77
+ * @param inputBytes The input JPEG image as a Uint8Array.
78
+ * @returns the rotated JPEG image as a Uint8Array.
79
+ */
80
+ rotateJpeg90CounterClockwise(inputBytes: Uint8Array): Promise<Uint8Array>;
81
+ }
@@ -0,0 +1,62 @@
1
+ import { BrilliantMsg } from '../brilliant-msg';
2
+ import { AsyncQueue } from '../async-queue';
3
+ /**
4
+ * Configuration options for the RxTap class.
5
+ */
6
+ export interface RxTapOptions {
7
+ /**
8
+ * Optional msgCode byte used to identify tap event packets received from the Frame device.
9
+ * Defaults to 0x09.
10
+ */
11
+ msgCode?: number;
12
+ /**
13
+ * Optional time window in seconds within which multiple taps are counted as a single event.
14
+ * Defaults to 0.3 seconds.
15
+ */
16
+ threshold?: number;
17
+ }
18
+ /**
19
+ * RxTap class handles tap events from the device.
20
+ * It counts the number of taps within a specified threshold time.
21
+ * It uses a queue to manage tap events and provides methods to attach and detach from a BrilliantMsg instance.
22
+ * It also debounces taps that occur too close together (40ms).
23
+ * The tap count is reset if no taps are detected within the threshold time.
24
+ */
25
+ export declare class RxTap {
26
+ private msgCode;
27
+ private threshold;
28
+ /** Asynchronous queue for tap count events. Each event is a number representing the count of taps. Null if not attached. */
29
+ queue: AsyncQueue<number> | null;
30
+ private lastTapTime;
31
+ private tapCount;
32
+ private thresholdTimeoutId;
33
+ /**
34
+ * Constructs an instance of the RxTap class.
35
+ * @param options Configuration options for the tap handler.
36
+ * Includes `msgCode` (default: 0x09) and `threshold` in seconds (default: 0.3).
37
+ */
38
+ constructor(options?: RxTapOptions);
39
+ private resetThresholdTimer;
40
+ private thresholdTimeout;
41
+ /**
42
+ * Handles incoming tap event data packets.
43
+ * This method is typically called by a `BrilliantMsg` instance when a tap event is received.
44
+ * It debounces rapid taps and counts taps within a defined threshold.
45
+ * The accumulated tap count is placed onto the `queue` when the threshold timer expires.
46
+ * @param data A Uint8Array containing the tap event data (usually just the msgCode byte).
47
+ */
48
+ handleData(data: Uint8Array): void;
49
+ /**
50
+ * Attaches this RxTap instance to a BrilliantMsg object to receive tap event data.
51
+ * It initializes the tap event queue and registers a handler for incoming data.
52
+ * @param frame The BrilliantMsg instance to attach to.
53
+ * @returns A Promise that resolves to the `AsyncQueue` where tap counts (number) will be placed.
54
+ */
55
+ attach(frame: BrilliantMsg): Promise<AsyncQueue<number>>;
56
+ /**
57
+ * Detaches this RxTap instance from a BrilliantMsg object.
58
+ * It unregisters the data handler, clears any active timers, and clears the event queue.
59
+ * @param frame The BrilliantMsg instance to detach from.
60
+ */
61
+ detach(frame: BrilliantMsg): void;
62
+ }
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Options for configuring auto exposure and gain settings.
3
+ */
4
+ export interface TxAutoExpSettingsOptions {
5
+ /** Optional zero-based index into metering modes ['SPOT', 'CENTER_WEIGHTED', 'AVERAGE'] (0, 1, or 2). Defaults to 1 (CENTER_WEIGHTED). */
6
+ meteringIndex?: number;
7
+ /** Optional target exposure value (0.0-1.0). Defaults to 0.1. */
8
+ exposure?: number;
9
+ /** Optional speed of exposure adjustments (0.0-1.0). Defaults to 0.45. */
10
+ exposureSpeed?: number;
11
+ /** Optional maximum shutter value (4-16383). Defaults to 16383. */
12
+ shutterLimit?: number;
13
+ /** Optional maximum analog gain value (1-248). Defaults to 16. */
14
+ analogGainLimit?: number;
15
+ /** Optional speed of white balance adjustments (0.0-1.0). Defaults to 0.5. */
16
+ whiteBalanceSpeed?: number;
17
+ /** Optional maximum gain value for red, green, blue channels (0-1023). Defaults to 287. */
18
+ rgbGainLimit?: number;
19
+ }
20
+ /**
21
+ * Message for auto exposure and gain settings.
22
+ */
23
+ export declare class TxAutoExpSettings {
24
+ /**
25
+ * Zero-based index into ['SPOT', 'CENTER_WEIGHTED', 'AVERAGE'] i.e. 0, 1 or 2.
26
+ */
27
+ meteringIndex: number;
28
+ /**
29
+ * Target exposure value (0.0-1.0)
30
+ */
31
+ exposure: number;
32
+ /**
33
+ * Speed of exposure adjustments (0.0-1.0)
34
+ */
35
+ exposureSpeed: number;
36
+ /**
37
+ * Maximum shutter value (4-16383)
38
+ */
39
+ shutterLimit: number;
40
+ /**
41
+ * Maximum analog gain value (1-248)
42
+ */
43
+ analogGainLimit: number;
44
+ /**
45
+ * Speed of white balance adjustments (0.0-1.0)
46
+ */
47
+ whiteBalanceSpeed: number;
48
+ /**
49
+ * Maximum gain value for red, green, blue channels (0-1023)
50
+ */
51
+ rgbGainLimit: number;
52
+ /**
53
+ * Constructs an instance of TxAutoExpSettings.
54
+ * @param options Configuration options for auto exposure and gain settings.
55
+ */
56
+ constructor(options?: TxAutoExpSettingsOptions);
57
+ /**
58
+ * Packs the settings into 9 bytes.
59
+ * @returns Uint8Array Binary representation of the message (9 bytes)
60
+ */
61
+ pack(): Uint8Array;
62
+ }