restart()
deepSleep()
The restart
function reboots the device.
The deepSleep
schedules the system to enter deep sleep.
getRunlevel()
Example:
function setup() {
// Check if we are running on internal battery
if (getRunlevel() == 2) {
print("Running on battery");
} else {
print("Running on power supply");
}
}
Returns the current system run-level. This can be one of:
Level | Alias | Description |
---|---|---|
0x00 | RUNLEVEL_BOOT | Early boot sequence. |
0x01 | RUNLEVEL_EXT_POWER | The device is externally powered. |
0x02 | RUNLEVEL_BAT_POWER | The device is powered by the internal battery. |
0xFE | RUNLEVEL_RESTART | Restart system. |
0xFF | RUNLEVEL_SHUTDOWN | Shut down system (eg. deep sleep) |
setRunlevel(level)
Example:
function restart() {
// Switch system to restart runlevel
setRunlevel(0xfe);
}
This function changes the system runlevel to the given number. This function is intended to be used in cases where you have implemented custom run-levels that you want to use.