import { Color } from "../color" ; import { Device } from "./device" ; import { IDeviceInterface } from "../interfaces" ; import * as Consts from "../consts" ; class extends Device export class Technic3x3ColorLightMatrix extends Device { constructor ( hub , portId ) { super ( hub , portId , { } , Consts . DeviceType . TECHNIC_3X3_COLOR_LIGHT_MATRIX ) ; } method param { Color [ ] | Color } colors returns { Promise } public setMatrix ( colors ) { return new Promise < void > ( ( resolve ) => { this . subscribe ( Mode . PIX_0 ) ; const colorArray = new Array ( 9 ) ; for ( let i = 0 ; i < colorArray . length ; i ++ ) { if ( typeof colors === 'number' ) { colorArray [ i ] = colors + ( 10 << 4 ) ; } if ( colors [ i ] instanceof Color ) { colorArray [ i ] = colors [ i ] . toValue ( ) ; } if ( colors [ i ] === Consts . Color . NONE ) { colorArray [ i ] = Consts . Color . NONE ; } if ( colors [ i ] <= 10 ) { colorArray [ i ] = colors [ i ] + ( 10 << 4 ) ; } } this . writeDirect ( Mode . PIX_0 , Buffer . from ( colorArray ) ) ; return resolve ( ) ; } ) ; } } export enum Mode { LEV_0 = 0x00 , COL_0 = 0x01 , PIX_0 = 0x02 , TRANS = 0x03 }