Skip to content

Suspend/resume power management (B13) #4

@Ashex

Description

@Ashex

Context

sKeets has no power management. The device stays fully awake while the app runs, draining the battery. The src/platform/power.cpp infrastructure probes battery state and suspend safety, but no actual suspend action is triggered. Power button press during bootstrap just exits the app.

KOReader's suspend/resume state machine was analyzed in docs/koreader-cross-reference.md as reference.

Sub-tasks

  • Detect inactivity timeout (e.g. 5 minutes with no touch/key input) → blank screen
  • On inactivity timeout or power button short-press: tear down Wi-Fi, turn off frontlight, write mem to /sys/power/state for suspend-to-RAM
  • Handle wake from suspend: restore Wi-Fi, restore frontlight, resume event loop
  • Gate suspend safety: skip suspend if MTK device is charging (known kernel crash per KOReader reference)
  • Write 1 to /sys/power/state-extended before suspend, 0 after resume (per KOReader pattern)
  • Add unexpected wakeup guard: if wakeup was not user-initiated, re-suspend (with a max retry count)
  • Handle sleep cover events (SleepCoverClosed → suspend, SleepCoverOpened → resume) if hardware supports it

References

  • KOReader suspend sequence: device/kobo/device.lua (~L1330)
  • Existing infra: src/platform/power.h/cpp (probes battery, charging, standby capability)
  • MTK crash workaround: KOReader explicitly skips suspend/standby if isMTK() and isCharging()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions