private void HandleLedColorCommand(byte[] command) { var redChannel = command[CommandHelper.CommandDataBeginIndex]; var greenChannel = command[CommandHelper.CommandDataBeginIndex + 1]; var blueChannel = command[CommandHelper.CommandDataBeginIndex + 2]; var color = Color.FromArgb(0, redChannel, greenChannel, blueChannel); if (ledArray != null) { ledArray.Reset(color); } DiagnosticInfo.Display(null, color.ToString() + " " + redChannel + " " + greenChannel + " " + blueChannel); }
private async Task InitializeLedArray() { const byte address = 0x46; var device = await I2cHelper.GetI2cDevice(address); if (device != null) { ledArray = new LedArray(device); ledArray.Reset(Colors.Black); } else { DiagnosticInfo.Display(null, "Led array unavailable"); } }
public IAsyncOperation <SenseHatLedArrayTurnOffResult> TurnOffAsync(AllJoynMessageInfo info) { Task <SenseHatLedArrayTurnOffResult> task = new Task <SenseHatLedArrayTurnOffResult>(() => { if (ledArray != null) { ledArray.Reset(Colors.Black); return(SenseHatLedArrayTurnOffResult.CreateSuccessResult()); } else { return(SenseHatLedArrayTurnOffResult.CreateFailureResult((int)ErrorCodes.LedInitializationError)); } }); task.Start(); return(task.AsAsyncOperation()); }