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

Luacontrollers don’t report input state reliably on bidirectional pins #558

Open
Hawk777 opened this issue Mar 23, 2021 · 2 comments
Open
Labels

Comments

@Hawk777
Copy link
Contributor

Hawk777 commented Mar 23, 2021

Mesecons wires act like wired-OR systems when there are multiple drivers (“receptors”) attached to a single wire—the wire is powered if any of the levers/buttons/etc. connected to it are active.

In the Luacontroller world, using a pin exclusively as an output works fine (with the port table), and using it exclusively as an input also works fine (with the pin table). But multiple-driver configurations do not work properly. For example, build a wire connected to a lever and a Luacontroller I/O pin, then do the following sequence of steps:

  1. Set the port value high (port.a = true).
  2. Flip the lever to the ON state.
  3. Set the port value low (port.a = false).
  4. Print the pin value (print(pin.a)).

The value printed is false, despite the lever being on! Even changing the state of other inputs does not have any effect—the input only reads as high once the lever is turned off and on again.

This is not just about events not firing. In fact, even if an event is provoked by some other cause (such as a program event, or even another input pin!), the pin table still shows false for the active input.

@sfan5
Copy link
Member

sfan5 commented Mar 23, 2021

I believe this limitation is fully intentional.

@Hawk777
Copy link
Contributor Author

Hawk777 commented Mar 23, 2021

I know that not generating change events when outputs change is intentional (there’s a bunch of code to squelch those), but even having the pin array read totally wrong values? That seems weird—on any real-world microcontroller I’ve used, you can still read a pin as input when it’s operating in any kind of output mode for which reading input makes sense (e.g. open-drain mode) and get back an accurate value.

@numberZero numberZero added the bug label Mar 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants