Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ButtonBase.IsPressed not properly initialized #2328

Open
RevZero opened this issue Jun 26, 2024 · 1 comment
Open

ButtonBase.IsPressed not properly initialized #2328

RevZero opened this issue Jun 26, 2024 · 1 comment
Assignees
Labels
bug Something isn't working Priority:3 Work that is nice to have up-for-grabs Good issue for external contributors to iot

Comments

@RevZero
Copy link

RevZero commented Jun 26, 2024

Describe the bug

After initializing a GpioButton, the IsPressed property is always false, even if the logical state (depending on active low/high configuration) of the pin is true.

Steps to reproduce
This examples assumes pin 16 being externally pulled up, having a switch connected which is currently pulling the input low.

var gpio = new GpioController(PinNumberingScheme.Logical, new RaspberryPi3Driver());
var input = new GpioButton(16, true, false, gpio, false);
Assert.That(input.IsPressed); // This fails but IsPressed should be true, because the input is low active and being pulled down.
var pin = gpio.OpenPin(16, PinMode.InputPullUp);
Assert.That(pin.Read() == PinValue.Low); // Passes as expected
input.IsPressed = pin.Read() == PinValue.Low;  // Manually set the initial state as a workaround.

Expected behavior
IsPressed should be initialized according to the initial pin state instead after the first transition.

Versions used

  • net8.0 self-contained
  • Version of System.Device.Gpio package: 3.1.0
@RevZero RevZero added the bug Something isn't working label Jun 26, 2024
@krwq krwq added Priority:3 Work that is nice to have up-for-grabs Good issue for external contributors to iot and removed untriaged labels Jun 27, 2024
@krwq
Copy link
Member

krwq commented Jun 27, 2024

[Triage] @RevZero can you try with both LibGpiodDriver, SysFsDriver and RaspberryPi3Driver directly and see if that makes any difference? If you haven't done yet please make sure you have installed libgpiod (with i.e. apt)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Priority:3 Work that is nice to have up-for-grabs Good issue for external contributors to iot
Projects
None yet
Development

No branches or pull requests

3 participants