Pinoccio/library-pinoccio — pull request #127 by matthijskooijman (2014-05-13 20:19:55+00:00)
Title: Initial sleep (hibernate) support

Pullrequest to track progress.

Initial support is working call the `power.hibernate` function to make the scout drop off the grid and do maximum powersaving for a specified amount of time (in milliseconds). Can optionally take a callback function to call after the hibernate completes. e.g.

function foo {led.on; power.hibernate(4000, "bar"); };
function bar {led.off; power.hibernate(4000, "foo"); };

To toggle the led every 4 seconds, while sleeping in between.

Hibernate shouldn't be used for very short amounts of time. It currently rounds to multiples of around 31ms, so you should probably hibernate for at least 100ms for it to be really effective.