diff options
Diffstat (limited to 'apps/gui/backdrop.c')
-rw-r--r-- | apps/gui/backdrop.c | 155 |
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 | ||
29 | static fb_data main_backdrop[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16))); | ||
30 | static fb_data wps_backdrop[LCD_HEIGHT][LCD_WIDTH] __attribute__ ((aligned (16))); | ||
31 | #elif LCD_DEPTH == 2 | ||
32 | static fb_data main_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH]; | ||
33 | static fb_data wps_backdrop[LCD_FBHEIGHT][LCD_FBWIDTH]; | ||
34 | #endif | ||
35 | |||
36 | #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1 | ||
37 | static fb_remote_data remote_wps_backdrop[LCD_REMOTE_FBHEIGHT][LCD_REMOTE_FBWIDTH]; | ||
38 | static bool remote_wps_backdrop_valid = false; | ||
39 | #endif | ||
40 | |||
41 | static bool main_backdrop_valid = false; | ||
42 | static bool wps_backdrop_valid = false; | ||
43 | |||
44 | /* load a backdrop into a buffer */ | ||
45 | static 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 | |||
65 | bool load_main_backdrop(char* filename) | ||
66 | { | ||
67 | main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]); | ||
68 | return main_backdrop_valid; | ||
69 | } | ||
70 | |||
71 | bool load_wps_backdrop(char* filename) | ||
72 | { | ||
73 | wps_backdrop_valid = load_backdrop(filename, &wps_backdrop[0][0]); | ||
74 | return wps_backdrop_valid; | ||
75 | } | ||
76 | |||
77 | void unload_main_backdrop(void) | ||
78 | { | ||
79 | main_backdrop_valid = false; | ||
80 | } | ||
81 | |||
82 | void unload_wps_backdrop(void) | ||
83 | { | ||
84 | wps_backdrop_valid = false; | ||
85 | } | ||
86 | |||
87 | void show_main_backdrop(void) | ||
88 | { | ||
89 | lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL); | ||
90 | } | ||
91 | |||
92 | void 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 | |||
107 | static 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 | |||
127 | bool 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 | |||
133 | void unload_remote_wps_backdrop(void) | ||
134 | { | ||
135 | remote_wps_backdrop_valid = false; | ||
136 | } | ||
137 | |||
138 | void 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 | |||
151 | void show_remote_main_backdrop(void) | ||
152 | { | ||
153 | lcd_remote_set_backdrop(NULL); | ||
154 | } | ||
155 | #endif | ||