mirror of
https://github.com/jwetzell/rttrp-js.git
synced 2026-09-11 08:59:33 +00:00
add encoder for channel-block
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import ChannelBlock from './lighting/channel-block';
|
||||||
import CentroidAccelVelocity from './motion/centroid-accel-velocity';
|
import CentroidAccelVelocity from './motion/centroid-accel-velocity';
|
||||||
import CentroidPosition from './motion/centroid-position';
|
import CentroidPosition from './motion/centroid-position';
|
||||||
import OrientationEuler from './motion/orientation-euler';
|
import OrientationEuler from './motion/orientation-euler';
|
||||||
@@ -22,4 +23,5 @@ export const Encoders = {
|
|||||||
TrackedPointAccelVelocity,
|
TrackedPointAccelVelocity,
|
||||||
ZoneCollisionDetection,
|
ZoneCollisionDetection,
|
||||||
ZoneObject,
|
ZoneObject,
|
||||||
|
ChannelBlock,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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;
|
||||||
|
};
|
||||||
@@ -2,7 +2,15 @@ const { deepEqual, throws } = require('assert');
|
|||||||
const { describe, it } = require('node:test');
|
const { describe, it } = require('node:test');
|
||||||
const { Encoders } = require('../');
|
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', () => {
|
describe('RTTrPL Message Encoding', () => {
|
||||||
goodTests.forEach((messageTest) => {
|
goodTests.forEach((messageTest) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user