mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2025-12-12 17:48:31 +00:00
Merge pull request #161 from DarthAffe/SDK/BitwizardFix
Added pin-selectionn for Bitwizard devices
This commit is contained in:
commit
e418710f3e
@ -16,6 +16,8 @@ namespace RGB.NET.Devices.WS281X.Bitwizard
|
||||
{
|
||||
#region Properties & Fields
|
||||
|
||||
private readonly int _ledOffset;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the update queue performing updates for this device.
|
||||
/// </summary>
|
||||
@ -33,10 +35,12 @@ namespace RGB.NET.Devices.WS281X.Bitwizard
|
||||
/// </summary>
|
||||
/// <param name="deviceInfo">The update trigger used by this queue.</param>
|
||||
/// <param name="updateQueue">The update queue performing updates for this device.</param>
|
||||
public BitwizardWS2812USBDevice(BitwizardWS2812USBDeviceInfo deviceInfo, BitwizardWS2812USBUpdateQueue updateQueue)
|
||||
public BitwizardWS2812USBDevice(BitwizardWS2812USBDeviceInfo deviceInfo, BitwizardWS2812USBUpdateQueue updateQueue, int ledOffset)
|
||||
{
|
||||
this.DeviceInfo = deviceInfo;
|
||||
this.UpdateQueue = updateQueue;
|
||||
|
||||
this._ledOffset = ledOffset;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -58,7 +62,7 @@ namespace RGB.NET.Devices.WS281X.Bitwizard
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override object CreateLedCustomData(LedId ledId) => (int)ledId - (int)LedId.LedStripe1;
|
||||
protected override object CreateLedCustomData(LedId ledId) => _ledOffset + ((int)ledId - (int)LedId.LedStripe1);
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void UpdateLeds(IEnumerable<Led> ledsToUpdate) => UpdateQueue.SetData(ledsToUpdate.Where(x => x.Color.A > 0));
|
||||
|
||||
@ -36,11 +36,22 @@ namespace RGB.NET.Devices.WS281X.Bitwizard
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the pin sed to control the leds.
|
||||
/// </summary>
|
||||
public int Pin { get; set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of leds of this device.
|
||||
/// </summary>
|
||||
public int StripLength { get; set; } = 384;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the amount of leds controlled by one pin.
|
||||
/// This only needs to be changed if the firmware on the controller is updated.
|
||||
/// </summary>
|
||||
public int MaxStripLength { get; set; } = 384;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@ -73,7 +84,8 @@ namespace RGB.NET.Devices.WS281X.Bitwizard
|
||||
{
|
||||
BitwizardWS2812USBUpdateQueue queue = new BitwizardWS2812USBUpdateQueue(updateTrigger, SerialConnection);
|
||||
string name = Name ?? $"Bitwizard WS2812 USB ({Port})";
|
||||
BitwizardWS2812USBDevice device = new BitwizardWS2812USBDevice(new BitwizardWS2812USBDeviceInfo(name), queue);
|
||||
int ledOffset = Pin * MaxStripLength;
|
||||
BitwizardWS2812USBDevice device = new BitwizardWS2812USBDevice(new BitwizardWS2812USBDeviceInfo(name), queue, ledOffset);
|
||||
device.Initialize(StripLength);
|
||||
yield return device;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user