add encoder for channel-block

This commit is contained in:
2025-03-15 13:08:37 -05:00
parent 1c8536e27a
commit f8f3f060dc
3 changed files with 24 additions and 1 deletions
+2
View File
@@ -1,3 +1,4 @@
import ChannelBlock from './lighting/channel-block';
import CentroidAccelVelocity from './motion/centroid-accel-velocity';
import CentroidPosition from './motion/centroid-position';
import OrientationEuler from './motion/orientation-euler';
@@ -22,4 +23,5 @@ export const Encoders = {
TrackedPointAccelVelocity,
ZoneCollisionDetection,
ZoneObject,
ChannelBlock,
};
+13
View File
@@ -0,0 +1,13 @@
export default (offset: number, fade: number, value: number, isLittleEndian: boolean = false): Uint8Array => {
const bytes = new Uint8Array(5);
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
let dataOffset = 0;
view.setUint16(dataOffset, offset, isLittleEndian);
dataOffset += 2;
view.setUint16(dataOffset, fade, isLittleEndian);
dataOffset += 2;
view.setUint8(dataOffset, value);
return bytes;
};
+9 -1
View File
@@ -2,7 +2,15 @@ const { deepEqual, throws } = require('assert');
const { describe, it } = require('node:test');
const { Encoders } = require('../');
const goodTests = [];
const goodTests = [
{
description: 'Channel Block',
expected: new Uint8Array([0x00, 0x08, 0x00, 0x06, 0x40]),
bytes: () => {
return Encoders.ChannelBlock(8, 6, 64);
},
},
];
describe('RTTrPL Message Encoding', () => {
goodTests.forEach((messageTest) => {