コード例 #1
0
 private static string GenerateFromSetFeatureReport(SetFeatureReport report)
 {
     var bytes = report.GetReportData();
     var sb = new StringBuilder();
     sb.Append("sf ");
     AppendBytesAsString(bytes, sb);
     return sb.ToString();
 }
コード例 #2
0
        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();
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public void StopPlaybackOfStoredProgram()
 {
     if (_connectedToDriver && !_isProgramming)
     {
         var stopCommand = new SetFeatureReport { Command = SetFeatureCommands.ChangeFeatureMode };
         stopCommand.CommandData[0] = (byte)FeatureModeOptions.RenderLiveFrameData;
         _device.WriteFeatureData(stopCommand.GetReportData());
     }
 }
コード例 #6
0
 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;
 }
コード例 #7
0
        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());
        }