Open() public method

public Open ( ) : Task
return Task
Esempio n. 1
0
        internal async Task Start()
        {
            if (await _pca9685.Open())
            {
                Reset();
            }
            else
            {
                Debug.WriteLine("Could not find Pca9685");
                return;
            }

            //Self test
            for (byte pwmnum = 0; pwmnum < 16; pwmnum++)
            {
                for (ushort i = 4096; i > 0; i -= 4)
                {
                    SetPin(pwmnum, i);
                }
            }

            SetAllPwm(4096, 0);
        }
Esempio n. 2
0
        internal async Task InitHardware()
        {
            try
            {
                _ioController = GpioController.GetDefault();
                _interruptPin = _ioController.OpenPin(17);
                _interruptPin.Write(GpioPinValue.Low);
                _interruptPin.SetDriveMode(GpioPinDriveMode.Input);
                _interruptPin.ValueChanged += _interruptPin_ValueChanged;

                _mpu9150 = new I2CDevice((byte)Mpu9150Setup.Address, I2cBusSpeed.FastMode);
                await _mpu9150.Open();

                await Task.Delay(100);                                     // power up

                _mpu9150.Write((byte)Mpu9150Setup.PowerManagement1, 0x80); // reset the device

                await Task.Delay(100);

                _mpu9150.Write((byte)Mpu9150Setup.PowerManagement1, 0x2);
                _mpu9150.Write((byte)Mpu9150Setup.UserCtrl, 0x04);      //reset fifo

                _mpu9150.Write((byte)Mpu9150Setup.PowerManagement1, 1); // clock source = gyro x
                _mpu9150.Write((byte)Mpu9150Setup.GyroConfig, 0);       // +/- 250 degrees sec, max sensitivity
                _mpu9150.Write((byte)Mpu9150Setup.AccelConfig, 0);      // +/- 2g, max sensitivity

                _mpu9150.Write((byte)Mpu9150Setup.Config, 1);           // 184 Hz, 2ms delay
                _mpu9150.Write((byte)Mpu9150Setup.SampleRateDiv, 19);   // set rate 50Hz
                _mpu9150.Write((byte)Mpu9150Setup.FifoEnable, 0x78);    // enable accel and gyro to read into fifo
                _mpu9150.Write((byte)Mpu9150Setup.UserCtrl, 0x40);      // reset and enable fifo
                _mpu9150.Write((byte)Mpu9150Setup.InterruptEnable, 0x1);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }
Esempio n. 3
0
        internal async Task InitializeHardware()
        {
            try
            {
                _ioController = GpioController.GetDefault();
                _interruptPin = _ioController.OpenPin(17);
                _interruptPin.Write(GpioPinValue.Low);
                _interruptPin.SetDriveMode(GpioPinDriveMode.Input);
                _interruptPin.ValueChanged += Interrupt;
                
                _mpu9150 = new I2CDevice((byte)Mpu9150Setup.Address, I2cBusSpeed.FastMode);
                await _mpu9150.Open();

                await Task.Delay(5); // power up 

                _mpu9150.Write((byte)Mpu9150Setup.PowerManagement1, 0x80);// reset the device

                await Task.Delay(100);

                _mpu9150.Write((byte)Mpu9150Setup.PowerManagement1, 0x2 );
                _mpu9150.Write((byte)Mpu9150Setup.UserCtrl, 0x04);//reset fifo

                _mpu9150.Write((byte)Mpu9150Setup.PowerManagement1, 1 ); // clock source = gyro x
                _mpu9150.Write((byte)Mpu9150Setup.GyroConfig, 0); // +/- 250 degrees sec, max sensitivity
                _mpu9150.Write((byte)Mpu9150Setup.AccelConfig, 0); // +/- 2g, max sensitivity

                _mpu9150.Write((byte)Mpu9150Setup.Config, 1);// 184 Hz, 2ms delay
                _mpu9150.Write((byte)Mpu9150Setup.SampleRateDiv, 19); // set rate 50Hz
                _mpu9150.Write((byte)Mpu9150Setup.FifoEnable, 0x78); // enable accel and gyro to read into fifo
                _mpu9150.Write((byte)Mpu9150Setup.UserCtrl, 0x40); // reset and enable fifo
                _mpu9150.Write((byte)Mpu9150Setup.InterruptEnable, 0x1); 
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
        }