Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: camera control float encoding #161

Merged
merged 3 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/commands/CameraControlCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,10 @@ export class CameraControlCommand extends BasicWritableCommand<CameraControlPack
buffer = Buffer.alloc(headerSize + padToMultiple(this.properties.numberData.length * 2, 8))
buffer.writeUint16BE(this.properties.numberData.length, header16BitPos)

// TODO - verify this encoding is correct
let offset = headerSize
for (let i = 0; i < this.properties.numberData.length; i++) {
const encodedValue = this.properties.numberData[i] * 0x7ff
buffer.writeInt16BE(encodedValue, offset)
for (const value of this.properties.numberData) {
// Values are encoded as 5.11 fixed point floats
buffer.writeInt16BE(value * 2048, offset)
offset += 2
}

Expand Down Expand Up @@ -239,10 +238,11 @@ export class CameraControlUpdateCommand extends DeserializedCommand<CameraContro
break
}
case CameraControlDataType.FLOAT: {
// TODO - verify this encoding is correct
for (let i = 0; i < count16Bit; i++) {
const decodedValue = rawCommand.readInt16BE(offset) / 0x7ff
props.numberData.push(decodedValue)
const decodedValue = rawCommand.readInt16BE(offset)

// Values are encoded as 5.11 fixed point floats
props.numberData.push(decodedValue / 2048)
offset += 2
}
break
Expand Down
2 changes: 2 additions & 0 deletions src/commands/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ describe('Commands vs LibAtem', () => {
case 'KeFS': // TODO - TMP!
case '_MvC': // Not all properties parsed
case 'FTSU': // Unkown props getting overwritten by generator: https://github.com/LibAtem/LibAtem/blob/master/LibAtem/Commands/DataTransfer/DataTransferDownloadRequestCommand.cs
case 'CCmd': // LibAtem is incorrect
case 'CCdP': // LibAtem is incorrect
continue
}

Expand Down