mirror of
https://github.com/DarthAffe/RGB.NET.git
synced 2026-01-02 10:43:37 +00:00
Compare commits
No commits in common. "4675349621171ee77616adee2c5823d965441186" and "6e313ea6a150fbb67fa7c05e571504661f233277" have entirely different histories.
4675349621
...
6e313ea6a1
@ -111,7 +111,7 @@ public abstract class AbstractRGBDevice<TDeviceInfo> : Placeable, IRGBDevice<TDe
|
||||
/// </summary>
|
||||
/// <param name="flushLeds">Forces all LEDs to be treated as dirty.</param>
|
||||
/// <returns>The collection LEDs to update.</returns>
|
||||
protected virtual IEnumerable<Led> GetLedsToUpdate(bool flushLeds) => ((RequiresFlush || flushLeds || UpdateQueue.RequiresFlush) ? LedMapping.Values : LedMapping.Values.Where(x => x.IsDirty)).Where(led => led.RequestedColor?.A > 0);
|
||||
protected virtual IEnumerable<Led> GetLedsToUpdate(bool flushLeds) => ((RequiresFlush || flushLeds) ? LedMapping.Values : LedMapping.Values.Where(x => x.IsDirty)).Where(led => led.RequestedColor?.A > 0);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an enumerable of a custom data and color tuple for the specified leds.
|
||||
|
||||
@ -178,7 +178,7 @@ public abstract class AbstractRGBDeviceProvider : IRGBDeviceProvider
|
||||
/// </summary>
|
||||
/// <param name="ex">The exception to throw.</param>
|
||||
/// <param name="isCritical">Indicates if the exception is critical for device provider to work correctly.</param>
|
||||
public virtual void Throw(Exception ex, bool isCritical = false)
|
||||
protected virtual void Throw(Exception ex, bool isCritical = false)
|
||||
{
|
||||
ExceptionEventArgs args = new(ex, isCritical, ThrowsExceptions);
|
||||
try { OnException(args); } catch { /* we don't want to throw due to bad event handlers */ }
|
||||
|
||||
@ -20,10 +20,6 @@ public interface IRGBDeviceProvider : IDisposable
|
||||
/// <summary>
|
||||
/// Indicates if exceptions in the device provider are thrown or silently ignored.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This should only be set to <c>true</c> for debugging/development purposes.
|
||||
/// Production code should use the <see cref="Exception"/>-Event to handle exceptions.
|
||||
/// </remarks>
|
||||
bool ThrowsExceptions { get; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -11,11 +11,6 @@ namespace RGB.NET.Core;
|
||||
public interface IUpdateQueue<TIdentifier, TData> : IDisposable
|
||||
where TIdentifier : notnull
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a bool indicating if the queue requires a flush of all data due to an internal error.
|
||||
/// </summary>
|
||||
bool RequiresFlush { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets or merges the provided data set in the current dataset and notifies the trigger that there is new data available.
|
||||
/// </summary>
|
||||
|
||||
@ -19,9 +19,6 @@ public abstract class UpdateQueue<TIdentifier, TData> : IUpdateQueue<TIdentifier
|
||||
private readonly IDeviceUpdateTrigger _updateTrigger;
|
||||
private readonly Dictionary<TIdentifier, TData> _currentDataSet = new();
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool RequiresFlush { get; private set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@ -65,7 +62,7 @@ public abstract class UpdateQueue<TIdentifier, TData> : IUpdateQueue<TIdentifier
|
||||
_currentDataSet.Clear();
|
||||
}
|
||||
|
||||
RequiresFlush = !Update(data);
|
||||
Update(data);
|
||||
|
||||
ArrayPool<(TIdentifier, TData)>.Shared.Return(dataSet);
|
||||
}
|
||||
@ -81,7 +78,7 @@ public abstract class UpdateQueue<TIdentifier, TData> : IUpdateQueue<TIdentifier
|
||||
/// Performs the update this queue is responsible for.
|
||||
/// </summary>
|
||||
/// <param name="dataSet">The set of data that needs to be updated.</param>
|
||||
protected abstract bool Update(in ReadOnlySpan<(TIdentifier key, TData color)> dataSet);
|
||||
protected abstract void Update(in ReadOnlySpan<(TIdentifier key, TData color)> dataSet);
|
||||
|
||||
/// <summary>
|
||||
/// Sets or merges the provided data set in the current dataset and notifies the trigger that there is new data available.
|
||||
|
||||
@ -43,14 +43,14 @@ public class AsusUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ((Device.Type == (uint)AsusDeviceType.KEYBOARD_RGB) || (Device.Type == (uint)AsusDeviceType.NB_KB_RGB))
|
||||
{
|
||||
if (Device is not IAuraSyncKeyboard keyboard)
|
||||
return true;
|
||||
return;
|
||||
|
||||
foreach ((object customData, Color value) in dataSet)
|
||||
{
|
||||
@ -88,15 +88,10 @@ public class AsusUpdateQueue : UpdateQueue
|
||||
}
|
||||
|
||||
Device.Apply();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AsusDeviceProvider.Instance.Throw(ex);
|
||||
catch
|
||||
{ /* "The server threw an exception." seems to be a thing here ... */
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -37,9 +37,7 @@ public class CoolerMasterUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
{
|
||||
@ -48,15 +46,6 @@ public class CoolerMasterUpdateQueue : UpdateQueue
|
||||
}
|
||||
|
||||
_CoolerMasterSDK.SetAllLedColor(_deviceMatrix, _deviceIndex);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CoolerMasterDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -50,26 +50,6 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
/// </summary>
|
||||
public CorsairSessionDetails SessionDetails { get; private set; } = new();
|
||||
|
||||
private CorsairSessionState _sessionState = CorsairSessionState.Invalid;
|
||||
public CorsairSessionState SessionState
|
||||
{
|
||||
get => _sessionState;
|
||||
private set
|
||||
{
|
||||
_sessionState = value;
|
||||
|
||||
try { SessionStateChanged?.Invoke(this, SessionState); }
|
||||
catch { /* catch faulty event-handlers*/ }
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
|
||||
// ReSharper disable once UnassignedField.Global
|
||||
public EventHandler<CorsairSessionState>? SessionStateChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
@ -94,7 +74,7 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
|
||||
using ManualResetEventSlim waitEvent = new(false);
|
||||
|
||||
void OnInitializeSessionStateChanged(object? sender, CorsairSessionState state)
|
||||
void OnSessionStateChanged(object? sender, CorsairSessionState state)
|
||||
{
|
||||
if (state == CorsairSessionState.Connected)
|
||||
// ReSharper disable once AccessToDisposedClosure
|
||||
@ -104,7 +84,6 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
try
|
||||
{
|
||||
_CUESDK.SessionStateChanged += OnSessionStateChanged;
|
||||
_CUESDK.SessionStateChanged += OnInitializeSessionStateChanged;
|
||||
|
||||
CorsairError errorCode = _CUESDK.CorsairConnect();
|
||||
if (errorCode != CorsairError.Success)
|
||||
@ -121,12 +100,10 @@ public class CorsairDeviceProvider : AbstractRGBDeviceProvider
|
||||
}
|
||||
finally
|
||||
{
|
||||
_CUESDK.SessionStateChanged -= OnInitializeSessionStateChanged;
|
||||
_CUESDK.SessionStateChanged -= OnSessionStateChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSessionStateChanged(object? sender, CorsairSessionState state) => SessionState = state;
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override IEnumerable<IRGBDevice> LoadDevices()
|
||||
{
|
||||
|
||||
@ -38,12 +38,8 @@ public class CorsairDeviceUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override unsafe bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override unsafe void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_CUESDK.IsConnected) return false;
|
||||
|
||||
Span<_CorsairLedColor> colors = new((void*)_colorPtr, dataSet.Length);
|
||||
for (int i = 0; i < colors.Length; i++)
|
||||
{
|
||||
@ -55,15 +51,6 @@ public class CorsairDeviceUpdateQueue : UpdateQueue
|
||||
CorsairError error = _CUESDK.CorsairSetLedColors(_device.id!, dataSet.Length, _colorPtr);
|
||||
if (error != CorsairError.Success)
|
||||
throw new RGBDeviceException($"Failed to update device '{_device.id}'. (ErrorCode: {error})");
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CorsairDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@ -59,9 +59,7 @@ public class E131UpdateQueue : UpdateQueue
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
DataPacket.SetSequenceNumber(GetNextSequenceNumber());
|
||||
|
||||
@ -73,15 +71,6 @@ public class E131UpdateQueue : UpdateQueue
|
||||
}
|
||||
|
||||
_socket.Send(DataPacket, DataPacket.Length);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
DMXDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -15,7 +15,7 @@ internal class DebugDeviceUpdateQueue : UpdateQueue
|
||||
|
||||
#region Methods
|
||||
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet) => true;
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet) { }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -25,9 +25,7 @@ public class LogitechPerDeviceUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
Color color = dataSet[0].color;
|
||||
|
||||
@ -35,15 +33,6 @@ public class LogitechPerDeviceUpdateQueue : UpdateQueue
|
||||
_LogitechGSDK.LogiLedSetLighting((int)Math.Round(color.R * 100),
|
||||
(int)Math.Round(color.G * 100),
|
||||
(int)Math.Round(color.B * 100));
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogitechDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -25,9 +25,7 @@ public class LogitechPerKeyUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.PerKeyRGB);
|
||||
|
||||
@ -40,15 +38,6 @@ public class LogitechPerKeyUpdateQueue : UpdateQueue
|
||||
(int)MathF.Round(color.G * 100),
|
||||
(int)MathF.Round(color.B * 100));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogitechDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -33,9 +33,7 @@ public class LogitechZoneUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
_LogitechGSDK.LogiLedSetTargetDevice(LogitechDeviceCaps.All);
|
||||
|
||||
@ -47,15 +45,6 @@ public class LogitechZoneUpdateQueue : UpdateQueue
|
||||
(int)MathF.Round(color.G * 100),
|
||||
(int)MathF.Round(color.B * 100));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogitechDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -34,21 +34,10 @@ public class MsiDeviceUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
_MsiSDK.SetLedColor(_deviceType, (int)key, color.GetR(), color.GetG(), color.GetB());
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MsiDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -35,21 +35,10 @@ public abstract class MidiUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
SendMessage(CreateMessage(key, color));
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
NovationDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -49,23 +49,12 @@ public class OpenRGBUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
_colors[(int)key] = new OpenRGBColor(color.GetR(), color.GetG(), color.GetB());
|
||||
|
||||
_openRGB.UpdateLeds(_deviceid, _colors);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OpenRGBDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -44,9 +44,7 @@ public class PicoPiBulkUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
Span<byte> buffer = _dataBuffer;
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
@ -62,15 +60,6 @@ public class PicoPiBulkUpdateQueue : UpdateQueue
|
||||
}
|
||||
|
||||
_sdk.SendBulkUpdate(buffer, _channel);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PicoPiDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -41,9 +41,7 @@ public class PicoPiHIDUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
Span<byte> buffer = _dataBuffer;
|
||||
foreach ((object key, Color color) in dataSet)
|
||||
@ -59,15 +57,6 @@ public class PicoPiHIDUpdateQueue : UpdateQueue
|
||||
}
|
||||
|
||||
_sdk.SendHidUpdate(buffer, _channel);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
PicoPiDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@ -23,16 +23,15 @@ public abstract class RazerUpdateQueue : UpdateQueue
|
||||
/// <param name="updateTrigger">The update trigger used to update this queue.</param>
|
||||
protected RazerUpdateQueue(IDeviceUpdateTrigger updateTrigger)
|
||||
: base(updateTrigger)
|
||||
{ }
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
IntPtr effectParams = CreateEffectParams(dataSet);
|
||||
Guid effectId = Guid.NewGuid();
|
||||
@ -44,15 +43,6 @@ public abstract class RazerUpdateQueue : UpdateQueue
|
||||
_RazerSDK.DeleteEffect(_lastEffect.Value);
|
||||
|
||||
_lastEffect = effectId;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
RazerDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -36,36 +36,16 @@ internal class SteelSeriesDeviceUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
protected override void OnUpdate(object? sender, CustomUpdateData customData)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (customData[CustomUpdateDataIndex.HEARTBEAT] as bool? ?? false)
|
||||
SteelSeriesSDK.SendHeartbeat();
|
||||
else
|
||||
base.OnUpdate(sender, customData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SteelSeriesDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
SteelSeriesSDK.UpdateLeds(_deviceType, dataSet.ToArray().Select(x => (((SteelSeriesLedId)x.key).GetAPIName(), x.color.ToIntArray())).Where(x => x.Item1 != null).ToList()!);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SteelSeriesDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
=> SteelSeriesSDK.UpdateLeds(_deviceType, dataSet.ToArray().Select(x => (((SteelSeriesLedId)x.key).GetAPIName(), x.color.ToIntArray())).Where(x => x.Item1 != null).ToList()!);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -56,24 +56,13 @@ public abstract class SerialConnectionUpdateQueue<TData> : UpdateQueue
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
foreach (TData command in GetCommands(dataSet.ToArray()))
|
||||
{
|
||||
SerialConnection.ReadTo(Prompt);
|
||||
SendCommand(command);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WS281XDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -77,25 +77,13 @@ public class NodeMCUWS2812USBUpdateQueue : UpdateQueue
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (IGrouping<int, ((int channel, int key), Color color)> channelData in dataSet.ToArray()
|
||||
.Select(x => (((int channel, int key))x.key, x.color)).GroupBy(x => x.Item1.channel))
|
||||
foreach (IGrouping<int, ((int channel, int key), Color color)> channelData in dataSet.ToArray().Select(x => (((int channel, int key))x.key, x.color)).GroupBy(x => x.Item1.channel))
|
||||
{
|
||||
byte[] buffer = GetBuffer(channelData);
|
||||
_sendDataAction(buffer);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WS281XDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void SendHttp(byte[] buffer)
|
||||
|
||||
@ -31,9 +31,7 @@ public class WootingUpdateQueue : UpdateQueue
|
||||
#region Methods
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
try
|
||||
protected override void Update(in ReadOnlySpan<(object key, Color color)> dataSet)
|
||||
{
|
||||
lock (_WootingSDK.SdkLock)
|
||||
{
|
||||
@ -47,15 +45,6 @@ public class WootingUpdateQueue : UpdateQueue
|
||||
|
||||
_WootingSDK.ArrayUpdateKeyboard();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WootingDeviceProvider.Instance.Throw(ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user