WIP - Power Loss Recovery

I recently klipperized my Prusa MK3S+, and have been missing the power loss recovery feature it had in the original firmware. I have some ideas on how to implement a basic form of power panic, where it would use the power panic pin as a button with some emergency GCode. Does anyone know what pin the power panic cable is plugged into on the MK3 and how I could link that to a button?
Any help would be appreciated.

I found some information on the Einsy Rambo at Einsy-Rambo/board/Project Outputs/Schematic Prints_Einsy Rambo_1.1a.PDF at 1.1a · ultimachine/Einsy-Rambo · GitHub

It looks like the power panic is at PF4. Does anybody know if it is pulled high or low? I don’t know how to read schematics well, so any help would be appreciatd.

I was able to find information on the pin, and am working on Klipper Macros + Python to add power panic support. I will post it here when I am finished.

Quick update: I am working on a different method of power loss recovery:

  1. A post-processing script will take the type annotations by the slicer e.g. ;TYPE: Perimeter, and turn those into numbered marks with a custom G-Code to save those to a file
  2. While printing, the bed temperature will be saved to the same file
  3. In the event of a power outage, the printhead moves up to protect the print
  4. When the power is restored, the heatbed automatically heats to the temperature saved earlier
  5. A gcode_shell_command will invoke a Python script to slice the G-Code properly at the last mark, and to insert a SET_KINEMATIC_POSITION Z= to set the Z position at pause
  6. A home XY will follow, then the print will resume

I think this approach is a decent middleground between saving every layer and saving every line of G-Code. Another thing to note is that approach requires a change in the Start G-Code of the slicer adding some sort of indicator comment where needed. Also, this approach would negate the need for an actual power panic, so any printer could use this. I am still working on this and will post code and macros when finished.