예제 #1
0
        public override void Run()
        {
            RequireRx();
            RequireTx();

            Console.WriteLine("This demo will transmit any received IR signals. There is no filtering of");
            Console.WriteLine("signals, so noise will also be repeated.");
            Console.WriteLine();
            Console.WriteLine("If you want you can have the signals rounded off to a known PULSE/SPACE");
            Console.WriteLine("duration to help correct errors. Or you can just allow the raw signals through.");
            Console.Write("Round to (or leave blank): ");
            _roundTo = ReadInt32();

            Console.WriteLine();
            Console.WriteLine();

            _sender = new RaspberryIRDotNet.TX.PulseSpaceTransmitter_ManualOpenClose()
            {
                TransmissionDevice = DemoConfig.GetTxDevice()
            };
            var receiver = new Receiver()
            {
                CaptureDevice = DemoConfig.GetRxDevice(),
                OnRx          = OnRx
            };

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Starting repeater. Use Ctrl+C to stop.");
            Console.WriteLine();
            Console.WriteLine();
            _sender.Open();
            receiver.Start();
        }
        private RaspberryIRDotNet.TX.PulseSpaceTransmitter_ManualOpenClose MakeSubject(FileSystem.IFileSystem fileSystem)
        {
            var subject = new RaspberryIRDotNet.TX.PulseSpaceTransmitter_ManualOpenClose()
            {
                TransmissionDevice = LircPath
            };

            subject.SetFileSystem(fileSystem);
            return(subject);
        }
        public void NoDeviceSet()
        {
            // ARRANGE
            var fileSystem = new Mock <FileSystem.IFileSystem>(MockBehavior.Strict);
            var subject    = new RaspberryIRDotNet.TX.PulseSpaceTransmitter_ManualOpenClose();

            subject.SetFileSystem(fileSystem.Object);

            // ACT, ASSERT
            Assert.That(() => subject.Open(), Throws.ArgumentNullException.With.Property("ParamName").EqualTo("TransmissionDevice"));
            Assert.That(subject.IsOpen, Is.False);
            Assert.That(subject.Disposed, Is.False);
        }
예제 #4
0
        public override void Run()
        {
            RequireRx();

            RaspberryIRDotNet.IReadOnlyPulseSpaceDurationList leadInDurations = LearnExpectedLeadInDurations();
            int unitDuration = LearnExpectedUnitDuration(leadInDurations);
            int unitCount    = LearnExpectedUnitCount(leadInDurations, unitDuration);

            Console.WriteLine("IR parameters learnt. Now ready to learn individual buttons.");
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            var key1 = LearnKey("1", leadInDurations, unitDuration, unitCount);
            var key2 = LearnKey("2", leadInDurations, unitDuration, unitCount);

            Console.WriteLine("IR codes learnt. Now press 1 or 2 on the Pi's keyboard to transmit those IR codes.");

            RequireTx();

            using (var sender = new RaspberryIRDotNet.TX.PulseSpaceTransmitter_ManualOpenClose()
            {
                TransmissionDevice = DemoConfig.GetTxDevice()
            })
            {
                sender.Open();
                while (true)
                {
                    var choice = Console.ReadKey();
                    if (choice.Key == ConsoleKey.Escape)
                    {
                        Console.WriteLine();
                        Console.WriteLine("Escape pressed, quitting.");
                        return;
                    }
                    else if (choice.KeyChar == '1')
                    {
                        sender.Send(key1);
                    }
                    else if (choice.KeyChar == '2')
                    {
                        sender.Send(key2);
                    }
                    else
                    {
                        Console.WriteLine();
                        Console.WriteLine("Press 1, 2 or escape.");
                    }
                }
            }
        }