public MainPage()
        {
            this.InitializeComponent();

            //uses the default mpr121 address and Pin #5 on the RaspberryPi as IRQ Pin
            __mpr121 = new MPR121();

            //            this.pinList.DataContext = this.__mpr121;
            //this.pinList.ItemsSource = this.__mpr121.Pins;
            //this.pinList.UpdateLayout();

            pinStatusUIElements = new UIElement[] { pin0Status,pin1Status, pin2Status, pin3Status,
                                                    pin4Status, pin5Status,pin6Status, pin7Status,
                                                    pin8Status,pin9Status, pin10Status, pin11Status };

            this.__initMPR121();
        }
Пример #2
0
        private async void __initMPR121()
        {
            __mpr121 = new MPR121();
            //Get the I2C device list on the Raspberry Pi.
            string aqs = I2cDevice.GetDeviceSelector(); //get the device selector AQS  (adavanced query string)
            var i2cDeviceList = await DeviceInformation.FindAllAsync(aqs); //get the I2C devices that match the device selector aqs

            //if the device list is not null, try to establish I2C connection between the master and the MPR121
            if (i2cDeviceList != null && i2cDeviceList.Count > 0)
            {
                bool connected = await __mpr121.OpenConnection(i2cDeviceList[0].Id);
                if (connected)
                {
                    //MPR121 will raise Touched and Released events if the IRQ pin is connected and configured corectly.. 
                    //Adding event handlers for those events
                    __mpr121.PinTouched += __mpr121_PinTouched; ;
                    __mpr121.PinReleased += __mpr121_PinReleased; ; ;
                }
            }

        }