private void EchoGpio_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.RisingEdge)
            {
                pulseLength.Start();
            }
            else
            {
                pulseLength.Stop();

                TimeSpan timeBetween = pulseLength.Elapsed;
                var      distance    = timeBetween.TotalSeconds * 17000;

                if (OnDistance != null)
                {
                    OnDistance.Invoke(distance);
                }
            }
        }
Ejemplo n.º 2
0
 // Bouton Vert
 private void _pin13_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     // Détection du front montant
     if (args.Edge == GpioPinEdge.RisingEdge)
     {
         if (_MODE.Equals("HORLOGE"))
         {
         }
         else if (_MODE.Equals("REVEIL_SET"))
         {
             // Retrait d'une heure à l'horaire de réveil
             _H_REG = _UtilReveilDriver.removeHour(_H_REG);
             _H_SON = _H_REG;
         }
         else if (_MODE.Equals("REVEIL_ON"))
         {
         }
         else if (_MODE.Equals("REVEIL_TYPE"))
         {
             if (_TYPE.Equals("SONNERIE"))
             {
                 _TYPE = "MP3";
             }
             else if (_TYPE.Equals("MP3"))
             {
                 _TYPE = "RADIO";
             }
             else if (_TYPE.Equals("RADIO"))
             {
                 _TYPE = "SONNERIE";
             }
         }
         else if (_MODE.Equals("MP3"))
         {
         }
         else if (_MODE.Equals("RADIO"))
         {
         }
         else if (_MODE.Equals("SONNERIE"))
         {
         }
     }
 }
Ejemplo n.º 3
0
        private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            lock (_lock)
            {
                if (!_evaluatingRows)
                {
                    IGpioPinMapping mapping = this.PinMappings.Where(t => t.PinNumber == sender.PinNumber).SingleOrDefault();

                    if (mapping != null)
                    {
                        PinChangedStatus status = mapping.GetChangedStatus(args.Edge);
                        if (status != PinChangedStatus.None)
                        {
                            this.OnPinValueChanged(mapping, status);
                        }
                    }
                }
            }
        }
        private void InterruptGpioPinOnValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            try
            {
                _lastState = new GroveMiniPIRMotionSensorState()
                {
                    CurrentEdge = args.Edge,
                    PinNumber   = sender.PinNumber
                };

                if (myAction != null)
                {
                    myAction.Invoke(_lastState);
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 5
0
        private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            byte[] r;

            if (!_i2CDevice.Read(2, out r))
            {
                return;
            }

            var touched = BitConverter.ToUInt16(r, 0);

            for (var i = 0; i <= 15; i++)
            {
                if ((touched & (1 << i)) != 0)
                {
                    Debug.WriteLine("Touched " + i);
                }
            }
        }
Ejemplo n.º 6
0
 private void Light_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
 {
     if (e.Edge == GpioPinEdge.FallingEdge) //release
     {
         SetLED(LEDCOLOR.Grey);
         var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             timer.Stop();
         });
     }
     else //pressed
     {
         SetLED(LEDCOLOR.Blue);
         var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             timer.Start();
         });
     }
 }
Ejemplo n.º 7
0
        private async void ButtonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.FallingEdge)
            {
                // Get Registered Callbacks
                IClientCallbackStore <PushTriggerConfiguration> callbackStore = new AzureStorageClientCallbackStore <PushTriggerConfiguration>();
                var callbacks = await callbackStore.ReadCallbacksAsync();

                // Trigger Logic App
                foreach (var callback in callbacks)
                {
                    if (!callback.Configuration.Enabled)
                    {
                        continue;
                    }
                    await callback.InvokeAsync();
                }
            }
        }
Ejemplo n.º 8
0
        private void buttonPressed(object sender, GpioPinValueChangedEventArgs e)
        {
            if (e.Edge == GpioPinEdge.FallingEdge)
            {
                var pin = (GpioPin)sender;

                if (pin != null)
                {
                    var button = (Buttons)pin.PinNumber;

                    if (button == Buttons.Select)
                    {
                        _isQuitPressed = true;
                    }

                    _buttonPressStack.Push(button);
                }
            }
        }
