Ejemplo n.º 1
0
 private void lightningDetectorSPI_LightningDetected(LightningDetectorSPI sender,
     LightningDetectorSPI.LightningEventArgs e)
 {
     led7C.SetColor(LED7C.Color.Red);
     lightningSPI = "L " + e.Distance + " " + e.Energy;
     UpdateDisplay();
 }
Ejemplo n.º 2
0
 private void lightningDetectorSpi_NoiseDetected(LightningDetectorSPI sender)
 {
     Debug.Print("Noise Detected");
 }
Ejemplo n.º 3
0
 private void lightningDetectorSpi_LightningDetected(LightningDetectorSPI sender,
     LightningDetectorSPI.LightningEventArgs e)
 {
     Debug.Print("Lightning Detected " + e.Distance + " km away with energy " + e.Energy);
 }
Ejemplo n.º 4
0
 private void lightningDetectorSpi_DisturbanceDetected(LightningDetectorSPI sender)
 {
     Debug.Print("Disturbance  Detected");
 }
        private void OnNoiseEvent(LightningDetectorSPI sender)
        {
            if (onNoiseEvent == null)
                onNoiseEvent = OnNoiseEvent;

            if (Program.CheckAndInvoke(NoiseDetected, onNoiseEvent, sender))
            {
                NoiseDetected(sender);
            }
        }
        private void OnLightningEvent(LightningDetectorSPI sender, LightningEventArgs e)
        {
            if (onLightningEvent == null)
                onLightningEvent = OnLightningEvent;

            if (Program.CheckAndInvoke(LightningDetected, onLightningEvent, sender, e))
            {
                LightningDetected(sender, e);

                if (onLightningEvent == null)
                    onLightningEvent = OnLightningEvent;
            }
        }
        private void OnDisturbanceEvent(LightningDetectorSPI sender)
        {
            if (onDisturbanceEvent == null)
                onDisturbanceEvent = OnDisturbanceEvent;

            if (Program.CheckAndInvoke(DisturbanceDetected, onDisturbanceEvent, sender))
            {
                DisturbanceDetected(sender);
            }
        }
Ejemplo n.º 8
0
 private void lightningDetectorSPI_NoiseDetected(LightningDetectorSPI sender)
 {
     led7C.SetColor(LED7C.Color.Yellow);
     lightningSPI = "Noise";
     UpdateDisplay();
 }
Ejemplo n.º 9
0
 private void lightningDetectorSPI_DisturbanceDetected(LightningDetectorSPI sender)
 {
     led7C.SetColor(LED7C.Color.Magenta);
     lightningSPI = "Disturbance";
     UpdateDisplay();
 }
        /// <summary>
        ///     Raises the <see cref="ButtonPressed" /> or <see cref="ButtonReleased" /> event.
        /// </summary>
        /// <param name="sender">The <see cref="LightningDetectorSPI" /> that raised the event.</param>
        /// <param name="buttonState">The state of the button.</param>
        protected virtual void OnButtonEvent(LightningDetectorSPI sender, ButtonState buttonState)
        {
            if (onButton == null)
            {
                onButton = OnButtonEvent;
            }

            if (buttonState == ButtonState.Pressed)
            {
                // Program.CheckAndInvoke helps event callers get onto the Dispatcher thread.
                // If the event is null then it returns false.
                // If it is called while not on the Dispatcher thread, it returns false but also re-invokes this method on the Dispatcher.
                // If on the thread, it returns true so that the caller can execute the event.
                if (Program.CheckAndInvoke(ButtonPressed, onButton, sender, buttonState))
                {
                    ButtonPressed(sender, buttonState);
                }
            }
            else
            {
                if (Program.CheckAndInvoke(ButtonReleased, onButton, sender, buttonState))
                {
                    ButtonReleased(sender, buttonState);
                }
            }
        }