Skip to content

Commit

Permalink
feat: time mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Apr 8, 2024
1 parent c45077c commit 9e469df
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/atem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ export class Atem extends BasicAtem {
return this.sendCommand(command)
}

public async setTimeMode(mode: Enums.TimeMode): Promise<void> {
const command = new Commands.TimeConfigCommand(mode)
return this.sendCommand(command)
}

public async requestTime(): Promise<void> {
const command = new Commands.TimeRequestCommand()
return this.sendCommand(command)
Expand Down
40 changes: 40 additions & 0 deletions src/commands/TimeConfigCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import * as Enums from '../enums'
import { BasicWritableCommand } from '.'
import { DeserializedCommand } from './CommandBase'
import { AtemState } from '../state'

export class TimeConfigCommand extends BasicWritableCommand<{ mode: Enums.TimeMode }> {
public static readonly rawName = 'CTCC'
public static readonly minimumVersion = Enums.ProtocolVersion.V8_1_1

constructor(mode: Enums.TimeMode) {
super({ mode })
}

public serialize(): Buffer {
const buffer = Buffer.alloc(4)
buffer.writeUInt8(this.properties.mode, 0)

return buffer
}
}

export class TimeConfigUpdateCommand extends DeserializedCommand<{ mode: Enums.TimeMode }> {
public static readonly rawName = 'TCCc'
public static readonly minimumVersion = Enums.ProtocolVersion.V8_1_1

constructor(mode: Enums.TimeMode) {
super({ mode })
}

public static deserialize(rawCommand: Buffer): TimeConfigUpdateCommand {
const mode = rawCommand.readUInt8(0)

return new TimeConfigUpdateCommand(mode)
}

public applyToState(state: AtemState): string {
state.settings.timeMode = this.properties.mode
return 'settings.timeMode'
}
}
1 change: 1 addition & 0 deletions src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ export * from './PowerStatusCommand'
export * from './StartupStateCommand'
export * from './TallyBySourceCommand'
export * from './TimeCommand'
export * from './TimeConfigCommand'
5 changes: 5 additions & 0 deletions src/enums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,3 +412,8 @@ export enum AudioInternalPortType {
AuxOut = 10,
AudioAuxOut = 11, // TODO - verify
}

export enum TimeMode {
FreeRun = 0,
TimeOfDay = 1,
}
3 changes: 2 additions & 1 deletion src/state/settings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VideoMode, MultiViewerLayout } from '../enums'
import { VideoMode, MultiViewerLayout, TimeMode } from '../enums'

export interface MultiViewerSourceState {
source: number
Expand Down Expand Up @@ -33,4 +33,5 @@ export interface SettingsState {
readonly multiViewers: Array<MultiViewer | undefined>
videoMode: VideoMode
mediaPool?: MediaPool
timeMode?: TimeMode
}

0 comments on commit 9e469df

Please sign in to comment.