From 61032f181c8f873e441d70e807ada5b4f7df45e9 Mon Sep 17 00:00:00 2001 From: vickash Date: Sun, 25 Aug 2024 01:26:52 -0400 Subject: [PATCH] Call #stop on ultrasonic echo pin before use to avoid lgpio alerts --- lib/denko/sensor/hcsr04.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/denko/sensor/hcsr04.rb b/lib/denko/sensor/hcsr04.rb index 56a5cd4..82c7558 100644 --- a/lib/denko/sensor/hcsr04.rb +++ b/lib/denko/sensor/hcsr04.rb @@ -15,6 +15,9 @@ def initialize_pins(options={}) def after_initialize(options={}) super(options) + # Avoid generating extraneous alerts when used with Denko::PiBoard. + echo.stop + # Receive values from echo pin. echo.add_callback { |data| self.update(data) } end