コード例 #1
0
        public static void IrTest(List <string> argsList, IrReceiver ir)
        {
            Console.WriteLine($"Ir Test");

            double delay;

            if (argsList.Count > 1)
            {
                delay = Convert.ToDouble(argsList[1]);
            }
            else
            {
                delay = 10;
            }

            while (true)
            {
                int data = ir.GetKey();
                if (data == 0 & data != 999)
                {
                    Console.Write($"_");
                }
                else if (data == 999)
                {
                    Console.WriteLine($"data: repeated last");
                }
                else
                {
                    Console.WriteLine($"data: {data} ");
                }
                DelayHelper.DelayMilliseconds((int)delay, true);
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            IrReceiver ir = new IrReceiver();

            ir.IrKeyPress += RecievedIrKey;
            ir.Start();

            Console.WriteLine("IR Test running press any key to exit");
            Console.ReadKey();

            ir.Stop();
            ir.IrKeyPress -= RecievedIrKey;

            Console.WriteLine("IR Test exited...");
        }
コード例 #3
0
        public static void IrTest1(List <string> argsList, IrReceiver ir)
        {
            Console.WriteLine($"Ir Test1");

            double delay;

            if (argsList.Count > 1)
            {
                delay = Convert.ToDouble(argsList[1]);
            }
            else
            {
                delay = 10;
            }

            while (true)
            {
                Console.WriteLine($"{ir.GetKeyTemp()}");
                DelayHelper.DelayMilliseconds((int)delay, true);
            }
        }
コード例 #4
0
ファイル: AlphaBot2.cs プロジェクト: ACT-ZUT/AlphaBot2.NET
        public void Enable(Accessories accessory)
        {
            try
            {
                switch (accessory)
                {
                case Accessories.Camera:
                    if (camera is null)
                    {
                        this.camera = new Camera();
                    }
                    else
                    {
                        Disable(Accessories.Camera); this.camera = new Camera();
                    }
                    break;

                case Accessories.IMU:
                    if (imu is null)
                    {
                        this.imu = new Mpu6050(I2cDevice.Create(
                                                   new I2cConnectionSettings(1, Mpu6050.DefaultI2cAddress)));
                    }
                    else
                    {
                        Disable(Accessories.IMU);
                        this.imu = new Mpu6050(I2cDevice.Create(
                                                   new I2cConnectionSettings(1, Mpu6050.DefaultI2cAddress)));
                    }
                    break;

                case Accessories.MotorL:
                    if (motorL is null)
                    {
                        this.motorL = DCMotor.Create(6, 12, 13);
                    }
                    else
                    {
                        Disable(Accessories.MotorL); this.motorL = DCMotor.Create(6, 12, 13);
                    }
                    break;

                case Accessories.MotorR:
                    if (motorR is null)
                    {
                        this.motorR = DCMotor.Create(26, 20, 21);
                    }
                    else
                    {
                        Disable(Accessories.MotorR); this.motorR = DCMotor.Create(26, 20, 21);
                    }
                    break;

                case Accessories.Motors:
                    Enable(Accessories.MotorL);
                    Enable(Accessories.MotorR);
                    break;

                case Accessories.ADC:
                    if (adc is null)
                    {
                        this.adc = new Tlc1543(24, 5, 23, 25);
                    }
                    else
                    {
                        Disable(Accessories.ADC); this.adc = new Tlc1543(24, 5, 23, 25);
                    }
                    break;

                case Accessories.IR:
                    if (ir is null)
                    {
                        this.ir = new IrReceiver(17);
                    }
                    else
                    {
                        Disable(Accessories.IR); this.ir = new IrReceiver(17);
                    }
                    break;

                case Accessories.Sonar:
                    if (sonar is null)
                    {
                        this.sonar = new Hcsr04(22, 27);
                    }
                    else
                    {
                        Disable(Accessories.Sonar); this.sonar = new Hcsr04(22, 27);
                    }
                    break;

                case Accessories.LED:
                    if (led is null)
                    {
                        this.led = new Ws2812b(18, 4);
                    }
                    else
                    {
                        Disable(Accessories.LED); this.led = new Ws2812b(18, 4);
                    }
                    break;

                case Accessories.CPUTemp:
                    if (cpuTemperature is null)
                    {
                        this.cpuTemperature = new CpuTemperature();
                    }
                    //else { Disable(led); this.led = new Ws2812b(18, 4); }
                    break;

                case Accessories.All:
                    foreach (var item in Enum.GetValues(typeof(Accessories)))
                    {
                        Enable((Accessories)item);
                    }
                    break;

                default:
                    Console.WriteLine("Something went wrong (Enabling accessories)");
                    break;
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine($"Enabling accessory: {Enum.GetName(typeof(Accessories), accessory)} failed.");
                System.Diagnostics.Debug.WriteLine($"Exception message: {ex.Message}");

                Console.WriteLine($"Enabling accessory: {Enum.GetName(typeof(Accessories), accessory)} failed.");
                Console.WriteLine($"Exception message: {ex.Message}");
            }
        }