Skip to content

Consider warning or documenting deepSleep(0, false) behavior #285

Description

@rorihoi

Summary

When M5.Power.deepSleep() is called with micro_seconds == 0 and touch_wakeup == false, the device can enter deep sleep without any wakeup source configured and may never wake up unless externally reset.

Current Behavior

Example:

int sleepSec = SleepTimeSec - execTimeSec;

M5.Power.deepSleep(
sleepSec * 1000ULL * 1000ULL,
false
);

If sleepSec unexpectedly becomes 0, the device enters permanent deep sleep. This can be difficult to distinguish from a system freeze.

Suggestion

Consider one of the following:

  • Return an error when micro_seconds == 0 and no wakeup source is configured.
  • Output a warning log before entering deep sleep.
  • Document this behavior in the API reference.

Additional Information

In my case, a calculated sleep duration unexpectedly became 0, causing the device to enter deep sleep without any wakeup source. It took considerable time to diagnose because the symptoms were similar to a system freeze.
This may be intended behavior, but a warning or documentation note could help developers avoid accidental permanent deep-sleep situations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions