diff options
Diffstat (limited to 'apps/sleeptimer.c')
-rw-r--r-- | apps/sleeptimer.c | 164 |
1 files changed, 0 insertions, 164 deletions
diff --git a/apps/sleeptimer.c b/apps/sleeptimer.c deleted file mode 100644 index e9b0924388..0000000000 --- a/apps/sleeptimer.c +++ /dev/null | |||
@@ -1,164 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 Linus Nielsen Feltzing | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "options.h" | ||
21 | |||
22 | #include "lcd.h" | ||
23 | #include "font.h" | ||
24 | #include "button.h" | ||
25 | #include "kernel.h" | ||
26 | #include "sprintf.h" | ||
27 | #include <string.h> | ||
28 | #include "settings.h" | ||
29 | #include "power.h" | ||
30 | #include "powermgmt.h" | ||
31 | #include "statusbar.h" | ||
32 | #include "debug.h" | ||
33 | #include "talk.h" | ||
34 | #include "icons.h" | ||
35 | |||
36 | #include "lang.h" | ||
37 | |||
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 */ | ||
42 | |||
43 | bool sleeptimer_screen(void) | ||
44 | { | ||
45 | unsigned long seconds; | ||
46 | int hours, minutes; | ||
47 | int button; | ||
48 | bool done = false; | ||
49 | char buf[32]; | ||
50 | int oldtime, newtime; | ||
51 | int amount = 0; | ||
52 | int org_timer=get_sleep_timer(); | ||
53 | bool changed=false; | ||
54 | bool sayit = true; | ||
55 | |||
56 | #ifdef HAVE_LCD_BITMAP | ||
57 | if (global_settings.statusbar) | ||
58 | lcd_setmargins(0, STATUSBAR_HEIGHT); | ||
59 | else | ||
60 | lcd_setmargins(0, 0); | ||
61 | #endif | ||
62 | |||
63 | lcd_clear_display(); | ||
64 | lcd_puts_scroll(0, 0, str(LANG_SLEEP_TIMER)); | ||
65 | |||
66 | while(!done) | ||
67 | { | ||
68 | button = button_get_w_tmo(HZ); | ||
69 | switch(button) | ||
70 | { | ||
71 | #ifdef SETTINGS_OK2 | ||
72 | case SETTINGS_OK2: | ||
73 | #endif | ||
74 | case SETTINGS_OK: | ||
75 | done = true; | ||
76 | break; | ||
77 | |||
78 | case SETTINGS_CANCEL: | ||
79 | if (changed) { | ||
80 | lcd_stop_scroll(); | ||
81 | lcd_puts(0, 0, str(LANG_MENU_SETTING_CANCEL)); | ||
82 | lcd_update(); | ||
83 | set_sleep_timer(org_timer); | ||
84 | sleep(HZ/2); | ||
85 | } | ||
86 | done = true; | ||
87 | break; | ||
88 | |||
89 | case SETTINGS_INC: | ||
90 | oldtime = (get_sleep_timer()+59) / 60; | ||
91 | if(oldtime < THRESHOLD) | ||
92 | amount = SMALL_STEP_SIZE; | ||
93 | else | ||
94 | amount = LARGE_STEP_SIZE; | ||
95 | |||
96 | newtime = oldtime * 60 + amount; | ||
97 | if(newtime > MAX_TIME) | ||
98 | newtime = MAX_TIME; | ||
99 | |||
100 | changed = sayit = true; | ||
101 | set_sleep_timer(newtime); | ||
102 | break; | ||
103 | |||
104 | case SETTINGS_DEC: | ||
105 | oldtime = (get_sleep_timer()+59) / 60; | ||
106 | if(oldtime <= THRESHOLD) | ||
107 | amount = SMALL_STEP_SIZE; | ||
108 | else | ||
109 | amount = LARGE_STEP_SIZE; | ||
110 | |||
111 | newtime = oldtime*60 - amount; | ||
112 | if(newtime < 0) | ||
113 | newtime = 0; | ||
114 | |||
115 | changed = sayit = true; | ||
116 | set_sleep_timer(newtime); | ||
117 | break; | ||
118 | } | ||
119 | |||
120 | seconds = get_sleep_timer(); | ||
121 | |||
122 | if(seconds) | ||
123 | { | ||
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", | ||
128 | hours, minutes); | ||
129 | lcd_puts(0, 1, (unsigned char *)buf); | ||
130 | |||
131 | if (sayit && global_settings.talk_menu) | ||
132 | { | ||
133 | bool enqueue = false; /* first one should not ne queued */ | ||
134 | |||
135 | if (hours) | ||
136 | { | ||
137 | talk_value(hours, UNIT_HOUR, enqueue); | ||
138 | enqueue = true; /* queue any following */ | ||
139 | } | ||
140 | if (minutes) | ||
141 | { | ||
142 | talk_value(minutes, UNIT_MIN, enqueue); | ||
143 | } | ||
144 | |||
145 | sayit = false; | ||
146 | } | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | lcd_puts(0, 1, str(LANG_OFF)); | ||
151 | if (sayit && global_settings.talk_menu) | ||
152 | { | ||
153 | talk_id(LANG_OFF, false); | ||
154 | sayit = false; | ||
155 | } | ||
156 | } | ||
157 | |||
158 | gui_syncstatusbar_draw(&statusbars, true); | ||
159 | |||
160 | lcd_update(); | ||
161 | } | ||
162 | lcd_stop_scroll(); | ||
163 | return false; | ||
164 | } | ||