private static string GenerateFromSetFeatureReport(SetFeatureReport report) { var bytes = report.GetReportData(); var sb = new StringBuilder(); sb.Append("sf "); AppendBytesAsString(bytes, sb); return sb.ToString(); }
public static string Generate(IEnumerable<IInstruction> instructions) { /* sf 00 01 00 01 00 00 00 00 00 WR 00 FF FF FF 01 00 10 00 00 sf 00 01 00 02 00 00 00 00 00 */ var startCommand = new SetFeatureReport { Command = SetFeatureCommands.ChangeFeatureMode }; startCommand.CommandData[0] = (byte)FeatureModeOptions.StoreProgramStart; var stopCommand = new SetFeatureReport { Command = SetFeatureCommands.ChangeFeatureMode }; stopCommand.CommandData[0] = (byte)FeatureModeOptions.StoreProgramStop; var sb = new StringBuilder(); sb.AppendLine(GenerateFromSetFeatureReport(startCommand)); foreach (var instruction in instructions) { sb.AppendLine(GenerateFromInstruction(instruction)); } sb.AppendLine(GenerateFromSetFeatureReport(stopCommand)); return sb.ToString(); }
private bool SendProgramStopCommand() { var stopCommand = new SetFeatureReport {Command = SetFeatureCommands.ChangeFeatureMode}; stopCommand.CommandData[0] = (byte) FeatureModeOptions.StoreProgramStop; var result = _device.WriteFeatureData(stopCommand.GetReportData()); _isProgramming = false; if (OnProgramWriteComplete != null) { OnProgramWriteComplete(result); } return result; }
public void WriteAnimationProgram(IList<IInstruction> instructions) { _isProgramming = true; var stack = new Stack<IInstruction>(instructions.Reverse()); // Put device in program mode var startCommand = new SetFeatureReport {Command = SetFeatureCommands.ChangeFeatureMode}; startCommand.CommandData[0] = (byte)FeatureModeOptions.StoreProgramStart; _device.WriteFeatureData(startCommand.GetReportData()); WriteProgramData(stack); }
public void StopPlaybackOfStoredProgram() { if (_connectedToDriver && !_isProgramming) { var stopCommand = new SetFeatureReport { Command = SetFeatureCommands.ChangeFeatureMode }; stopCommand.CommandData[0] = (byte)FeatureModeOptions.RenderLiveFrameData; _device.WriteFeatureData(stopCommand.GetReportData()); } }
public bool StartPlaybackOfStoredProgram() { if (_connectedToDriver && !_isProgramming) { var playCommand = new SetFeatureReport {Command = SetFeatureCommands.ChangeFeatureMode}; playCommand.CommandData[0] = (byte) FeatureModeOptions.PlayStoredProgram; return _device.WriteFeatureData(playCommand.GetReportData()); } return false; }
public void SetDeviceConfiguration(RgbColor staticColor) { if (_device == null) return; var report = new SetFeatureReport {Command = SetFeatureCommands.SetStaticColor}; staticColor.GetBytes().CopyTo(report.CommandData, 0); _device.WriteFeatureData(report.GetReportData()); }