1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2002 Linus Nielsen Feltzing
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
30 #include "powermgmt.h"
31 #include "statusbar.h"
38 #define SMALL_STEP_SIZE 15*60 /* Seconds */
39 #define LARGE_STEP_SIZE 30*60 /* Seconds */
40 #define THRESHOLD 60 /* Minutes */
41 #define MAX_TIME 5*60*60 /* Hours */
43 bool sleeptimer_screen(void)
45 unsigned long seconds
;
52 int org_timer
=get_sleep_timer();
56 #ifdef HAVE_LCD_BITMAP
57 if (global_settings
.statusbar
)
58 lcd_setmargins(0, STATUSBAR_HEIGHT
);
64 lcd_puts_scroll(0, 0, str(LANG_SLEEP_TIMER
));
68 button
= button_get_w_tmo(HZ
);
81 lcd_puts(0, 0, str(LANG_MENU_SETTING_CANCEL
));
83 set_sleep_timer(org_timer
);
90 oldtime
= (get_sleep_timer()+59) / 60;
91 if(oldtime
< THRESHOLD
)
92 amount
= SMALL_STEP_SIZE
;
94 amount
= LARGE_STEP_SIZE
;
96 newtime
= oldtime
* 60 + amount
;
97 if(newtime
> MAX_TIME
)
100 changed
= sayit
= true;
101 set_sleep_timer(newtime
);
105 oldtime
= (get_sleep_timer()+59) / 60;
106 if(oldtime
<= THRESHOLD
)
107 amount
= SMALL_STEP_SIZE
;
109 amount
= LARGE_STEP_SIZE
;
111 newtime
= oldtime
*60 - amount
;
115 changed
= sayit
= true;
116 set_sleep_timer(newtime
);
120 seconds
= get_sleep_timer();
124 seconds
+= 59; /* Round up for a "friendlier" display */
125 hours
= seconds
/ 3600;
126 minutes
= (seconds
- (hours
* 3600)) / 60;
127 snprintf(buf
, 32, "%d:%02d",
129 lcd_puts(0, 1, (unsigned char *)buf
);
131 if (sayit
&& global_settings
.talk_menu
)
133 bool enqueue
= false; /* first one should not ne queued */
137 talk_value(hours
, UNIT_HOUR
, enqueue
);
138 enqueue
= true; /* queue any following */
142 talk_value(minutes
, UNIT_MIN
, enqueue
);
150 lcd_puts(0, 1, str(LANG_OFF
));
151 if (sayit
&& global_settings
.talk_menu
)
153 talk_id(LANG_OFF
, false);
158 gui_syncstatusbar_draw(&statusbars
, true);