Set_Led does its magic by accessing a few syscalls. I do not know whether this will work with the OpenSlug kernel. The syscalls are as follows.
The bit arguments referred to above correspond to the information on GPIOConnections. It is not a bitmask, it is the number of the bit to affect.
Some additional comments:
There is a bit of 'magic' going on with some of the commands: The "blinking" commands as well as the "beep2" and "beep3" commands do not return. So to use them in a script and avoid blocking, follow them with an ampersand as in
A subsequent call of "Set_Led ready" will turn the status LED to green and terminate the blinking or beep processes.
Also when the "r_blinking" command is terminated manually while the LED is off, it will stay off. I do not know of a way to achieve this programmatically though.
Lastly the "power_off" command is intended to be used at the end of the shutdown scripts. A proper shutdown that will also call the shutdown scripts can be triggered with the "halt" command.
Because I don't want my HDD to run 24/7, I automatically shut down at night (and restart in the morning using the Always-On-wiring). To be warned before shutdown occurs (save data, cancel shutdown, ...), I added the following lines to my /etc/crontab:
30 22 * * * root Set_Led s_blinking &>/dev/null 00 23 * * * root Set_Led rs_blinking &>/dev/null 00 23 * * * root Set_Led beep1 &>/dev/null 29 23 * * * root Set_Led beep3 &>/dev/null 30 23 * * * root /usr/sbin/DO_Shutdown &>/dev/null
This way, the Ready-LED starts to blink Green/Orange one hour before shutdown. Half an hour before shutdown, the LED starts to blink Green/Red and a beep is triggered. Finally, one minute before shutdown, a triple beep will demand attention. Feel free to use this as a starting point for your own warning mechanism.