Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic shutdown on idle #1647

Open
wants to merge 35 commits into
base: dev
Choose a base branch
from

Conversation

SHxKenzuto
Copy link

@SHxKenzuto SHxKenzuto commented Aug 23, 2022

What's new

  • Added an option under [Settings->Power] that allows Flipper to be automatically turned off after a certain amount of time has passed without input from user ( the options are 15min, 30min, 1h, 2h, 6h, 12h, 24h, 48h).

Verification

  • A submenu named [Shutdown on Idle] has been added under [Settings->Power]. Under that submenu is possible to set how long Flipper will be idle before shutting off on his own and to turn off this feature.

Checklist (For Reviewer)

  • PR has description of feature/bug or link to Confluence/Jira task
  • Description contains actions to verify feature/bugfix
  • I've built this code, uploaded it to the device and verified feature/bugfix

Copy link
Member

@hedger hedger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please format code with clang-format

@SHxKenzuto SHxKenzuto requested a review from hedger August 23, 2022 21:34
hedger
hedger previously approved these changes Aug 23, 2022
Copy link
Member

@hedger hedger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but introducing a new file in /int will take up at least 4Kb of internal storage - and we're running short on it for debug builds.
We'll discuss this feature internally and may merge it after releasing v.0.65.

@hedger hedger added UI Affects UI New Feature Contains an IMPLEMENTATION of a new feature Core+Services HAL, furi & core system services labels Aug 23, 2022
@digitalcircuit
Copy link
Contributor

@hedger

Looks good to me, but introducing a new file in /int will take up at least 4Kb of internal storage - and we're running short on it for debug builds. We'll discuss this feature internally and may merge it after releasing v.0.65.

Good to know this. I've been looking at adding a setting to the Power application for optionally limiting the battery charging voltage, and that would've required creating a new /int file as well.

If this idle shutdown PR gets merged, I can base my battery charge limit configuration efforts atop this so there will be two settings stored in /int/.power.settings, not just one. That might make the 4 Kb minimum filesystem cost more palatable?

@azaitsev
Copy link

azaitsev commented Sep 7, 2022

Hi flipper team, how about to merge this? We are at 0.66 already.

@skotopes
Copy link
Member

skotopes commented Sep 7, 2022

Hi @azaitsev, will be included in next release. Sorry for delay.

@skotopes
Copy link
Member

@SHxKenzuto May I ask you to merge dev?

@SHxKenzuto
Copy link
Author

@SHxKenzuto May I ask you to merge dev?

Ok, doing it right now

@SHxKenzuto
Copy link
Author

@skotopes merge completed

@skotopes
Copy link
Member

Thanks. This RC is already packed with more features than our QA can test, so I'll merge it after this release.

@SHxKenzuto SHxKenzuto marked this pull request as ready for review December 19, 2022 00:34
@digitalcircuit
Copy link
Contributor

digitalcircuit commented Dec 22, 2022

I've built from the most recent set of commits (2022-12-18) and tested it. Overall, this is a nice feature!

Testing - ⚠️ potential issues

This pull request functions as is. However, there are two changes I'd recommend making, noted in tests B and F.

Setup

  1. Compile and install firmware
  2. Set SettingsPowerShutdown on IdleSet Time to 15min
  3. Return to desktop
  4. Unplug Flipper from USB connection

A: Unplugged, auto-shutoff at desktop when idle - ✅ pass

  1. Make sure the Flipper desktop is showing
  2. Wait 15 or so minutes
  3. Ensure the Flipper has powered off

B: Plugged in, auto-shutoff at desktop when idle - ⚠️ potential issues

  1. Plug Flipper into USB charger and/or computer
  2. Make sure the Flipper desktop is showing
  3. Wait 15 or so minutes
  4. Ensure the Flipper remains turned on
  5. Unplug the Flipper from the USB charger
  6. Ensure the Flipper remains turned on
  7. Wait 15 or so minutes
  8. Ensure the Flipper has powered off

Current situation

The Flipper will immediately shut off without warning when unplugged from USB.

While this could be intentional, it feels unintuitive to me.

ℹ Recommended changes

  • When connected to USB power, pause the auto-shutdown timer
  • When disconnected from USB power, re-enable and reset the auto-shutdown timer if it is configured
    • This needs to avoid conflicting with the app launch/quit event handling so if either an app is open or USB is connected it won't auto-shutdown
    • Consider how charging is inhibited for the battery charging chip - every request to pause increments a counter, request to resume decrements it, and only when the counter is at zero does charging turn back on
    • Test: plug into USB, launch an app, then unplug USB - auto-shutdown should still be paused

This might mimic the app launch/quit event handling.

C: Remains on in internal app - ✅ pass

  1. Open SubGhz app
  2. Wait 15 or so minutes
  3. Ensure the Flipper remains turned on

D: Remains on in external app - ✅ pass

  1. Navigate to PluginsTools and launch Weather Station
  2. Wait 15 or so minutes
  3. Ensure the Flipper remains turned on

