Skip to content

feat: implement true sleep timer with hardware mute and status icon#337

Open
bostoneboy wants to merge 8 commits into
esp32-si4732:mainfrom
bostoneboy:main
Open

feat: implement true sleep timer with hardware mute and status icon#337
bostoneboy wants to merge 8 commits into
esp32-si4732:mainfrom
bostoneboy:main

Conversation

@bostoneboy
Copy link
Copy Markdown

Overview
This PR introduces a dedicated Sleep Timer feature, allowing users to set a countdown (1-120 minutes) after which the device will automatically stop playback and enter
sleep mode. This is distinct from the existing inactivity-based display sleep.

Key Features

  • True Sleep Logic: When the timer expires, it performs a "long-press" action—turning off the display and triggering a hardware mute (disabling the audio amplifier) to
    ensure zero power consumption and noise.
  • Dynamic Stepping & Wrap-around:
    • 1-minute increments for the first 20 minutes.
    • 5-minute increments from 20 to 120 minutes.
    • Seamless wrap-around logic (e.g., 120 min -> Off -> 1 min) for easier navigation.
  • Intelligent Volume Restoration: Automatically restores the previous volume level upon waking up (soft power-on) if the device was muted by the Sleep Timer, while
    preserving manual mute states.
  • Visual Indicator: Added a "Zz" icon in the status bar (top bar) that appears only when the Sleep Timer is active.
  • Persistence: The Sleep Timer setting is saved to NVS and persists across reboots.

Changes

  • ats-mini.ino: Added timer countdown logic and state management in the main loop.
  • Menu.cpp / Menu.h: Added "Sleep Timer" to the Settings menu with custom encoder handling and UI rendering.
  • Utils.cpp: Enhanced sleepOn() to handle volume restoration using a new sleepTimerMuted flag.
  • Draw.cpp / Draw.h: Implemented and integrated the "Zz" status icon.
  • Storage.cpp: Added persistence for the new timer setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant