Menu

#158 Allow to pass -1 as a GPIO number (dummy GPIO)

New
None
Medium
Enhancement
2018-02-09
2018-02-09
Arsenijs
No

Hi! Many libraries are using RPi.GPIO, and in some cases it's desirable to override the behaviour of these libraries. For example, a display library might require to have a RESET pin of a display connected, even though it's technically not necessary (say, the display uses an autoreset function), and a sensor library might require an INT pin for a sensor, even though the sensor is perfectly capable of working when being polled. While RPi.GPIO is not responsible for other people's mistakes, bad judgement or laziness, I think it would be great to give us, developers, an ability to override the code by supplying something like '-1' (a number).

In my vision, a '-1' GPIO would behave like a mock GPIO, with .output() and similar calls acting as if everything was done successfully, and input() calls returning a defined value - say, 0 (maybe, 0 for '-1' and 1 for a '-2' GPIO, for versatility). To avoid confusion from users that might accidentally use -1, I think it's best to raise a warning when such a GPIO is set up.

I'd send you a patch, but SourceForge is confusing for me, sorry. Hope you understand my idea and its usecases!

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.