public static void SetBacklight(byte unitId, int keyNr, BacklightColorEnum color, bool blinking) { lock (((IList)Devices).SyncRoot) { Devices.ForEach(d => { if (d.UnitId == unitId) { d.SetBackLight(keyNr, color, blinking); } }); } }
public void SetBackLight(int keyNr, BacklightColorEnum color, bool blinking) { var wData = new byte[PieDevice.WriteLength]; wData[1] = 181; //b5 var result = 404; switch (color) { case BacklightColorEnum.None: wData[2] = (byte)keyNr; wData[3] = 0; while (result != 0) { result = PieDevice.WriteData(wData); } result = 404; wData[2] = (byte)(keyNr + 32); wData[3] = 0; while (result != 0) { result = PieDevice.WriteData(wData); } break; case BacklightColorEnum.Red: wData[2] = (byte)keyNr; wData[3] = 0; while (result != 0) { result = PieDevice.WriteData(wData); } result = 404; wData[2] = (byte)(keyNr + 32); wData[3] = blinking ? (byte)2 : (byte)1; while (result != 0) { result = PieDevice.WriteData(wData); } break; case BacklightColorEnum.Blue: wData[2] = (byte)keyNr; wData[3] = blinking ? (byte)2 : (byte)1; while (result != 0) { result = PieDevice.WriteData(wData); } result = 404; wData[2] = (byte)(keyNr + 32); wData[3] = 0; while (result != 0) { result = PieDevice.WriteData(wData); } break; case BacklightColorEnum.Both: wData[2] = (byte)keyNr; wData[3] = blinking ? (byte)2 : (byte)1; while (result != 0) { result = PieDevice.WriteData(wData); } result = 404; wData[2] = (byte)(keyNr + 32); wData[3] = blinking ? (byte)2 : (byte)1; while (result != 0) { result = PieDevice.WriteData(wData); } break; } }