/// <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 /> protected override void ReadPayload(BinaryReader reader) { byte startIndex = reader.ReadByte(); this.StartIndex = startIndex; byte endIndex = reader.ReadByte(); this.EndIndex = endIndex; // HSBK ushort hue = reader.ReadUInt16(); this.Hue = hue; ushort saturation = reader.ReadUInt16(); this.Saturation = saturation; ushort brightness = reader.ReadUInt16(); this.Brightness = brightness; ushort kelvin = reader.ReadUInt16(); this.Kelvin = kelvin; uint duration = reader.ReadUInt32(); this.Duration = TimeSpan.FromMilliseconds(duration); byte apply = reader.ReadByte(); this.Apply = (LifxApplicationRequest)apply; }
/// <inheritdoc /> public override async Task SetMultizoneState(LifxApplicationRequest apply, ushort startAt, IEnumerable <ILifxColor> colors, TimeSpan duration = default, int?timeoutMs = null, CancellationToken cancellationToken = default) { Messages.SetExtendedColorZones setExtendedColorZones = new Messages.SetExtendedColorZones() { Duration = duration, Apply = apply, Index = startAt, }; IEnumerable <ILifxColor> hsbkColors = colors.Take(Messages.SetExtendedColorZones.MaxZoneCount); foreach (ILifxColor color in hsbkColors) { setExtendedColorZones.Colors.Add(color.ToHsbk()); } await this.Lifx.SendWithAcknowledgement(this, setExtendedColorZones, timeoutMs, cancellationToken); }
// Trivial methods /// <inheritdoc /> public Task SetMultizoneState(LifxApplicationRequest apply, ushort startAt, IEnumerable <ILifxColor> colors, uint durationMs = 0, int?timeoutMs = null, CancellationToken cancellationToken = default) { return(this.SetMultizoneState(apply, startAt, colors, TimeSpan.FromMilliseconds(durationMs), timeoutMs, cancellationToken)); }
/// <inheritdoc /> public abstract Task SetMultizoneState(LifxApplicationRequest apply, ushort startAt, IEnumerable <ILifxColor> colors, TimeSpan duration = default, int?timeoutMs = null, CancellationToken cancellationToken = default);