/// <inheritdoc /> public async Task SetWaveformOptional(bool transient, ILifxColor color, TimeSpan period, float cycles, short skewRatio, LifxWaveform waveform, bool setHue, bool setSaturation, bool setBrightness, bool setKelvin, bool rapid = false, int?timeoutMs = null, CancellationToken cancellationToken = default) { if (color is null) { throw new ArgumentNullException(nameof(color)); } Messages.LightSetWaveformOptional setWaveformOptional = new Messages.LightSetWaveformOptional() { Transient = transient, Period = period, Cycles = cycles, SkewRatio = skewRatio, Waveform = waveform, SetHue = setHue, SetSaturation = setSaturation, SetBrightness = setBrightness, SetKelvin = setKelvin, }; setWaveformOptional.FromHsbk(color.ToHsbk()); if (rapid) { await this.Lifx.Send(this, setWaveformOptional); } else { await this.Lifx.SendWithAcknowledgement(this, setWaveformOptional, timeoutMs, cancellationToken); } }
/// <inheritdoc /> public override async Task SetMultizoneState(LifxApplicationRequest apply, ushort startAt, IEnumerable <ILifxColor> colors, TimeSpan duration = default, int?timeoutMs = null, CancellationToken cancellationToken = default) { ushort index = startAt; IEnumerator <ILifxColor> colorEnumerator = colors.GetEnumerator(); while (colorEnumerator.MoveNext()) { ILifxColor color = colorEnumerator.Current; // TODO: Optimize end index for duplicate colors Messages.SetColorZones setColorZones = new Messages.SetColorZones() { Duration = duration, Apply = apply, StartIndex = (byte)index, EndIndex = (byte)index, }; setColorZones.FromHsbk(color.ToHsbk()); await this.Lifx.SendWithAcknowledgement(this, setColorZones, timeoutMs, cancellationToken); index++; } }
/// <inheritdoc /> public async Task SetColor(ILifxColor color, TimeSpan duration = default, bool rapid = false, int?timeoutMs = null, CancellationToken cancellationToken = default) { if (color is null) { throw new ArgumentNullException(nameof(color)); } Messages.LightSetColor setColor = new Messages.LightSetColor() { Duration = duration, }; setColor.FromHsbk(color.ToHsbk()); if (rapid) { await this.Lifx.Send(this, setColor); } else { await this.Lifx.SendWithAcknowledgement(this, setColor, timeoutMs, cancellationToken); } }