When I use Raspian, I setup a hardware button to shutdown the PI. Often much easier to press that button than to ssh in…
Is this possible today (or in the next rev of the os)? Preferably this has
Some led feedback that shutdown is started/complete
Config of the pins used
Config of the “gesture”/how long to hold button to shutdown (prevent accidental shutdowns)
Some method to restart instead of shutdown (bonus)
Bonus points for a poor mans UPS with orderly shutdown upon loss of AC. Assuming one of the CV in’s could be used to implement this easily? General idea is that you pull the USB power and a battery kicks in briefly while a shutdown begins immediately upon sensing the change in power source (or other timing).
Alternately, provide some software method for preventing SD corruption (readonly?) that i reversible without a reboot. General idea is a power-safe mode that you can turn on/off with a command. This sounds simple, but I suspect in practice this is hard.
Next release with SENSEI it will be pretty easy to implement this. You’ll just need to configure the HW pins used by SENSEI (both for button input and LED output), write a small program that listens to OSC events generated by the button, wrap it in a systemd service and call poweroff from there.
That’s something we can indeed prepare on our side and include in the release, although it won’t be activated by default.
If you want to do something similar right now, there are few PINs on the Raspberry pinout that are exposed directly on the Elk Pi board header. If you only need just a single pin input, you can use BCM 17, available using the sysfs GPIO interface in /sys/class/gpio/gpio17.
There are two small LEDs on the board that are accessible through the same sysfs interface that you can use right now. They are available through BCM pins n. 12 and 26. Just follow one of the many guides available on the web to access them, for example this one
This is something that we did for other products but it’s pretty hard on the Pi. After detection of shutdown, you need to inform promptly the system and take action in the amount of time given by the battery or big capacitor.
This is our suggested approach. The next release will have the main filesystem mounted in read-only, so you can pretty much turn it off at any time without fear of corrupting the SD card.
There will still be a R/W partition for user data, corruption could happen there but it’s your responsibility to write data in that partition knowing the limitations.