In an Octoprint GCODE script, is there a way to read a Raspberry Pi GPIO pin and do something based on it's state? For example, if GPIO pin 23 is 1, I want to execute a certain GCODE command. I need to do this in an Octoprint script (because I can safely send GCODE commands from there), not an external python program (I can't safely send GCODE commands from an external program because Octoprint already has the serial port open). Here's pseudo code of what I want in my Octoprint script:
gcode command
gcode command
if GPIO pin 23 is 1
send gcode command
end
gcode command
gcode command
etc
I can do conditional stuff (if, for, etc) thanks to the Jinja2 engine, but I'm stumped on how to get the value of a GPIO pin.