// ReSharper disable MemberCanBePrivate.Global // ReSharper disable UnusedMember.Global using System.Collections.Generic; using System.Linq; using RGB.NET.Core; namespace RGB.NET.Devices.WS281X.NodeMCU; // ReSharper disable once InconsistentNaming /// /// /// Represents an NodeMCU WS2812 device. /// public class NodeMCUWS2812USBDevice : AbstractRGBDevice, ILedStripe { #region Properties & Fields /// /// Gets the channel (as defined in the NodeMCU-sketch) this device is attached to. /// public int Channel { get; } #endregion #region Constructors /// /// Initializes a new instance of the class. /// /// The device info of this device. /// The update queue performing updates for this device. /// The channel (as defined in the NodeMCU-sketch) this device is attached to. /// The amount of leds on this device. public NodeMCUWS2812USBDevice(NodeMCUWS2812USBDeviceInfo deviceInfo, NodeMCUWS2812USBUpdateQueue updateQueue, int channel, int ledCount) : base(deviceInfo, updateQueue) { this.Channel = channel; InitializeLayout(ledCount); } #endregion #region Methods private void InitializeLayout(int ledCount) { for (int i = 0; i < ledCount; i++) AddLed(LedId.LedStripe1 + i, new Point(i * 10, 0), new Size(10, 10)); } /// protected override object GetLedCustomData(LedId ledId) => (Channel, (int)ledId - (int)LedId.LedStripe1); /// protected override IEnumerable GetLedsToUpdate(bool flushLeds) => (flushLeds || LedMapping.Values.Any(x => x.IsDirty)) ? LedMapping.Values : Enumerable.Empty(); #endregion }