1
0
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:
DarthAffe 2020-12-25 19:32:50 +01:00 committed by GitHub
commit e418710f3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 3 deletions

View File

@ -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));

View File

@ -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;
}