I have a Witty Pi 4 and it works flawlessly with my Raspberr Pi Zero 2W.
But I was wondering if there is some way or 'trick' to be able to use the power button on the Witty Pi to indicate/signal, so that there is a sort of flag set that the Raspberry Pi can read to know that it has to perform a special 'factory reset' script.
I tried pressing the power button and holding it, the Raspberry Pi boots up but also shuts down after a few seconds. I was thinking of doing a long press so that it starts up and that I could read the button down state in the Raspberry Pi so it knows that it has to perform a special script/action, in my case a sort of factory reset, by reverting changes in folders. But that long press doesn't seem to work.
Seems that I would need to change the original firmware for this? I would prefer to not introduce additional buttons or wires. Or is there a different way to use the Witty Pi power button to achieve my goal? Perhaps pressing it twice?
I asked ChatGPT also for some solutions, but it comes up with many creative idea's, like scheduling a specific time (e.g. 13:37) so that at that time it will perform a specific routine, but that's all software based. I would really to be able to do it externally by using the Witty Pi button somehow.
Any thoughts on this?
Witty Pi 4's button connects to a pin in the MCU (ATtiny841) and GPIO-4 on Raspberry Pi. To handle the button event, you may either do something on Raspberry Pi side (if Pi is running) or on the firmware side.
If Pi is off, pressing down the button will turn it on, and this is done by the firmware.
If Pi is on, pressing down the button will shut it down, and this is done by the software on Raspberry Pi. After the Pi has been shutdown, the firmware will cut its power.
The "long hold" behavior has been defined in firmware as "force power cut", so you can not redefine it without changing the firmware. Besides, "long hold" equals to "press down the button -> long wait -> release the button", the first part "press down the button" will triger the normal button behavior already.
It will be difficult to get what you want without adding a new button.
Thank you for taking the time to read my question and giving an answer. I was already sort of afraid that I would not be able to solve it via a single button of the Witty Pi.
Looking at how many consumer devices implement a sort of pinhole (factory) reset button functionality, I guess that's the direction to go for me. I will add a separate button to the Raspberry Pi itself that can be pressed and a daemon on the Raspberry will then react on the GPIO button press state and do its job. Or use some custom boot loader (e.g. U-Boot) to be able to detect the GPIO button state before the system boots. Depends if I want to restore only some folders while the system is up and running or completely want to restore a partition. Have to investigate/try that out a bit.