Added idle mode to the delay function

The controller will be sent to idle mode if the remaining delay time allows this. It will be woken up by any interrupt, which will be latest by the timer0 interrupt.