Skip to content

Commit 9e469df

Browse files
committedApr 8, 2024
feat: time mode
1 parent c45077c commit 9e469df

File tree

5 files changed

+53
-1
lines changed

5 files changed

+53
-1
lines changed
 

‎src/atem.ts

+5
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,11 @@ export class Atem extends BasicAtem {
439439
return this.sendCommand(command)
440440
}
441441

442+
public async setTimeMode(mode: Enums.TimeMode): Promise<void> {
443+
const command = new Commands.TimeConfigCommand(mode)
444+
return this.sendCommand(command)
445+
}
446+
442447
public async requestTime(): Promise<void> {
443448
const command = new Commands.TimeRequestCommand()
444449
return this.sendCommand(command)

‎src/commands/TimeConfigCommand.ts

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import * as Enums from '../enums'
2+
import { BasicWritableCommand } from '.'
3+
import { DeserializedCommand } from './CommandBase'
4+
import { AtemState } from '../state'
5+
6+
export class TimeConfigCommand extends BasicWritableCommand<{ mode: Enums.TimeMode }> {
7+
public static readonly rawName = 'CTCC'
8+
public static readonly minimumVersion = Enums.ProtocolVersion.V8_1_1
9+
10+
constructor(mode: Enums.TimeMode) {
11+
super({ mode })
12+
}
13+
14+
public serialize(): Buffer {
15+
const buffer = Buffer.alloc(4)
16+
buffer.writeUInt8(this.properties.mode, 0)
17+
18+
return buffer
19+
}
20+
}
21+
22+
export class TimeConfigUpdateCommand extends DeserializedCommand<{ mode: Enums.TimeMode }> {
23+
public static readonly rawName = 'TCCc'
24+
public static readonly minimumVersion = Enums.ProtocolVersion.V8_1_1
25+
26+
constructor(mode: Enums.TimeMode) {
27+
super({ mode })
28+
}
29+
30+
public static deserialize(rawCommand: Buffer): TimeConfigUpdateCommand {
31+
const mode = rawCommand.readUInt8(0)
32+
33+
return new TimeConfigUpdateCommand(mode)
34+
}
35+
36+
public applyToState(state: AtemState): string {
37+
state.settings.timeMode = this.properties.mode
38+
return 'settings.timeMode'
39+
}
40+
}

‎src/commands/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ export * from './PowerStatusCommand'
2222
export * from './StartupStateCommand'
2323
export * from './TallyBySourceCommand'
2424
export * from './TimeCommand'
25+
export * from './TimeConfigCommand'

‎src/enums/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,8 @@ export enum AudioInternalPortType {
412412
AuxOut = 10,
413413
AudioAuxOut = 11, // TODO - verify
414414
}
415+
416+
export enum TimeMode {
417+
FreeRun = 0,
418+
TimeOfDay = 1,
419+
}

‎src/state/settings.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { VideoMode, MultiViewerLayout } from '../enums'
1+
import { VideoMode, MultiViewerLayout, TimeMode } from '../enums'
22

33
export interface MultiViewerSourceState {
44
source: number
@@ -33,4 +33,5 @@ export interface SettingsState {
3333
readonly multiViewers: Array<MultiViewer | undefined>
3434
videoMode: VideoMode
3535
mediaPool?: MediaPool
36+
timeMode?: TimeMode
3637
}

0 commit comments

Comments
 (0)
Failed to load comments.