-
Notifications
You must be signed in to change notification settings - Fork 50
Description
Currently running (sleep-deep 0) makes us enter deep sleep, without setting a wakeup timer. So it's the same as setting the time argument to a negative argument. The documentation (see below) says that setting time to a negative value makes us go to sleep forever.
The current documentation (from https://github.com/vedderb/bldc/blob/master/lispBM/README.md#sleep-deep):
(sleep-deep time)Put the CPU in deep sleep mode for time seconds. If time is negative the CPU will sleep forever, or until a wakeup pin triggers a wakeup. Waking up from sleep-deep results in a complete reset.
While this behavior can be argued to not strictly contradict the documentation it is still unexpected (to me at least), and I'd suggest we change it. In any case, the documentation should be updated to better describe this edge case.
I will suggest two ways we can modify sleep-deep's API which I think would improve things. We can of course go for another solution if we think that is better.
Suggenstion 1
Make it so that setting time to nil disables the wakeup timer. We would probably still need to keep the option to pass -1 for backwards compatibility, but we can push that to a small note in the documentation.
Then we explicitly define setting it to 0 as retarting the device.
Suggestion 2
Still change the behavior with allowing nil to be passed to time, but we make passing 0 less well defined, but instead add another extension which restarts us, perhaps called reboot?