static internal extern bool SetAllLedColor([In] COLOR_MATRIX colorMatrix);
public override void UpdateState(int chainIndex, ICommand[] outputStates) { if (!_connected) { // Try to open the connection if (!OpenConnection()) { return; } } var matrix = COLOR_MATRIX.Create(); var changed = false; for (var i = 0; i < outputStates.Length; i++) { byte newValue = 0; if (outputStates[i] != null) { var command = outputStates[i] as _8BitCommand; if (command == null) { continue; } newValue = command.CommandValue; _nullCommands[i] = 0; } else { // it was a null command. We should turn it off; however, to avoid some potentially nasty flickering, // we will keep track of the null commands for this output, and ignore the first one. Any after that will // actually be sent through. if (_nullCommands[i] == 0) { _nullCommands[i] = 1; newValue = _lastValues[i]; } } if (_lastValues[i] == newValue) { continue; } changed = true; matrix.SetKeyValue(i, _channelCount, newValue); _lastValues[i] = newValue; } // don't bother writing anything if we haven't acutally *changed* any values... // also, send at least a 'null' update command every 10 seconds. if (!changed && _timeoutStopwatch.ElapsedMilliseconds < 10000) { return; } try { _timeoutStopwatch.Restart(); // Write Data if (!CoolerMasterSDK.SetAllLedColor(matrix)) { throw new Exception("SetAllLedColor() Failed"); } CoolerMasterSDK.RefreshLed(); } catch (Exception ex) { //Logging.Warn(LogTag + "failed to write data to device during update", ex); CloseConnection(); } }