1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 01:58:30 +00:00

Added an option for devices to force flushing on every update

This commit is contained in:
Darth Affe 2018-03-08 19:42:33 +01:00
parent 54f7ec97d1
commit 7d105a0734
2 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,6 @@
// ReSharper disable MemberCanBePrivate.Global
// ReSharper disable UnusedMember.Global
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
using System;
using System.Collections;
@ -42,6 +43,11 @@ namespace RGB.NET.Core
set => SetProperty(ref _location, value);
}
/// <summary>
/// Gets or sets if the device needs to be flushed on every update.
/// </summary>
protected bool RequiresFlush { get; set; } = false;
/// <inheritdoc />
public DeviceUpdateMode UpdateMode { get; set; } = DeviceUpdateMode.Sync;
@ -74,13 +80,13 @@ namespace RGB.NET.Core
#region Methods
/// <inheritdoc />
public virtual void Update(bool render = true, bool flushLeds = false)
public virtual void Update(bool flushLeds = false)
{
// Device-specific updates
DeviceUpdate();
// Send LEDs to SDK
IEnumerable<Led> ledsToUpdate = (flushLeds ? LedMapping.Values : LedMapping.Values.Where(x => x.IsDirty)).ToList();
IEnumerable<Led> ledsToUpdate = ((RequiresFlush || flushLeds) ? LedMapping.Values : LedMapping.Values.Where(x => x.IsDirty)).ToList();
foreach (Led ledToUpdate in ledsToUpdate)
ledToUpdate.Update();

View File

@ -65,11 +65,9 @@ namespace RGB.NET.Core
/// <summary>
/// Perform an update for all dirty <see cref="Led"/>, or all <see cref="Led"/> if flushLeds is set to true.
/// Only physically syncs the colors to the device if <paramref name="sync"/> is set to true.
/// </summary>
/// <param name="sync">Specifies whether the colors should be synced to the device or not.</param>
/// <param name="flushLeds">Specifies whether all <see cref="Led"/> (including clean ones) should be updated.</param>
void Update(bool sync = true, bool flushLeds = false);
void Update(bool flushLeds = false);
/// <summary>
/// Synchronizes the internal state of the device to the real (physical) state.