Locking emergency stop button

Hi everyone,

I'm trying to make a plugin that will send M112 and also blink the button's red led when the button is pressed and then when the button is released / reset, have it Reset the printer back to normal and stop the led from blinking. The button is currently wired as Normally Open as well. I forked a starting point from emergency stop simplified which itself is forked from filament sensor simplified. Here is my Repository with my attempt so far. Any help would be appreciated as I don't have much of an idea of what I am doing!