Ejemplo n.º 9
0
        private void buttonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            // Random para seleccionar un color al azar
            Random r     = new Random();
            int    color = r.Next(3);

            // Si el boton esta pulsado
            if (args.Edge == GpioPinEdge.FallingEdge)
            {
                Debug.WriteLine("Button Pressed");
                // Establece el color según el valor obtenido en el random
                switch (color)
                {
                default:
                    pinVerde.Write(GpioPinValue.Low);
                    pinRojo.Write(GpioPinValue.Low);
                    break;

                case 0:     // Verde
                    pinVerde.Write(GpioPinValue.High);
                    pinRojo.Write(GpioPinValue.Low);
                    break;

                case 1:     // Rojo
                    pinVerde.Write(GpioPinValue.Low);
                    pinRojo.Write(GpioPinValue.High);
                    break;

                case 2:
                    pinVerde.Write(GpioPinValue.High);
                    pinRojo.Write(GpioPinValue.High);
                    break;
                }
            }
            else
            {
                Debug.WriteLine("Button Released");
                // Una vez soltado el boton, apagamos el led
                pinVerde.Write(GpioPinValue.Low);
                pinRojo.Write(GpioPinValue.Low);
            }
        }
Ejemplo n.º 10
0
 private async void StopButtonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     GpioPinValue currentValue = sender.Read();
     await eventDispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         bool wasDown   = stopButtonDown;
         stopButtonDown = (currentValue == GpioPinValue.Low);
         if (wasDown != stopButtonDown)
         {
             if (stopButtonDown)
             {
                 GpioStopButtonDown?.Invoke(this, null);
             }
             else
             {
                 GpioStopButtonUp?.Invoke(this, null);
             }
         }
     });
 }
Ejemplo n.º 11
0
 private void EncA_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
 {
     _aState = _encA.Read();
     if (_aState != _aLastState)
     {
         if (_encB.Read() != _aState)
         {
             InternalCounter++;
             Direction = Directions.Clockwise;
         }
         else
         {
             InternalCounter--;
             Direction = Directions.CounterClockwise;
         }
         RotationEventHandler rotationEvent = RotationDetected;
         rotationEvent(this, new RotationEventArgs(Direction, InternalCounter));
     }
     _aLastState = _aState;
 }
Ejemplo n.º 12
0
        private void _buttonDisLike_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.FallingEdge)
            {
                if (SelectedMenuItem != null)
                {
                    var task = Task.Run(() => WebApiHelper.UpdateProduct(SelectedMenuItem.Id, false));
                    task.Wait();

                    if (task.Result != null)
                    {
                        Dispatcher.InvokeOnUI(() =>
                        {
                            SelectedMenuItem.Reset(task.Result);
                            CustomText = "Button DisLike was pressed...";
                        });
                    }
                }
            }
        }
        private void InterruptPinB_ValueChanged(object sender, GpioPinValueChangedEventArgs e)
        {
            var interruptFlags = this.ReadRegister(MCP23017_INTFB);

            for (byte i = 0; i < 8; i++)
            {
                var interruptFlag = (interruptFlags & (1 << i)) != 0;
                if (interruptFlag)
                {
                    var capture = ReadRegister(MCP23017_INTCAPB, i);
                    var value   = this.ReadRegister(MCP23017_GPIOB, i);

                    // We can now fire the individual PORT event handler.
                    if (this._gpioPin[i + 8] != null)
                    {
                        this._gpioPin[i + 8].DoValueChangedEvent(new GpioPinValueChangedEventArgs(capture ? GpioPinEdge.FallingEdge : GpioPinEdge.RisingEdge));
                    }
                }
            }
        }
Ejemplo n.º 14
0
 // Detect button press event
 private void Button_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
 {
     // Pedestrian has pushed the button. Start timer for going red.
     if (e.Edge == GpioPinEdge.FallingEdge)
     {
         // Start the timer if and only if not in a cycle
         if (this.secondsElapsed == 0)
         {
             // need to invoke UI updates on the UI thread because this event
             // handler gets invoked on a separate thread.
             var task = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
             {
                 if (e.Edge == GpioPinEdge.FallingEdge)
                 {
                     this.walkTimer.Start();
                 }
             });
         }
     }
 }
        /// <summary>
        /// Get sensor data and display the result
        /// </summary>
        private async Task GetSensorValueAndUpdateUI(string sensorName, GpioPinValueChangedEventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            // When user touched, pushed or tiled, then lit the LED and display sensor data
            if (e.Edge == GpioPinEdge.RisingEdge)
            {
                ledPinValue = GpioPinValue.High;
                ledPin.Write(ledPinValue);
                onboardLedPin1Value = GpioPinValue.High;
                onboardLedPin1.Write(onboardLedPin1Value);
                onboardLedPin2Value = GpioPinValue.High;
                onboardLedPin2.Write(onboardLedPin1Value);
                sb.Append($"{sensorName} on");

                var geoposition = await GetCurrentLocation();

                sb.Append($"Temp: {GetTemperature()}");
                sb.Append($"Lux: {GetLux()}");
                sb.Append($"Latitude: {geoposition.Coordinate.Point.Position.Latitude}");
                sb.Append($"Longitude: {geoposition.Coordinate.Point.Position.Longitude}");
            }
            else if (e.Edge == GpioPinEdge.FallingEdge)
            {
                ledPinValue = GpioPinValue.Low;
                ledPin.Write(ledPinValue);
                onboardLedPin1Value = GpioPinValue.Low;
                onboardLedPin1.Write(onboardLedPin1Value);
                onboardLedPin2Value = GpioPinValue.Low;
                onboardLedPin2.Write(onboardLedPin1Value);
                sb.Append($"Off");
            }

            // Display the result to the view.
            await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                LedColor = (ledPinValue == GpioPinValue.High) ?
                           redBrush : grayBrush;
                Message = sb.ToString();
            });
        }
Ejemplo n.º 16
0
        private void Pin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            var currentPinValue = pin.Read();

            // If same value of last read, exits.
            if (currentPinValue == lastPinValue)
            {
                return;
            }

            // Checks the pin value.
            if (currentPinValue == actualHighPinValue)
            {
                longClickWatch.Restart();

                IsPressed = true;
                this.RaiseEvent(Pressed);
            }
            else if (currentPinValue == actualLowPinValue)
            {
                longClickWatch.Stop();

                this.RaiseEvent(Released);

                if (IsPressed)
                {
                    IsPressed = false;

                    if (longClickWatch.Elapsed > longClickTimeout)
                    {
                        this.RaiseEvent(LongClick);
                    }
                    else
                    {
                        this.RaiseEvent(Click);
                    }
                }
            }

            lastPinValue = currentPinValue;
        }
Ejemplo n.º 17
0
        private void Input_ValueChanged(object sender, GpioPinValueChangedEventArgs e)
        {
            var state = e.Edge == GpioPinEdge.FallingEdge ? ButtonState.Released : ButtonState.Pressed;

            switch (state)
            {
            case ButtonState.Released:
                if (this.Mode == LedMode.OnWhilePressed)
                {
                    this.TurnLedOff();
                }
                else if (this.Mode == LedMode.OnWhileReleased)
                {
                    this.TurnLedOn();
                }
                else if (this.Mode == LedMode.ToggleWhenReleased)
                {
                    this.ToggleLED();
                }

                break;

            case ButtonState.Pressed:
                if (this.Mode == LedMode.OnWhilePressed)
                {
                    this.TurnLedOn();
                }
                else if (this.Mode == LedMode.OnWhileReleased)
                {
                    this.TurnLedOff();
                }
                else if (this.Mode == LedMode.ToggleWhenPressed)
                {
                    this.ToggleLED();
                }

                break;
            }

            this.OnButtonEvent(this, state);
        }
Ejemplo n.º 18
0
        private void SwPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.FallingEdge)
            {
                // switch down
                //ToggleLED();

                // Cross Thread 문제가 발생!!
                if (isBlink == true)
                {
                    tmrBlink.Stop();
                }
                else
                {
                    tmrBlink.Start();
                }

                isBlink = !isBlink;
            }
            //throw new NotImplementedException();
        }
Ejemplo n.º 19
0
 protected override void countStep(GpioPin p, GpioPinValueChangedEventArgs args)
 {
     if (motorDrv.State == MotorState.Forward)
     {
         if (args.Edge == GpioPinEdge.FallingEdge)
         {
             Position++;
         }
     }
     else if (motorDrv.State == MotorState.Backward)
     {
         if (args.Edge == GpioPinEdge.RisingEdge)
         {
             Position--;
         }
     }
     else
     {
         System.Diagnostics.Debug.WriteLine("Read step when motor stopped.");
     }
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Event handler for when the GPIO pin value is changed
        /// </summary>
        /// <param name="sender">The sender object</param>
        /// <param name="args">Event arguements</param>
        private void OnValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            //default is high, so check for lows
            //roomba IR works by pulsing the frequency
            //but we only need a few downs to detect the IR

            //but make sure we have started the sensor reading
            if (!Enabled)
            {
                return;
            }
            if (args.Edge == GpioPinEdge.FallingEdge)
            {
                if (NumDetections++ >= DetectionThreshold)
                {
                    WallDetected = true;
                    //do not fire any more events since we don't have to anymore
                    _pin.ValueChanged -= OnValueChanged;
                }
            }
        }
Ejemplo n.º 21
0
        private void DataReady(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge == GpioPinEdge.FallingEdge)
            {
                if (_tcs == null)
                {
                    return;
                }
                try
                {
                    var           r     = ReadRegister(Register.ConfB, 8);
                    MagneticField field = RegistersToMagneticField(r);

                    _tcs.SetResult(field);
                }
                catch (Exception ex)
                {
                    _tcs.SetException(ex);
                }
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// This interrupt will trigger when detector receives back reflected sonic pulse
        /// </summary>
        /// <param name="data1">Not used</param>
        /// <param name="data2">Not used</param>
        /// <param name="time">Transfer to endTick to calculated sound pulse travel time</param>
        void InterIn_OnInterrupt(object sender, GpioPinValueChangedEventArgs e)
        {
            // if (gpcc.IsStarted) { gpcc.Stop(); }

            // save the ticks when pulse was received back
            //if (e.Edge == GpioPinEdge.RisingEdge)
            //{
            //    beginTick = (long)gpcc.Read().Count;
            //   // Console.WriteLine("begintick = " + beginTick.ToString());
            //};

            if (e.Edge == GpioPinEdge.FallingEdge)
            {
                etick = gpcc.Read();
                //endTick = (long)gpcc.Read().Count;
                //Console.WriteLine("EndTick = " + endTick.ToString());
            }
            ;
            //GpioChangeCount etick = gpcc.Reset();
            // endTick = etick.Count;
        }
Ejemplo n.º 23
0
 private async void buttonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
 {
     await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
     {
         if (e.Edge != GpioPinEdge.FallingEdge)
         {
             return;
         }
         if (_timer.IsEnabled)
         {
             _timer.Stop();
             _pin.Write(GpioPinValue.High);
             GpioText.Text = "LED stopped";
         }
         else
         {
             _timer.Start();
             GpioText.Text = "LED started";
         }
     });
 }
        private void boton1_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)//Funcion que verifica el estado en boton es decir presionado o no
        {
            if (e.Edge == GpioPinEdge.FallingEdge)
            {
                valor_led = (valor_led == GpioPinValue.Low) ? //Si el valor del led es 0 lo colocara en 1 y viceversa
                            GpioPinValue.High : GpioPinValue.Low;
                Led1.Write(valor_led);                        //Enciende el led
            }

            //Esta funcion es opcional y unicamente sirve para cuando este presionado el boton, nos muestre el estado del led
            //El metodo se creo como un procedimiento asincrono, ya que se ejecuta a la par de la funcion cambio del estado del boton
            //los colores se tienen que declarar como recursos
            var task = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                if (e.Edge == GpioPinEdge.FallingEdge)  //Verifica el valor del led para colocar el color segun corresponda
                {
                    led_virtual.Fill = (valor_led == GpioPinValue.Low) ?
                                       Rojo : Gris;
                }
            });
        }
Ejemplo n.º 25
0
        private void TriggerEchoPort_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
        {
            if (triggerEchoPort.Read() == GpioPinValue.High)
            {
                tickStart = DateTime.Now.Ticks;
                return;
            }

            // Calculate Difference
            float elapsed = DateTime.Now.Ticks - tickStart;

            // Return elapsed ticks
            // x10 for ticks to micro sec
            // divide by 58 for cm (assume speed of sound is 340m/s)
            CurrentDistance = elapsed / 580f;

            //    if (CurrentDistance < MinimumDistance || CurrentDistance > MaximumDistance)
            //       CurrentDistance = -1;

            DistanceDetected?.Invoke(this, new DistanceEventArgs(CurrentDistance));
        }
Ejemplo n.º 26
0
        private void Button_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
        {
            for (var i = 0; i < 4; i++)
            {
                if (sender.PinNumber == this.buttons[i].PinNumber)
                {
                    var pressed = e.Edge == GpioPinEdge.FallingEdge;

                    switch ((Button)i)
                    {
                    case Button.Left: (pressed ? this.WhenLeftButtonPressed : this.WhenLeftButtonReleased)?.Invoke(); break;

                    case Button.Right: (pressed ? this.WhenRightButtonPressed : this.WhenRightButtonReleased)?.Invoke(); break;

                    case Button.Up: (pressed ? this.WhenUpButtonPressed : this.WhenUpButtonReleased)?.Invoke(); break;

                    case Button.Down: (pressed ? this.WhenDownButtonPressed : this.WhenDownButtonReleased)?.Invoke(); break;
                    }
                }
            }
        }
        private void OnEchoResponse(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (RobotController.SystemDispatcher == null)
            {
                NetworkUtils.LogNetwork("RobotController.SystemDispatcher is null", MessageType.Error);
                return;
            }
            var task = RobotController.SystemDispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                switch (args.Edge)
                {
                case GpioPinEdge.FallingEdge:
                    //session_microseconds = distanceTimer.ElapsedTicks / TICKS_PER_MICROSECOND;
                    //distance_in_cm = session_microseconds * MICROSECONDS_TO_CM;
                    //just using elappsed ms for now
                    Collected_Distance = distanceTimer.ElapsedMilliseconds;
                    if (Current_avg_itteration++ >= Total_avg_itterations)
                    {
                        Distance_in_cm         = Avg_Distance / Total_avg_itterations;
                        Current_avg_itteration = 1;
                        Avg_Distance           = 0;
                    }
                    else
                    {
                        if (Collected_Distance > Maximum_distance_width)
                        {
                            Collected_Distance = Maximum_distance_width;
                        }
                        Avg_Distance += Collected_Distance;
                    }
                    distanceTimer.Reset();
                    break;

                case GpioPinEdge.RisingEdge:
                    //it's a response, log it!
                    distanceTimer.Start();
                    break;
                }
            });
        }
Ejemplo n.º 28
0
        private void InterruptGpioPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            if (args.Edge != GpioPinEdge.RisingEdge)
            {
                return;
            }

            byte IrqFlags = this.RegisterManager.ReadByte(0x12);             // RegIrqFlags

            Debug.WriteLine(string.Format("RegIrqFlags {0}", Convert.ToString(IrqFlags, 2).PadLeft(8, '0')));

            if ((IrqFlags & 0b01000000) == 0b01000000)              // RxDone
            {
                Debug.WriteLine("Receive-Message");
                byte currentFifoAddress = this.RegisterManager.ReadByte(0x10);            // RegFifiRxCurrent
                this.RegisterManager.WriteByte(0x0d, currentFifoAddress);                 // RegFifoAddrPtr

                byte numberOfBytes = this.RegisterManager.ReadByte(0x13);                 // RegRxNbBytes

                // Allocate buffer for message
                byte[] messageBytes = new byte[numberOfBytes];

                for (int i = 0; i < numberOfBytes; i++)
                {
                    messageBytes[i] = this.RegisterManager.ReadByte(0x00);                     // RegFifo
                }

                string messageText = UTF8Encoding.UTF8.GetString(messageBytes);
                Debug.WriteLine("Received {0} byte message {1}", messageBytes.Length, messageText);
            }

            if ((IrqFlags & 0b00001000) == 0b00001000)              // TxDone
            {
                this.RegisterManager.WriteByte(0x01, 0b10000101);   // RegOpMode set LoRa & RxContinuous
                Debug.WriteLine("Transmit-Done");
            }

            this.RegisterManager.WriteByte(0x40, 0b00000000);      // RegDioMapping1 0b00000000 DI0 RxReady & TxReady
            this.RegisterManager.WriteByte(0x12, 0xff);            // RegIrqFlags
        }
Ejemplo n.º 29
0
        // Bouton Jaune
        private void _pin26_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            // Détection du front montant
            if (args.Edge == GpioPinEdge.RisingEdge)
            {
                if (_MODE.Equals("HORLOGE"))
                {
                }
                else if (_MODE.Equals("REVEIL_SET"))
                {
                    // Retrait d'une minute à l'horaire de réveil
                    _M_REG = _UtilReveilDriver.removeMinute(_M_REG);
                    _M_SON = _M_REG;
                }
                else if (_MODE.Equals("REVEIL_ON"))
                {
                    if (reveil.Equals("1"))
                    {
                        mediaPlayerReveil.Pause();

                        _M_SON = _UtilReveilDriver.addMinute(_M_AFF);
                        _M_SON = _UtilReveilDriver.addMinute(_M_SON);

                        reveil = "0";
                    }
                }
                else if (_MODE.Equals("REVEIL_TYPE"))
                {
                }
                else if (_MODE.Equals("MP3"))
                {
                }
                else if (_MODE.Equals("RADIO"))
                {
                }
                else if (_MODE.Equals("SONNERIE"))
                {
                }
            }
        }
Ejemplo n.º 30
0
        private async void PinPIR_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
        {
            //simple guard to prevent it from triggering this function again before it's compelted the first time - one photo at a time please
            if (IsInPictureCaptureMode)
            {
                return;
            }
            else
            {
                IsInPictureCaptureMode = true;
            }

            // turn off the LED because we're about to take a picture and send to Bot
            LightLED(false);
            try
            {
                StorageFile picture = await TakePicture();

                if (picture != null)
                {
                    UploadPictureToBot(picture);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                //reset the "IsInPictureMode" singleton guard so the next
                //PIR movement can come into this method and take a picture
                IsInPictureCaptureMode = false;

                //Turn the LED Status Light on - we're ready for another picture
                LightLED(true);
            }

            return;
        }