only send a Charging Only interface if nothing else is sent
[kugel-rb.git] / apps / gui / backdrop.c
blob0d023602be043ff6c4a2ebec230889a30cda8ab0
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2006 Dave Chapman
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.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
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"
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
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
41 static bool main_backdrop_valid = false;
42 static bool wps_backdrop_valid = false;
44 /* load a backdrop into a buffer */
45 static bool load_backdrop(char* filename, fb_data* backdrop_buffer)
47 struct bitmap bm;
48 int ret;
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);
55 if ((ret > 0) && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT))
57 return true;
59 else
61 return false;
65 bool load_main_backdrop(char* filename)
67 main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]);
68 return main_backdrop_valid;
71 bool load_wps_backdrop(char* filename)
73 wps_backdrop_valid = load_backdrop(filename, &wps_backdrop[0][0]);
74 return wps_backdrop_valid;
77 void unload_main_backdrop(void)
79 main_backdrop_valid = false;
82 void unload_wps_backdrop(void)
84 wps_backdrop_valid = false;
87 void show_main_backdrop(void)
89 lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL);
92 void show_wps_backdrop(void)
94 /* if no wps backdrop, fall back to main backdrop */
95 if(wps_backdrop_valid)
97 lcd_set_backdrop(&wps_backdrop[0][0]);
99 else
101 show_main_backdrop();
105 #if defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH > 1
107 static bool load_remote_backdrop(char* filename, fb_remote_data* backdrop_buffer)
109 struct bitmap bm;
110 int ret;
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);
117 if ((ret > 0) && (bm.width == LCD_REMOTE_WIDTH) && (bm.height == LCD_REMOTE_HEIGHT))
119 return true;
121 else
123 return false;
127 bool load_remote_wps_backdrop(char* filename)
129 remote_wps_backdrop_valid = load_remote_backdrop(filename, &remote_wps_backdrop[0][0]);
130 return remote_wps_backdrop_valid;
133 void unload_remote_wps_backdrop(void)
135 remote_wps_backdrop_valid = false;
138 void show_remote_wps_backdrop(void)
140 /* if no wps backdrop, fall back to main backdrop */
141 if(remote_wps_backdrop_valid)
143 lcd_remote_set_backdrop(&remote_wps_backdrop[0][0]);
145 else
147 show_remote_main_backdrop();
151 void show_remote_main_backdrop(void)
153 lcd_remote_set_backdrop(NULL);
155 #endif