|
|
Re: Inverted IO in SysFs [message #1725262 is a reply to message #1725062] |
Wed, 02 March 2016 08:19 |
Jose Maria Jesus Cabral Lassalle Messages: 199 Registered: February 2016 |
Senior Member |
|
|
You are right. As you say, in some cases a pull-up is already configured in the hardware or is better for the design, and a "true" for a pressed button will be seen as a 0.
But without any specific configuration it seems to me that it's more intuitive that a "false" represents a "0" and also low voltage (0 normally) in the pin (whether it's output or input) and a "true" represents a "1" and a high voltage (5 normally) in the pin.
Now, like you said, sometimes it would be nice to have the option of inverting this convention (making actually the program lighter, since instead of an additional NOT block, the QX/IX would take care of that). I think that a good convention for that would be to represent the inversion with a negative value. So if the gpio 50 must be inverted, the PARAM would be actually -50. That way, when the FB parse the PARAM in the INIT event, it could convert it to a signed integer, and in case it's < 0, the active_low file would be set to true.
|
|
|
Powered by
FUDForum. Page generated in 0.01817 seconds