E: Unlocked, auto-shutoff timer reset on desktop key press - ✅ pass

  1. Make sure auto-lock is disabled
  2. Navigate to the Flipper desktop
  3. Wait 10 minutes
  4. Press the Back button once
  5. Wait 10 more minutes
  6. Ensure the Flipper remains on
  7. Wait 5 more minutes (15 total minutes since last button press)
  8. Ensure the Flipper has powered off

F: Locked, must unlock to reset auto-shutoff timer - ❌ fail

  1. Navigate to the Flipper desktop
  2. Lock the Flipper with Up button, Lock (or use auto-lock)
  3. Wait 10 minutes
  4. Press the Back button only once, do not unlock the Flipper
  5. Wait 5 more minutes (15 total minutes since last Flipper unlock)
  6. Ensure the Flipper has powered off
    • Currently, the Flipper remains on at this point
  7. Power on the Flipper by holding the Back button
  8. Lock the Flipper with Up button, Lock (or use auto-lock)
  9. Wait 10 minutes
  10. Press the Back button three times to unlock the Flipper
  11. Wait 10 more minutes
  12. Ensure the Flipper remains powered on
  13. Wait 5 more minutes (15 total minutes since last Flipper unlock)
  14. Ensure the Flipper has powered off

Current situation

The Flipper will not shut off at step 6 (after pressing Back once without actually unlocking the Flipper).

ℹ Recommended changes

Don't reset the idle shutdown timer via key events when the desktop is locked.

  • When handling key events, check if the desktop is locked and ignore the event if so
  • Listen for the unlock event and reset the idle shutdown timer at that point

This ensures the Flipper will auto-shutdown even if in a backpack or such with occasional button presses.

@skotopes
Copy link
Member

skotopes commented Feb 9, 2023

We'll include this PR in next release(0.78).

@skotopes
Copy link
Member

I need more time with this code, moving to next release.

@Ethanol0001
Copy link
Contributor

I think the next priority it making sure the butthurt_max xp system works off of what the clock app runs off of. Ive had issues with the butthurt_max xp not resetting properly if you turn off the flipper fully instead of locking it. If we do that, it would make this feature much more favorable in terms of preserving power by shutting it off after some time.

@Ethanol0001
Copy link
Contributor

Otherwise I think this option in the settings to auto-shutoff would be very useful if the butthurt thing resets when the battery isnt under regular load

@digitalcircuit
Copy link
Contributor

Considering the recent success of a deeper power-saving mode for the Flipper for 1 month of idle time, I think the selectable auto-shutdown delays could be adjusted.

Instead of… {"OFF", "15min", "30min", "1h", "2h", "6h", "12h", "24h", "48h"}

Perhaps… {"OFF", "1h", "2h", "6h", "12h", "24h", "48h", "1wk", "2wk"}, or similar.

Alternatively, if auto-off is no longer desired, I'd still like to make use of the Power app's settings code to add the configurable battery charge voltage limit - which with longer idle time reduces the risk of someone overdischarging.

@digitalcircuit
Copy link
Contributor

Seeing the recent dev merge commits, I'm happy to help with retesting or other things to get this refined and merged.

I'm still both interested in auto-shutdown (especially if increasing the upper bound, so the Flipper shuts off after a week of not interacting with it), and in the Power application having a settings file (to build charge voltage limit settings on top of).

@skotopes
Copy link
Member

skotopes commented Sep 8, 2023

@digitalcircuit I'm currently refactoring power service, I'll update this PR and then merge it.

@skotopes skotopes requested a review from gsurkov as a code owner June 11, 2024 15:32
@skorokithakis
Copy link

Could this please be merged? Currently I'm finding myself in the fairly risky situation of forgetting to use my Flipper for a while and finding my battery depleted, which lithium batteries don't like. This would ensure that an idle flipper wouldn't be at risk of killing its battery.

@skotopes
Copy link
Member

skotopes commented Jun 13, 2024

Could this please be merged? Currently I'm finding myself in the fairly risky situation of forgetting to use my Flipper for a while and finding my battery depleted, which lithium batteries don't like. This would ensure that an idle flipper wouldn't be at risk of killing its battery.

Flipper will shut down itself when battery reaches 3.3V also there is a second battery protection circuit that will disconnect battery from the flipper when battery depleted below ~2.8V. Chances of killing battery is completely discharging it are quite small.

Anyway, I hear you. This PR was in a limbo for a long time, I'll allocate time to refactor power service and merge this PR in next release.

@skorokithakis
Copy link

Thanks, it's good to know my Flipper won't die! Still, it would be nice to leave it semi-charged and know I can pick it up and use it months later, without needing a charge.

@digitalcircuit
Copy link
Contributor

digitalcircuit commented Jun 14, 2024

I am still interested in the Power app gaining support for persistent settings, too - I haven't forgotten about the charge limiting feature that doesn't (yet!) have a GUI to control it.

Thank you for not giving up on this, and definitely understood on having had other priorities.

EDIT: Details on charge voltage limiting here: #1158 (comment)

@skorokithakis
Copy link

@digitalcircuit there's charge limiting? How do I enable it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core+Services HAL, furi & core system services New Feature Contains an IMPLEMENTATION of a new feature UI Affects UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants