summaryrefslogtreecommitdiff
path: root/apps/screensaver.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/screensaver.c')
-rw-r--r--apps/screensaver.c129
1 files changed, 129 insertions, 0 deletions
diff --git a/apps/screensaver.c b/apps/screensaver.c
new file mode 100644
index 0000000000..b8144478e2
--- /dev/null
+++ b/apps/screensaver.c
@@ -0,0 +1,129 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 Robert E. Hak (rhak at ramapo.edu)
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
20#ifdef HAVE_LCD_BITMAP
21
22#include "screensaver.h"
23#include "lcd.h"
24#include "button.h"
25#include "kernel.h"
26
27#ifdef SIMULATOR
28#include <stdio.h>
29#include <string.h>
30#endif
31
32#define SS_TITLE "Boxes"
33#define SS_TITLE_FONT 2
34
35void ss_loop(void)
36{
37 int b;
38 int x2 = LCD_WIDTH/2;
39 int y2 = LCD_HEIGHT/2;
40 int x = LCD_WIDTH/2;
41 int y = LCD_HEIGHT/2;
42 int i = 0;
43 int center = 0;
44 int factor = 0;
45 int offset = 0;
46
47 if (LCD_HEIGHT < LCD_WIDTH)
48 center = LCD_HEIGHT/2;
49 else
50 center = LCD_WIDTH/2;
51
52 i = center+1;
53 while(1)
54 {
55 /* Grow */
56 if ( i < 0 ) {
57 factor = 1;
58 i = 1;
59 }
60
61 /* Shrink */
62 if (i >= center) {
63 factor = -1;
64 i = center;
65 }
66
67 offset=i*factor;
68
69 b = button_get();
70 if ( b & BUTTON_OFF )
71 return;
72
73 lcd_clear_display();
74 lcd_drawrect(x-offset, y-offset, x2+offset, y2+offset);
75 lcd_update();
76
77 i+=factor;
78
79 sleep(10);
80 }
81}
82
83
84void screensaver(void)
85{
86 int w, h;
87 char *off = "[Off] to stop";
88 int len = strlen(SS_TITLE);
89
90 lcd_getfontsize(SS_TITLE_FONT, &w, &h);
91
92 /* Get horizontel centering for text */
93 len *= w;
94 if (len%2 != 0)
95 len = ((len+1)/2)+(w/2);
96 else
97 len /= 2;
98
99 if (h%2 != 0)
100 h = (h/2)+1;
101 else
102 h /= 2;
103
104 lcd_clear_display();
105 lcd_putsxy(LCD_WIDTH/2-len, (LCD_HEIGHT/2)-h, SS_TITLE, SS_TITLE_FONT);
106
107 len = strlen(off);
108 lcd_getfontsize(0, &w, &h);
109
110 /* Get horizontel centering for text */
111 len *= w;
112 if (len%2 != 0)
113 len = ((len+1)/2)+(w/2);
114 else
115 len /= 2;
116
117 if (h%2 != 0)
118 h = (h/2)+1;
119 else
120 h /= 2;
121
122 lcd_putsxy(LCD_WIDTH/2-len, LCD_HEIGHT-(2*h), off,0);
123
124 lcd_update();
125 sleep(150);
126 ss_loop();
127}
128
129#endif