Exemplo n.º 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();
        }
Exemplo n.º 2
0
        public override void Run()
        {
            RequireTx();
            var test = new RaspberryIRDotNet.TX.TestTransmitter()
            {
                TransmissionDevice = DemoConfig.GetTxDevice(),
                Frequency          = 9000,
                DutyCycle          = 50,
                Gap = TimeSpan.Zero,
            };

            Console.WriteLine($"This demo demonstrates how to use the {nameof(RaspberryIRDotNet.TX.TestTransmitter)} class by playing with the frequency and duty cycle. Connect the Pi's IR output pin to an oscilloscope to see the results.");
            Console.WriteLine("Press any key to start.");
            Console.ReadKey(true);

            while (true)
            {
                Run_Inner(test);
                Console.WriteLine();
                Console.Write("Run again?");
                bool again = Console.ReadKey(true).Key == ConsoleKey.Y;
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();
                if (!again)
                {
                    return;
                }
            }
        }
Exemplo n.º 3
0
        public override void Run()
        {
            RequireTx();

            var sender = new RaspberryIRDotNet.TX.PulseSpaceTransmitter_AutoOpenClose()
            {
                TransmissionDevice = DemoConfig.GetTxDevice()
            };

            var buffer = new RaspberryIRDotNet.PulseSpaceDurationList()
            {
                9000, // PULSE
                7000, // SPACE
                100,  // PULSE
                200,  // SPACE
                300,  // etc....
                400,
                500,
                600,
                700 // Last one must be a PULSE.
            };

            Console.WriteLine("This demo repeatedly sends the same fixed data over and over again.");
            Console.WriteLine("Use Ctrl+C to stop.");

            while (true)
            {
                sender.Send(buffer);
                System.Threading.Thread.Sleep(500);
            }
        }
Exemplo n.º 4
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            RouteConfig.RegisterRoutes(RouteTable.Routes);

            DemoConfig.RegisterDemo();
        }
Exemplo n.º 5
0
        public void Register(ContainerBuilder builder, ITypeFinder typeFinder, DemoConfig config)
        {
            builder.RegisterApiControllers(Assembly.GetExecutingAssembly());
            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            Assembly[] assemblies = Directory.GetFiles(AppDomain.CurrentDomain.RelativeSearchPath, "*.dll").Select(Assembly.LoadFrom).ToArray();
            Type       baseType   = typeof(IDependency);

            builder.RegisterAssemblyTypes(assemblies)
            .Where(type => baseType.IsAssignableFrom(type) && !type.IsAbstract)
            .AsSelf().AsImplementedInterfaces()
            .PropertiesAutowired().InstancePerLifetimeScope();
        }
Exemplo n.º 6
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.");
                    }
                }
            }
        }
Exemplo n.º 7
0
        public override void Run()
        {
            RequireRx();
            var receive = new RaspberryIRDotNet.RX.PulseSpaceConsoleWriter() /// Could also use <see cref="RaspberryIRDotNet.RX.FilteredPulseSpaceConsoleWriter"/>
            {
                CaptureDevice = DemoConfig.GetRxDevice()
            };

            Console.WriteLine("This demo will basically do the same as the \"ir-ctl -r\" command.");
            Console.WriteLine("Press any key to start.");
            Console.ReadKey(true);
            Console.WriteLine();
            Console.WriteLine();

            receive.Start();
        }
Exemplo n.º 8
0
        private RaspberryIRDotNet.IReadOnlyPulseSpaceDurationList LearnExpectedLeadInDurations()
        {
            var learner = new RaspberryIRDotNet.RX.LeadInLearner()
            {
                CaptureDevice = DemoConfig.GetRxDevice()
            };

            learner.Received += (s, e) => Console.Write("#");

            Console.WriteLine("This step will try to learn the lead-in pattern that prefixes each IR message.");
            Console.WriteLine("Press buttons at random (but don't hold them). A # will appear each time a signal is recognised.");

            var leadIn = learner.LearnLeadInDurations();

            Console.WriteLine();
            Console.WriteLine("Done, lead-in pattern (in microseconds) is: " + string.Join(",", leadIn));
            Breather();
            return(leadIn);
        }
Exemplo n.º 9
0
        private int LearnExpectedUnitDuration(RaspberryIRDotNet.IReadOnlyPulseSpaceDurationList leadInDurations)
        {
            var learner = new RaspberryIRDotNet.RX.UnitDurationLearner()
            {
                CaptureDevice          = DemoConfig.GetRxDevice(),
                LeadInPatternDurations = leadInDurations,
            };

            SetUpRxFeedback(learner);

            Console.WriteLine("This step will try to learn the unit duration of the IR message.");
            WriteKeyPressInstructions("any key", true);

            int duration = learner.LearnUnitDuration();

            Console.WriteLine();
            Console.WriteLine($"Done, unit duration is: {duration} microseconds.");
            Breather();
            return(duration);
        }
Exemplo n.º 10
0
        private RaspberryIRDotNet.IRPulseMessage LearnKey(string keyName, RaspberryIRDotNet.IReadOnlyPulseSpaceDurationList leadInDurations, int unitDuration, int unitCount)
        {
            var recorder = new RaspberryIRDotNet.RX.IRMessageLearn()
            {
                CaptureDevice           = DemoConfig.GetRxDevice(),
                UnitDurationMicrosecs   = unitDuration,
                MessageMinimumUnitCount = unitCount,
                MessageMaximumUnitCount = unitCount
            };

            recorder.SetLeadInPatternAsMicrosecs(leadInDurations);

            SetUpRxFeedback(recorder);
            WriteKeyPressInstructions($"the '{keyName}' key", false);

            var result = recorder.LearnMessage();

            Console.WriteLine("Key captured.");
            Breather();
            return(result);
        }
Exemplo n.º 11
0
        private int LearnExpectedUnitCount(RaspberryIRDotNet.IReadOnlyPulseSpaceDurationList leadInDurations, int unitDuration)
        {
            var counter = new RaspberryIRDotNet.RX.IRUnitCounter()
            {
                CaptureDevice         = DemoConfig.GetRxDevice(),
                UnitDurationMicrosecs = unitDuration,
            };

            counter.SetLeadInPatternAsMicrosecs(leadInDurations);

            SetUpRxFeedback(counter);

            Console.WriteLine("This step will try to learn how many units each IR message is.");
            WriteKeyPressInstructions("any key", true);

            int unitCount = counter.CaptureAndGetMostCommonUnitCount();

            Console.WriteLine();
            Console.WriteLine("Done, unit count is " + unitCount);
            Breather();
            return(unitCount);
        }
Exemplo n.º 12
0
 public Randomizer(DemoConfig config)
 {
     _config = config;
 }
Exemplo n.º 13
0
 public Thing1(DemoConfig config)
 {
     Number = config.Thing1;
 }