private void setColor(string color, bool blink = false) { try { bool set = false; switch (color) { case "red": if (blink) { _device.Blink(LedTarget.All, new LuxaforSharp.Color(255, 0, 0), BLINKSPEED, REPEAT, TIMEOUT); break; } _device.SetColor(LedTarget.All, new LuxaforSharp.Color(255, 0, 0)); break; case "green": if (blink) { _device.Blink(LedTarget.All, new LuxaforSharp.Color(0, 255, 0), BLINKSPEED, REPEAT, TIMEOUT); break; } _device.SetColor(LedTarget.All, new LuxaforSharp.Color(0, 255, 0)); break; case "yellow": if (blink) { _device.Blink(LedTarget.All, new LuxaforSharp.Color(255, 215, 0), BLINKSPEED, REPEAT, TIMEOUT); break; } _device.SetColor(LedTarget.All, new LuxaforSharp.Color(255, 215, 0)); break; } } catch (Exception e) { throw new Exception("Can't set color on Luxafor device..."); } }
private async Task OnPomodoroStateChanged(PomodoroState newState) { switch (newState) { case PomodoroState.Pomodoro: await _luxaforDevice?.SetColor(LedTarget.All, new LuxaforSharp.Color(255, 0, 0)); break; case PomodoroState.ShortBreak: await _luxaforDevice?.SetColor(LedTarget.All, new LuxaforSharp.Color(0, 255, 0)); break; case PomodoroState.ShortBreakEnded: await _luxaforDevice?.SetColor(LedTarget.All, new LuxaforSharp.Color(0, 0, 0)); await _luxaforDevice?.Blink(LedTarget.All, new LuxaforSharp.Color(0, 0, 255), 5, 3); break; } }