/// <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++;
            }
        }
예제 #2
0
        /// <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);
            }
        }
예제 #3
0
        /// <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);
            }
        }
예제 #4
0
 /// <inheritdoc />
 public Task SetColor(ILifxColor color, uint durationMs = 0, bool rapid = false, int?timeoutMs = null, CancellationToken cancellationToken = default)
 {
     return(this.SetColor(color, TimeSpan.FromMilliseconds(durationMs), rapid, timeoutMs, cancellationToken));
 }
예제 #5
0
 /// <inheritdoc />
 public Task SetWaveformOptional(bool transient, ILifxColor color, uint periodMs, float cycles, short skewRatio, LifxWaveform waveform, bool setHue, bool setSaturation, bool setBrightness, bool setKelvin, bool rapid = false, int?timeoutMs = null, CancellationToken cancellationToken = default)
 {
     return(this.SetWaveformOptional(transient, color, TimeSpan.FromMilliseconds(periodMs), cycles, skewRatio, waveform, setHue, setSaturation, setBrightness, setKelvin, rapid, timeoutMs, cancellationToken));
 }
예제 #6
0
        // Trivial methods

        /// <inheritdoc />
        public Task SetWaveform(bool transient, ILifxColor color, TimeSpan period, float cycles, short skewRatio, LifxWaveform waveform, bool rapid = false, int?timeoutMs = null, CancellationToken cancellationToken = default)
        {
            return(this.SetWaveformOptional(transient, color, period, cycles, skewRatio, waveform, true, true, true, true, rapid, timeoutMs, cancellationToken));
        }
예제 #7
0
 /// <inheritdoc />
 public abstract 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);
예제 #8
0
 /// <inheritdoc />
 public abstract Task SetColor(ILifxColor color, TimeSpan duration = default, bool rapid = false, int?timeoutMs = null, CancellationToken cancellationToken = default);