Beispiel #1
0
 protected virtual void OnPinReleased(PinReleasedEventArgs releasedEventArgs)
 {
     if (PinReleased != null)
     {
         PinReleased(this, releasedEventArgs);
     }
 }
 private void __mpr121_PinReleased(object sender, PinReleasedEventArgs e)
 {
     var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         santas[currentSanta].Visibility = Visibility.Collapsed;
     });
 }
Beispiel #3
0
        private void Mpr122IRQpin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.FallingEdge)
            {
                //read the touch status register and convert it in to CapsenseElectrode Enum
                int rawTouchRegisterData = readTouchStatusRegister();
                currentReading = (PinId)rawTouchRegisterData;

                List <PinId> allTouchedPins  = new List <PinId>();
                List <PinId> allReleasedPins = new List <PinId>();

                foreach (PinId val in Enum.GetValues(typeof(PinId))) //loop through all CapSense Pins
                {
                    if (val != PinId.None)
                    {
                        if (currentReading.HasFlag(val) && !lastReading.HasFlag(val))
                        {
                            allTouchedPins.Add(val);
                            this.__pins.Find(p => p.PinId == val).SetTouched(true);
                        }

                        if (!currentReading.HasFlag(val) && lastReading.HasFlag(val))
                        {
                            allReleasedPins.Add(val);
                            this.__pins.Find(p => p.PinId == val).SetTouched(false);
                        }
                    }
                }

                allTouchedPins.TrimExcess();
                allReleasedPins.TrimExcess();
                if (allTouchedPins.Count > 0)
                {
                    PinTouchedEventArgs touchedData = new PinTouchedEventArgs(allTouchedPins);
                    OnPinTouched(touchedData);
                }

                if (allReleasedPins.Count > 0)
                {
                    PinReleasedEventArgs releasedData = new PinReleasedEventArgs(allReleasedPins);
                    OnPinReleased(releasedData);
                }

                lastReading = currentReading;
            }
        }
        private void __mpr121_PinReleased(object sender, PinReleasedEventArgs e)
        {
            var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                
                this.txtStatus.Text = e.Released[0].ToString() + " Released"; //just the first released pin

                __updatePinStatusUI(e.Released,false);
            });
        }
 protected virtual void OnPinReleased(PinReleasedEventArgs releasedEventArgs)
 {
     if (PinReleased != null) { PinReleased(this, releasedEventArgs); }
 }
        private void Mpr122IRQpin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.FallingEdge)
            {
                //read the touch status register and convert it in to CapsenseElectrode Enum
                int rawTouchRegisterData = readTouchStatusRegister();
                currentReading = (PinId)rawTouchRegisterData;

                List<PinId> allTouchedPins = new List<PinId>();
                List<PinId> allReleasedPins = new List<PinId>();

                foreach (PinId val in Enum.GetValues(typeof(PinId))) //loop through all CapSense Pins
                {
                    if (val != PinId.None)
                    {
                        if (currentReading.HasFlag(val) && !lastReading.HasFlag(val))
                        {
                            allTouchedPins.Add(val);
                            this.__pins.Find(p => p.PinId == val).SetTouched(true);
                        }

                        if (!currentReading.HasFlag(val) && lastReading.HasFlag(val))
                        {
                            allReleasedPins.Add(val);
                            this.__pins.Find(p => p.PinId == val).SetTouched(false);
                        }
                    }
                }

                allTouchedPins.TrimExcess();
                allReleasedPins.TrimExcess();
                if (allTouchedPins.Count > 0)
                {
                    PinTouchedEventArgs touchedData = new PinTouchedEventArgs(allTouchedPins);
                    OnPinTouched(touchedData);
                }

                if (allReleasedPins.Count>0)
                {
                    PinReleasedEventArgs releasedData = new PinReleasedEventArgs(allReleasedPins);
                    OnPinReleased(releasedData);
                }

                lastReading = currentReading;
            }
        }