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

feat: option to automatically power off radio after inactivity #3414

Merged
merged 12 commits into from
Aug 28, 2024

Conversation

pault4r
Copy link
Contributor

@pault4r pault4r commented Mar 29, 2023

An implementation of feature request #789 for the TX16S (see also opentx issue #6421). [Note - now expanded to all radios with power buttons, see below]

Radio will automatically shutdown after a configurable number of minutes of inactivity. Option is shown on the main "Radio Setup" screen with zero minutes used to disable the feature. Shutdown will not take place if telemetry is present or if the radio is connected via USB.

I like this as it is on my radio but it might need a little more thought and development if you guys have any interest in pulling this into your repo for general use. Happy to look at it further if that is the case.

Paul

@Eldenroot
Copy link
Contributor

Maybe add on/off and then a configurable timer?

@pault4r
Copy link
Contributor Author

pault4r commented Mar 29, 2023

Yes I agree the user interface would be better with with an on/off switch first and then the timer shown only if the feature is switched on, rather than just using 0 for "off".

It would also be better if the option were next to the "Inactivity Alarm" setting, but that is currently under "Alarms" so not the logical place to look for a shutdown function.

@pault4r
Copy link
Contributor Author

pault4r commented Apr 3, 2023

Hi @elecpower - have added some support in companion for this setting.

The Windows-64 companion build workflow seems to have an issue around generate_datacopy.py / datacopy.inc but I don't think that's related to these changes....

@elecpower elecpower added enhancement ✨ New feature or request color Related generally to color LCD radios companion Related to the companion software and removed needs: companion labels Apr 4, 2023
@Eldenroot
Copy link
Contributor

Is ON/OFF check box added instead of minutes?

@pault4r
Copy link
Contributor Author

pault4r commented Apr 17, 2023

Hi @Eldenroot,

I guess we would need an ON/OFF checkbox and then the number of minutes if ON.

It's not in the code now, if you are interested I can try it that way and see how it looks then. Will get back to you on that.

If using a toggle, one question would then be why the inactivity alarm does not work in the same way (i.e. also have an ON/OFF toggle) as they are very similar functions. It could also be done that way of course.

Perhaps I should rebase this now as well as there seem to be some conflicts.

So I don't know if this feature is on any road map or has sufficient interest to be included, I just know that I find it useful (and regularly use it) and it has been requested at least once in the past. But of course that might not be enough, maybe most people do manage to switch their transmitters off :-). For me the TX16S just somehow looks like it's off most of the when the LCD is off. I've left it on a few times and moved away from it, not hearing the inactivity alarm, and I'd actually rather not have to manually switch it off a lot of the time when it can just do that itself.

Paul

@pfeerick
Copy link
Member

pfeerick commented Apr 17, 2023

Interest, definitely. And will probably be something to be included 2.10. Will just want to expand it to all radios, not just the TX16S. I wouldn't worry about rebasing it for a week or so (unless you want to), as I think there are some more PRs to go that will most likely cause minor conflicts (because they'll also be touching datastructs to save their own options). As far as a checkbox that controls the edit field, that makes sense, and for sure the inactivity timer could be done the same way (for consistency).

@pault4r
Copy link
Contributor Author

pault4r commented Apr 18, 2023

Hi Peter,

Ah OK, sounds good :-). I will update it in in a few days then and include the checkbox. Applying to all radios with a push button switch seems like an excellent idea. I only have the TX16S to test myself hence tried not to change anything else. However, it's pretty simple and should only need a few checks on other radios to get this right.

Paul

@JimB40
Copy link
Collaborator

JimB40 commented Apr 19, 2023

I assume this is to prevent draining radio's battery (particulary LiPo that can be destroyed once below 3.0V)
So good feature would be to have this feature based on tx voltage.
In this case no telemetry present checkig then as radio will start malfunction anyway below certain TX batt voltage.

@pfeerick
Copy link
Member

pfeerick commented Apr 19, 2023

That will add some complexity to an otherwise simple feature, but is something that should be considered as there is time to flesh this out. At present it is linked to transmitter inactivity - i.e. if idle for more than x time, and no telemetry, it's safe to turn off (if configured to do so). If it was linked to voltage, I would probably want a "battery critical" option in addition to the "battery low" audio/haptic warning we currently have (and must be set lower), so you get the nags about the battery voltage for a while before it would be allowed to also optionally shut off on a critical voltage level.

i.e. I would expect something like the following (note I would allow critical voltage to trigger poweroff in the case of USB as you don't usually fly with USB connected - and if you do !? - don't turn the option on).

if no telemetry and no usb active, then:
  if idle for more than x (and idle auto power off enabled), then:
    auto power off

if no telemetry:
  if battery at critical level (and battery auto power off enabled), then:
    auto power off

@JimB40
Copy link
Collaborator

JimB40 commented Apr 19, 2023

That's what I thought of. Killed radio lipo lastly. Finished dev late and forgot to switch off tx16s while volume was down not to disturb me while in dev mode :)

@pfeerick
Copy link
Member

