Example #1
0
        protected virtual void Update()
        {
            CheckForPositionChanges();

            if (OnDistance != null && SgtFloatingCamera.Instances.Count > 0)
            {
                var floatingCamera = SgtFloatingCamera.Instances.First.Value;
                var distance       = SgtPosition.Distance(position, floatingCamera.Position);

                OnDistance.Invoke(distance);
            }
        }
        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);
                }
            }
        }