• Status Closed
  • Percent Complete
  • Task Type Patches
  • Category Configuration
  • Assigned To No-one
  • Operating System All players
  • Severity Low
  • Priority Very Low
  • Reported Version Release 3.4
  • Due in Version Undecided
  • Due Date Undecided
  • Votes
  • Private
Attached to Project: Rockbox
Opened by nickp - 2009-11-13
Last edited by nls - 2009-12-13

FS#10779 - Permanent Sleep Timer Option

Permanent Sleep Timer Option.

This patch adds an additional option “Permanent Sleep Timer” under System→Time & Date (or System if CONFIG_RTC isn’t set).

When set, it immediately sets the sleep timer with the given number of minutes and writes a configuration option “permasleep timer: {mins}”.

On startup, if this configuration option is detected, it sets the sleep timer to this value.

If the value is set to “Off” the sleep timer is immediately reset and the config setting disappears.

Normal volatile timer settings can be initiated using the existing Sleep Timer option.

While it might have been better if I’d reworked the existing sleep timer, I’m very much a novice C coder, so thought it would be better to err on the side of caution and modify as little code as possible.

Tested on a Cowon D2.

Closed by  nls
2009-12-13 09:42
Reason for closing:  Out of Date
Additional comments about closing:   Warning: Undefined array key "typography" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 371 Warning: Undefined array key "camelcase" in /home/rockbox/flyspray/plugins/dokuwiki/inc/parserutils.php on line 407

requsted to be closed by the poster, superceded by fs#10849

so is this patch similar to what fs# 8630 did? I was all in favour of getting that committed.

also, does your patch simply create a default value in the config file for the sleep timer, or does it actually start the sleep timer each time you turn your player on? that wasn’t very clear from the task description.

nickp commented on 2009-11-14 00:02

The differences between this and patch #8630;
- This is a new menu entry, no changes have been made to the existing Sleep Timer option (setting it will be a one-off and be forgotten on restart).
- If you set a value in the new Permanent Sleep Timer option, a value gets written to the config file and the sleep timer starts there and then. It will then start the sleep timer to the config file value each time you turn the player on, until you go back into Permanent Sleep Timer and switch it off.

Initially I made these changes for myself, it was a feature I needed and was a coding exercise as much anything else, I didn’t expect it to work. If anyone has suggestions how they’d like the implementation changed, I’d be more than happy to have a go.

The main feature I wanted was that I could start the player up and have it automatically be in sleep timer mode.

While I remember: I didn’t mean to select “Reported Version - Release 3.4”, this is actually a patch to the (current as then) SVN revision 23621.

nickp commented on 2009-11-14 00:24

Another reason I made this a new menu option: I current use patch FS#10754 (Amend Sleep Timeout to Pause Timeout) and didn’t want to cause any conflicts with it.

If it turns out that patch gets accepted into the truck, I could maybe use the new sleeptimer_period value it creates to make a new version that had persistent values in the existing Sleep Timer option and replace Permanent Sleep Timer with a boolean switch; whether you’d like sleep timer to be active on startup or not.

The problem with the persistence in the current Sleep Timer option is it doubles as a viewer on how much sleep time is left. If you set it to half an hour and go back ten minutes later, it shows 20 minutes. It’s an issue both  FS#8630  & I avoided!

seani commented on 2009-11-27 13:33

Hi nickp, although it’d go against the “one feature per patch” guideline, I’d be interested in having a single patch with both these features in, even if it isn’t for a general audience. I’ll revisit FS10754 over the weekend with any luck.

I was also thinking of altering the way the pause timer works WRT track ending. At the moment, it plays in fixed increments (5, 10, 15 min etc) which means another bite at the cherry could straddle the boundary between two tracks (or podcasts in my case).

The behaviour I’m thinking of adding is that it adjusts the pause timeout to take account of this. As an example, if the pause timeout is 5 minutes and the track is 28 minutes, the timeout would operate for 5 sets of 5 and then one of 3. The next track would start with bites of five again.

This also sort of gives you “pause at the end of a track mode” for free; it you set the timeout to something large, it’ll play the whole track in one go and then pause. I say almost, because the timeout seems to be out by a second or so sometimes. I must quantify that sometime, but it doesn’t matter so much for audiobooks etc.

nickp commented on 2009-11-28 07:25

Hi Sean, good to hear from you. It occurs to me that it would be neat if we could make all these features optional through a dedicated sleep timer menu.

Kind of like (take with a pinch of salt, this is off the top of my head!);

Timer Status: Off / X Minutes ← Not an option just a display of current status
Timer Minutes: 5, 10, 15, etc ← (sleeptimer_duration*) Drop down list with value set being persistent between sessions. Has a default if value hasn’t been set?
Start Timer: Yes/ No ← Used to start the timer just for this session
Timer Behaviour: Power Down/ Pause ← (sleeptimer_action*) Feature your current patch handles. Maybe string value in case we think of other actions to perform?
Timer Starts on Power Up: Yes/ No ← (sleeptimer_on_startup*) Permanent sleep timer option.
Restrict to Boundary: Off/ Track/ Folder ← (sleeptimer_boundary_limit*) Extending the feature you describe above? Should this be a tolerance value instead?

* Option gets written to config file

This could either be a single patch, or if more palatable, a group of patches;

a) Implements Sleep Timer menu and persistent (but not permanent) timer value. Implements menu options 1, 2, 3
b) depends on a, implements menu option 4
c) depends on a, implements menu option 5
d) depends on a, implements menu option 6

I’ll be away most of next week and a bit busy this weekend, apologies in advance if it takes me a while to respond.

seani commented on 2009-11-29 17:50

Nick, I’ve has a quick try at pausing on track boundaries, and the naive method I was proposing to use won’t work. The pause kicks in after an absolute elapsed time, and this time is set only when the play button is pressed; it isn’t constantly revisited. This means that fastforwarding / rewinding through a track will result in it pausing in odd places. This can be addressed of course, but I don’t think this is the patch for that change: it’s crossed the boundary from being a useful side-effect of reworking the sleep timer into something that should really be separate.

Still worth looking at the other stuff I think, I’ll poke around in it.

nickp commented on 2009-12-13 09:19

This patch has now been superseded by  FS#10849 .


Available keyboard shortcuts


Task Details

Task Editing