private void lightningDetectorI2C_LightningDetected(LightningDetectorI2C sender, LightningDetectorI2C.LightningEventArgs e) { led7C2.SetColor(LED7C.Color.Red); lightningI2C = "L " + e.Distance + " " + e.Energy; UpdateDisplay(); }
private void lightningDetectorI2C_NoiseDetected(LightningDetectorI2C sender) { led7C2.SetColor(LED7C.Color.Yellow); lightningI2C = "Noise"; UpdateDisplay(); }
private void lightningDetectorI2C_DisturbanceDetected(LightningDetectorI2C sender) { led7C2.SetColor(LED7C.Color.Magenta); lightningI2C = "Disturbance"; UpdateDisplay(); }
/// <summary> /// Raises the <see cref="ButtonPressed" /> or <see cref="ButtonReleased" /> event. /// </summary> /// <param name="sender">The <see cref="LightningDetectorI2C" /> that raised the event.</param> /// <param name="buttonState">The state of the button.</param> protected virtual void OnButtonEvent(LightningDetectorI2C 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); } } }
private void lightningDetectorI2C_NoiseDetected(LightningDetectorI2C sender) { Debug.Print("Noise Detected"); }
private void lightningDetectorI2C_LightningDetected(LightningDetectorI2C sender, LightningDetectorI2C.LightningEventArgs e) { Debug.Print("Lightning Detected " + e.Distance + " km away with energy " + e.Energy); }
private void lightningDetectorI2C_DisturbanceDetected(LightningDetectorI2C sender) { Debug.Print("Disturbance Detected"); }