Yeah, for dev work, unless you're on the move, running from battery is not a good idea. Better to have a power supply and then it doesn't matter how long you leave it turned on for 😆

@pault4r
Copy link
Contributor Author

pault4r commented Apr 19, 2023

Agree that battery voltage related options are possible enhancements here.

Wanting this to happen based on battery voltage and wanting it to happen based on time are two different things though which would suit different people or different usage scenarios.

Personally I like to use a prompt time-based shutdown to save as much power as possible (say after max 10 mins of inactivity). If I'm out flying I usually leave the TX on after a flight (waiting for others to fly perhaps) but of course without any models powered. Then if I don't get back to flying promptly or am talking to someone else or whatever, I just prefer it to take care of itself. And, yes I have left it on whilst working on things at home as well just by mistake! Luckily never taken it out to the field flat though....

@gagarinlg gagarinlg added this to the 2.10 milestone May 6, 2023
@pault4r
Copy link
Contributor Author

pault4r commented Jul 15, 2023

Have rebased the code here since it was 900 odd commits behind with some conflicts. Still the same tx16s specific patch in this commit. The padding in the yaml generation is not quite right in this version though. To be corrected shortly.

@3djc
Copy link
Collaborator

3djc commented Jul 15, 2023

Just a thought reading this, should trainer not be checked too ? (Can't remember if traîner affect inactivity timer)

@pault4r
Copy link
Contributor Author

pault4r commented Jul 16, 2023

@3djc, good point regarding the trainer, I will have a look at that....

@pault4r
Copy link
Contributor Author

pault4r commented Jul 16, 2023

Latest commit expands to all radios as mentioned by @pfeerick above.

Still the simplest interface here, 0-255 mins shown. Main lack of clarity being what 0 means. Just replacing the 0 with "off" is one way to improve but many options with a GUI as always.

@raphaelcoeffic
Copy link
Member

@pault4r sorry for being late to the party: how does this interact with the regular inactivity timer?

@raphaelcoeffic raphaelcoeffic marked this pull request as draft August 12, 2023 05:46
@raphaelcoeffic raphaelcoeffic added the needs: rebase A git rebase on top of the latest destination branch version is required label Aug 12, 2023
@pault4r
Copy link
Contributor Author

pault4r commented Aug 12, 2023

Hi @raphaelcoeffic, it is based on the regular inactivity timer (read only - no adjustment made to the timer).

The user could have the inactivity alarm first and then automatic power off some time after that by using both features. Or have a silent power off.

There are additional checks beyond the inactivity timer but the timer is the main thing.

@pault4r
Copy link
Contributor Author

pault4r commented Dec 21, 2023

This is the same change as before, just rebased and with the commits organized in a clearer way

@pfeerick pfeerick self-requested a review May 16, 2024 09:58
@pfeerick pfeerick removed the needs: rebase A git rebase on top of the latest destination branch version is required label Jul 29, 2024
@pfeerick pfeerick changed the title Option to automatically power off radio after inactivity feat: option to automatically power off radio after inactivity Jul 29, 2024
@pfeerick pfeerick added rn: feature Feature to be highlighted in release notes and removed color Related generally to color LCD radios companion Related to the companion software labels Jul 29, 2024
@pfeerick pfeerick changed the title feat: option to automatically power off radio after inactivity feat(radio): option to automatically power off after inactivity Aug 2, 2024
@pfeerick pfeerick changed the title feat(radio): option to automatically power off after inactivity feat: option to automatically power off radio after inactivity Aug 2, 2024
pault4r and others added 12 commits August 27, 2024 04:48
power off radio after inactivity. String is added in English in
translation files as a placeholder.

Merge branch 'main_poweroff_2' into rebase_6
set the number of minutes of inactivity before an automatic power
off. A value of zero will disable the feature.
will control the inactivity based automatic power off.
These are the c++ changes, changes to the .ui file will be committed
separatly as the .ui file has a greater potential for conflicts.
@pfeerick pfeerick added the user manual change Will impact on the user manual in some respect label Aug 28, 2024
@pfeerick
Copy link
Member

This has been working well for some time now on TX16S, T12MAX and X9D+2019.

Some future improvements could be (mostly UI):

  • probably only for colorlcd - use a toggle switch to turn on, and then display textedit field for value
  • show a full screen alert when one minute remains before power off, with a new voice prompt, and haptic. Which has a countdown timer. I think it should clear itself as soon as the system is no longer inactive, thus at most perhaps a cancel button, linked to RTN, could be shown, as in the process of hitting an accept/ok button, it would clear it self 🤭
  • discussion points could be on whether the warning prompt should be configurable - both as to whether it appears or not, and when it should appear
  • once there is an advance warning prompt, I could see room for also adding an optional low battery voltage poweroff trigger also, also with toggle switch and number edit field - for specifying the shutdown voltage - which would probably have it's max warning voltage capped to below that of the low battery alarm value.

@pfeerick pfeerick merged commit af9ba9c into EdgeTX:main Aug 28, 2024
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request rn: feature Feature to be highlighted in release notes user manual change Will impact on the user manual in some respect
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants