Beispiel #1
0
        /// <inheritdoc />
        public IEnumerable <IRGBDevice> CreateDevices(IDeviceUpdateTrigger updateTrigger)
        {
            NodeMCUWS2812USBUpdateQueue queue = UpdateMode switch
            {
                NodeMCUUpdateMode.Http => new NodeMCUWS2812USBUpdateQueue(updateTrigger, Hostname),
                NodeMCUUpdateMode.Udp => new NodeMCUWS2812USBUpdateQueue(updateTrigger, Hostname, Port),
                _ => throw new ArgumentOutOfRangeException()
            };

            IEnumerable <(int channel, int ledCount)> channels = queue.GetChannels();
            int counter = 0;

            foreach ((int channel, int ledCount) in channels)
            {
                string name = string.Format(Name ?? $"NodeMCU WS2812 WIFI ({Hostname}) [{{0}}]", ++counter);
                NodeMCUWS2812USBDevice device = new NodeMCUWS2812USBDevice(new NodeMCUWS2812USBDeviceInfo(name), queue, channel);
                device.Initialize(ledCount);
                yield return(device);
            }
        }

        #endregion
    }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NodeMCUWS2812USBDevice"/> class.
 /// </summary>
 /// <param name="deviceInfo">The update trigger used by this queue.</param>
 /// <param name="updateQueue">The update queue performing updates for this device.</param>
 /// <param name="channel">The channel (as defined in the NodeMCU-sketch) this device is attached to.</param>
 public NodeMCUWS2812USBDevice(NodeMCUWS2812USBDeviceInfo deviceInfo, NodeMCUWS2812USBUpdateQueue updateQueue, int channel)
 {
     this.DeviceInfo  = deviceInfo;
     this.UpdateQueue = updateQueue;
     this.Channel     = channel;
 }