summaryrefslogtreecommitdiff
path: root/apps/gui/backdrop.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/gui/backdrop.c')
-rw-r--r--apps/gui/backdrop.c155
1 files changed, 155 insertions, 0 deletions
diff --git a/apps/gui/backdrop.c b/apps/gui/backdrop.c
new file mode 100644
index 0000000000..0d023602be
--- /dev/null
+++ b/apps/gui/backdrop.c
@@ -0,0 +1,155 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 Dave Chapman
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#include <stdio.h>
21#include "config.h"
22#include "lcd.h"
23#ifdef HAVE_REMOTE_LCD
24#include "lcd-remote.h"
25#endif
26#include "backdrop.h"
27
28#if LCD_DEPTH >= 8
29static fb_data main_backdrop[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16)));
30static fb_data wps_backdrop[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16)));
31#elif LCD_DEPTH == 2
32static fb_data main_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH];
33static fb_data wps_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH];
34#endif
35
36#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
37static fb_remote_data remote_wps_backdrop[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH];
38static bool remote_wps_backdrop_valid = false;
39#endif
40
41static bool main_backdrop_valid = false;
42static bool wps_backdrop_valid = false;
43
44/* load a backdrop into a buffer */
45static bool load_backdrop(char* filename, fb_data* backdrop_buffer)
46{
47 struct bitmap bm;
48 int ret;
49
50 /* load the image */
51 bm.data=(char*)backdrop_buffer;
52 ret = read_bmp_file(filename, &bm, sizeof(main_backdrop),
53 FORMAT_NATIVE | FORMAT_DITHER);
54
55 if ((ret > 0) && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT))
56 {
57 return true;
58 }
59 else
60 {
61 return false;
62 }
63}
64
65bool load_main_backdrop(char* filename)
66{
67 main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]);
68 return main_backdrop_valid;
69}
70
71bool load_wps_backdrop(char* filename)
72{
73 wps_backdrop_valid = load_backdrop(filename, &wps_backdrop[0][0]);
74 return wps_backdrop_valid;
75}
76
77void unload_main_backdrop(void)
78{
79 main_backdrop_valid = false;
80}
81
82void unload_wps_backdrop(void)
83{
84 wps_backdrop_valid = false;
85}
86
87void show_main_backdrop(void)
88{
89 lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL);
90}
91
92void show_wps_backdrop(void)
93{
94 /* if no wps backdrop, fall back to main backdrop */
95 if(wps_backdrop_valid)
96 {
97 lcd_set_backdrop(&wps_backdrop[0][0]);
98 }
99 else
100 {
101 show_main_backdrop();
102 }
103}
104
105#if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
106
107static bool load_remote_backdrop(char* filename, fb_remote_data* backdrop_buffer)
108{
109 struct bitmap bm;
110 int ret;
111
112 /* load the image */
113 bm.data=(char*)backdrop_buffer;
114 ret = read_bmp_file(filename, &bm, sizeof(main_backdrop),
115 FORMAT_NATIVE | FORMAT_DITHER | FORMAT_REMOTE);
116
117 if ((ret > 0) && (bm.width == LCD_REMOTE_WIDTH) && (bm.height == LCD_REMOTE_HEIGHT))
118 {
119 return true;
120 }
121 else
122 {
123 return false;
124 }
125}
126
127bool load_remote_wps_backdrop(char* filename)
128{
129 remote_wps_backdrop_valid = load_remote_backdrop(filename, &remote_wps_backdrop[0][0]);
130 return remote_wps_backdrop_valid;
131}
132
133void unload_remote_wps_backdrop(void)
134{
135 remote_wps_backdrop_valid = false;
136}
137
138void show_remote_wps_backdrop(void)
139{
140 /* if no wps backdrop, fall back to main backdrop */
141 if(remote_wps_backdrop_valid)
142 {
143 lcd_remote_set_backdrop(&remote_wps_backdrop[0][0]);
144 }
145 else
146 {
147 show_remote_main_backdrop();
148 }
149}
150
151void show_remote_main_backdrop(void)
152{
153 lcd_remote_set_backdrop(NULL);
154}
155#endif