mirror of
https://github.com/jwetzell/rttrp-js.git
synced 2026-08-20 06:19:03 +00:00
add encoder for RTTrPL packet
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import ChannelBlock from './lighting/channel-block';
|
||||
import LightingOutput from './lighting/lighting-output';
|
||||
import RTTrPL from './lighting/rttrpl';
|
||||
import Spot from './lighting/spot';
|
||||
import Universe from './lighting/universe';
|
||||
import CentroidAccelVelocity from './motion/centroid-accel-velocity';
|
||||
@@ -17,6 +18,7 @@ import RTTrPHeader from './rttrp-header';
|
||||
export const Encoders = {
|
||||
RTTrPHeader,
|
||||
RTTrPM,
|
||||
RTTrPL,
|
||||
Trackable,
|
||||
CentroidPosition,
|
||||
OrientationQuaternion,
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import RTTrPHeader from '../rttrp-header';
|
||||
|
||||
export default (
|
||||
packetId: number,
|
||||
context: number,
|
||||
lightingOutputs: Uint8Array[],
|
||||
isLittleEndian: boolean = false
|
||||
): Uint8Array => {
|
||||
let totalPacketSize = 18; //header size
|
||||
|
||||
lightingOutputs.forEach((lightingOutput) => {
|
||||
totalPacketSize += lightingOutput.length;
|
||||
});
|
||||
const bytes = new Uint8Array(totalPacketSize);
|
||||
|
||||
let dataOffset = 0;
|
||||
|
||||
const headerBytes = RTTrPHeader(0x4434, 0x02, packetId, 0x00, context, lightingOutputs, isLittleEndian);
|
||||
|
||||
bytes.set(headerBytes, dataOffset);
|
||||
dataOffset += headerBytes.length;
|
||||
lightingOutputs.forEach((lightingOutput) => {
|
||||
bytes.set(lightingOutput, dataOffset);
|
||||
dataOffset += lightingOutput.length;
|
||||
});
|
||||
return bytes;
|
||||
};
|
||||
Reference in New Issue
Block a user