コード例 #1
0
        /// <inheritdoc />
        protected override void WritePayload(BinaryWriter writer)
        {
            /* uint8_t count */ writer.Write((byte)this.ZoneCount);
            /* uint8_t index */ writer.Write((byte)this.ZoneCount);

            int count = this.Colors.Count;

            ILifxHsbkColor defaultColor = new LifxHsbkColor();

            for (int i = 0; i < StateMultiZone.MaxZoneCount; i++)
            {
                ILifxHsbkColor color;

                if (i < count)
                {
                    color = this.Colors[i];
                }
                else
                {
                    color = defaultColor;
                }

                /* uint16_t le hue */ writer.Write(color.Hue);
                /* uint16_t le saturation */ writer.Write(color.Saturation);
                /* uint16_t le brightness */ writer.Write(color.Brightness);
                /* uint16_t le kelvin */ writer.Write(color.Kelvin);
            }
        }
コード例 #2
0
        /// <inheritdoc />
        protected override void WritePayload(BinaryWriter writer)
        {
            /* uint32_t le duration */ writer.Write((uint)this.Duration.TotalMilliseconds);
            /* uint8_t apply */ writer.Write((byte)this.Apply);
            /* uint16_t le index */ writer.Write(this.Index);

            // HSBK color array
            int count = this.Colors.Count;

            /* uint8_t colors_count */ writer.Write((byte)count);

            ILifxHsbkColor defaultColor = new LifxHsbkColor();

            for (int i = 0; i < SetExtendedColorZones.MaxZoneCount; i++)
            {
                ILifxHsbkColor color;

                if (i < count)
                {
                    color = this.Colors[i];
                }
                else
                {
                    color = defaultColor;
                }

                /* uint16_t le hue */ writer.Write(color.Hue);
                /* uint16_t le saturation */ writer.Write(color.Saturation);
                /* uint16_t le brightness */ writer.Write(color.Brightness);
                /* uint16_t le kelvin */ writer.Write(color.Kelvin);
            }
        }
コード例 #3
0
        /// <inheritdoc />
        protected override void ReadPayload(BinaryReader reader)
        {
            // Duration
            uint duration = reader.ReadUInt32();

            this.Duration = TimeSpan.FromMilliseconds(duration);

            // Apply
            byte apply = reader.ReadByte();

            this.Apply = (LifxApplicationRequest)apply;

            // Index
            ushort index = reader.ReadUInt16();

            this.Index = index;

            // HSBK color array
            byte count = reader.ReadByte();

            // Empty list
            this.Colors.Clear();

            for (int i = 0; i < SetExtendedColorZones.MaxZoneCount; i++)
            {
                // Read HSBK
                ushort hue        = reader.ReadUInt16();
                ushort saturation = reader.ReadUInt16();
                ushort brightness = reader.ReadUInt16();
                ushort kelvin     = reader.ReadUInt16();

                // Store
                if (i < count)
                {
                    ILifxHsbkColor color = new LifxHsbkColor {
                        Hue        = hue,
                        Saturation = saturation,
                        Brightness = brightness,
                        Kelvin     = kelvin,
                    };

                    this.Colors.Add(color);
                }
            }
        }
コード例 #4
0
        /// <inheritdoc />
        protected override void ReadPayload(BinaryReader reader)
        {
            // ZoneCount
            ushort zoneCount = reader.ReadUInt16();

            this.ZoneCount = zoneCount;

            // Index
            ushort index = reader.ReadUInt16();

            this.Index = index;

            // HSBK color array
            byte count = reader.ReadByte();

            // Empty list
            this.Colors.Clear();

            for (int i = 0; i < StateExtendedColorZones.MaxZoneCount; i++)
            {
                // Read HSBK
                ushort hue        = reader.ReadUInt16();
                ushort saturation = reader.ReadUInt16();
                ushort brightness = reader.ReadUInt16();
                ushort kelvin     = reader.ReadUInt16();

                // Store
                if (i < count)
                {
                    ILifxHsbkColor color = new LifxHsbkColor {
                        Hue        = hue,
                        Saturation = saturation,
                        Brightness = brightness,
                        Kelvin     = kelvin,
                    };

                    this.Colors.Add(color);
                }
            }
        }
コード例 #5
0
        /// <inheritdoc />
        protected override void ReadPayload(BinaryReader reader)
        {
            byte zoneCount = reader.ReadByte();

            this.ZoneCount = zoneCount;

            byte index = reader.ReadByte();

            this.Index = index;

            this.Colors.Clear();

            for (int i = 0; i < StateMultiZone.MaxZoneCount; i++)
            {
                ILifxHsbkColor color = new LifxHsbkColor();

                // Read HSBK
                ushort hue = reader.ReadUInt16();

                color.Hue = hue;

                ushort saturation = reader.ReadUInt16();

                color.Saturation = saturation;

                ushort brightness = reader.ReadUInt16();

                color.Brightness = brightness;

                ushort kelvin = reader.ReadUInt16();

                color.Kelvin = kelvin;

                // Store
                this.Colors.Add(color);
            }
        }