summaryrefslogtreecommitdiff
path: root/apps/screens.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/screens.c')
-rw-r--r--apps/screens.c292
1 files changed, 292 insertions, 0 deletions
diff --git a/apps/screens.c b/apps/screens.c
new file mode 100644
index 0000000000..04870d1f1a
--- /dev/null
+++ b/apps/screens.c
@@ -0,0 +1,292 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Björn Stenberg
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 <stdbool.h>
20#include <string.h>
21#include <stdio.h>
22#include "backlight.h"
23#include "button.h"
24#include "lcd.h"
25#include "lang.h"
26#include "icons.h"
27#include "font.h"
28#include "mpeg.h"
29#include "usb.h"
30#include "settings.h"
31#include "playlist.h"
32
33void usb_screen(void)
34{
35#ifndef SIMULATOR
36 backlight_on();
37 usb_acknowledge(SYS_USB_CONNECTED_ACK);
38 usb_wait_for_disconnect(&button_queue);
39 backlight_on();
40#endif
41}
42
43#ifdef HAVE_RECORDER_KEYPAD
44/* returns:
45 0 if no key was pressed
46 1 if a key was pressed (or if ON was held down long enough to repeat)
47 2 if USB was connected */
48int on_screen(void)
49{
50 static int pitch = 100;
51 bool exit = false;
52 bool used = false;
53
54 while (!exit) {
55
56 if ( used ) {
57 char* ptr;
58 char buf[32];
59 int w, h;
60
61 lcd_scroll_pause();
62 lcd_clear_display();
63
64 ptr = str(LANG_PITCH_UP);
65 lcd_getstringsize(ptr,FONT_UI,&w,&h);
66 lcd_putsxy((LCD_WIDTH-w)/2, 0, ptr, FONT_UI);
67 lcd_bitmap(bitmap_icons_7x8[Icon_UpArrow],
68 LCD_WIDTH/2 - 3, h*2, 7, 8, true);
69
70 snprintf(buf, sizeof buf, "%d%%", pitch);
71 lcd_getstringsize(buf,FONT_UI,&w,&h);
72 lcd_putsxy((LCD_WIDTH-w)/2, h, buf, FONT_UI);
73
74 ptr = str(LANG_PITCH_DOWN);
75 lcd_getstringsize(ptr,FONT_UI,&w,&h);
76 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, ptr, FONT_UI);
77 lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
78 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
79
80 ptr = str(LANG_PAUSE);
81 lcd_getstringsize(ptr,FONT_UI,&w,&h);
82 lcd_putsxy((LCD_WIDTH-(w/2))/2, LCD_HEIGHT/2 - h/2, ptr, FONT_UI);
83 lcd_bitmap(bitmap_icons_7x8[Icon_Pause],
84 (LCD_WIDTH-(w/2))/2-10, LCD_HEIGHT/2 - h/2, 7, 8, true);
85
86 lcd_update();
87 }
88
89 /* use lastbutton, so the main loop can decide whether to
90 exit to browser or not */
91 switch (button_get(true)) {
92 case BUTTON_UP:
93 case BUTTON_ON | BUTTON_UP:
94 case BUTTON_ON | BUTTON_UP | BUTTON_REPEAT:
95 used = true;
96 pitch++;
97 if ( pitch > 200 )
98 pitch = 200;
99#ifdef HAVE_MAS3587F
100 mpeg_set_pitch(pitch);
101#endif
102 break;
103
104 case BUTTON_DOWN:
105 case BUTTON_ON | BUTTON_DOWN:
106 case BUTTON_ON | BUTTON_DOWN | BUTTON_REPEAT:
107 used = true;
108 pitch--;
109 if ( pitch < 50 )
110 pitch = 50;
111#ifdef HAVE_MAS3587F
112 mpeg_set_pitch(pitch);
113#endif
114 break;
115
116 case BUTTON_ON | BUTTON_PLAY:
117 mpeg_pause();
118 used = true;
119 break;
120
121 case BUTTON_PLAY | BUTTON_REL:
122 mpeg_resume();
123 used = true;
124 break;
125
126 case BUTTON_ON | BUTTON_PLAY | BUTTON_REL:
127 mpeg_resume();
128 exit = true;
129 break;
130
131#ifdef SIMULATOR
132 case BUTTON_ON:
133#else
134 case BUTTON_ON | BUTTON_REL:
135 case BUTTON_ON | BUTTON_UP | BUTTON_REL:
136 case BUTTON_ON | BUTTON_DOWN | BUTTON_REL:
137#endif
138 exit = true;
139 break;
140
141 case BUTTON_ON | BUTTON_REPEAT:
142 used = true;
143 break;
144
145 case SYS_USB_CONNECTED:
146 usb_screen();
147 return 2;
148 }
149 }
150
151 if ( used )
152 return 1;
153 else
154 return 0;
155}
156
157bool f2_screen(void)
158{
159 bool exit = false;
160 bool used = false;
161 int w, h;
162 char buf[32];
163
164 /* Get the font height */
165 lcd_getstringsize("A",FONT_UI,&w,&h);
166
167 lcd_stop_scroll();
168
169 while (!exit) {
170 lcd_clear_display();
171
172 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_SHUFFLE), FONT_UI);
173 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F2_MODE), FONT_UI);
174 lcd_putsxy(0, LCD_HEIGHT/2,
175 global_settings.playlist_shuffle ?
176 str(LANG_ON) : str(LANG_OFF), FONT_UI);
177 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
178 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
179
180 snprintf(buf, sizeof buf, str(LANG_DIR_FILTER),
181 global_settings.mp3filter ? str(LANG_ON) : str(LANG_OFF));
182
183 /* Get the string width and height */
184 lcd_getstringsize(buf,FONT_UI,&w,&h);
185 lcd_putsxy((LCD_WIDTH-w)/2, LCD_HEIGHT - h, buf, FONT_UI);
186 lcd_bitmap(bitmap_icons_7x8[Icon_DownArrow],
187 LCD_WIDTH/2 - 3, LCD_HEIGHT - h*3, 7, 8, true);
188
189 lcd_update();
190
191 switch (button_get(true)) {
192 case BUTTON_LEFT:
193 case BUTTON_F2 | BUTTON_LEFT:
194 global_settings.playlist_shuffle =
195 !global_settings.playlist_shuffle;
196
197 if (global_settings.playlist_shuffle)
198 randomise_playlist(current_tick);
199 else
200 sort_playlist(true);
201 used = true;
202 break;
203
204 case BUTTON_DOWN:
205 case BUTTON_F2 | BUTTON_DOWN:
206 global_settings.mp3filter = !global_settings.mp3filter;
207 used = true;
208 break;
209
210 case BUTTON_F2 | BUTTON_REL:
211 if ( used )
212 exit = true;
213 used = true;
214 break;
215
216 case SYS_USB_CONNECTED:
217 usb_screen();
218 return true;
219 }
220 }
221
222 settings_save();
223
224 return false;
225}
226
227bool f3_screen(void)
228{
229 bool exit = false;
230 bool used = false;
231
232 lcd_stop_scroll();
233
234 while (!exit) {
235 int w,h;
236 char* ptr;
237
238 ptr = str(LANG_F3_STATUS);
239 lcd_getstringsize(ptr,FONT_UI,&w,&h);
240 lcd_clear_display();
241
242 lcd_putsxy(0, LCD_HEIGHT/2 - h*2, str(LANG_F3_SCROLL), FONT_UI);
243 lcd_putsxy(0, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI);
244 lcd_putsxy(0, LCD_HEIGHT/2,
245 global_settings.scrollbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
246 lcd_bitmap(bitmap_icons_7x8[Icon_FastBackward],
247 LCD_WIDTH/2 - 16, LCD_HEIGHT/2 - 4, 7, 8, true);
248
249 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h*2, ptr, FONT_UI);
250 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2 - h, str(LANG_F3_BAR), FONT_UI);
251 lcd_putsxy(LCD_WIDTH - w, LCD_HEIGHT/2,
252 global_settings.statusbar ? str(LANG_ON) : str(LANG_OFF), FONT_UI);
253 lcd_bitmap(bitmap_icons_7x8[Icon_FastForward],
254 LCD_WIDTH/2 + 8, LCD_HEIGHT/2 - 4, 7, 8, true);
255 lcd_update();
256
257 switch (button_get(true)) {
258 case BUTTON_LEFT:
259 case BUTTON_F3 | BUTTON_LEFT:
260 global_settings.scrollbar = !global_settings.scrollbar;
261 used = true;
262 break;
263
264 case BUTTON_RIGHT:
265 case BUTTON_F3 | BUTTON_RIGHT:
266 global_settings.statusbar = !global_settings.statusbar;
267 used = true;
268 break;
269
270 case BUTTON_F3 | BUTTON_REL:
271 if ( used )
272 exit = true;
273 used = true;
274 break;
275
276 case SYS_USB_CONNECTED:
277 usb_screen();
278 return true;
279 }
280 }
281
282 settings_save();
283 if (global_settings.statusbar)
284 lcd_setmargins(0, STATUSBAR_HEIGHT);
285 else
286 lcd_setmargins(0, 0);
287
288 return false;
289}
290#endif
291
292