kantlivelong / OctoPrint-PSUControl

Smart control of your power supply via GPIO, GCODE Command, System Command, or variety of sub-plugins.
GNU Affero General Public License v3.0
203 stars 113 forks source link

Allow same GPIO for switching and sensing #223

Open xaver-k opened 3 years ago

xaver-k commented 3 years ago

What does this PR do and why is it necessary?

The changes allow to re-use the switching GPIO for sensing the current on/off state. This addresses #182.

How was it tested? How can it be tested by the reviewer?

Tested on my personal setup, which uses a Raspberry 4 and pulls GPIO 2 to GND for switching the printer on: circuit drawio

Further testing on other setups is needed, but I only have the one printer.

What are the relevant tickets if any?

182

Further notes

kantlivelong commented 3 years ago

RE: Refactoring, could you provide more detail in a separate ticket? Code definitely needs some general refactoring(format, make more use of constants, simplification, etc..) but not sure where your going with splitting things.