Closed pakozm closed 8 years ago
Thanks - I like the idea. This does pull in the Serial code, but I assume it's not such a big deal.
On balance I would probably not add the flush to Sleepy. Recognising that the power down will upset the flow of pending print operations I still see it as the responsibility of the sketch to handle the prerequisites before powering down. Moving the flush into sleepy passes the accountability and possibly the understanding of actions taken inside the sketch to the library.
Ah, good point - hadn't thought of the indeterminism. I agree - if this is to be added to JeeLib, I would rather see something like this:
void Sleepy::flushAndPowerDown () {
Serial.flush();
powerDown();
}
That way, both the implicit link to serial and the implied delay will be clearer (and optional).
Thanks for your comments. I think it can be changed to introduce a new method as @jcw says, this way the user is acknowledge of the expected behavior. I will change the pull-request.
Thanks, Francisco.
This commit updates Sleepy::powerDown method to check Serial object and forcing a flush before sleeping the MCU. Without flushing, UART communication for debugging is almost impossible.