2006-02-02 20:42:56 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Dave Chapman
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include "config.h"
|
|
|
|
#include "lcd.h"
|
|
|
|
#include "backdrop.h"
|
2006-05-21 11:00:02 +00:00
|
|
|
#include "splash.h" /* debugging */
|
2006-02-02 20:42:56 +00:00
|
|
|
|
|
|
|
fb_data main_backdrop[LCD_HEIGHT][LCD_WIDTH];
|
|
|
|
fb_data wps_backdrop[LCD_HEIGHT][LCD_WIDTH];
|
2006-05-21 11:00:02 +00:00
|
|
|
bool main_backdrop_valid = false;
|
|
|
|
bool wps_backdrop_valid = false;
|
2006-02-02 20:42:56 +00:00
|
|
|
|
2006-05-21 11:00:02 +00:00
|
|
|
/* load a backdrop into a buffer */
|
|
|
|
bool load_backdrop(char* filename, fb_data* backdrop_buffer)
|
2006-02-02 20:42:56 +00:00
|
|
|
{
|
|
|
|
struct bitmap bm;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* load the image */
|
2006-05-21 11:00:02 +00:00
|
|
|
bm.data=(char*)backdrop_buffer;
|
2006-10-11 01:26:09 +00:00
|
|
|
ret = read_bmp_file(filename, &bm, sizeof(main_backdrop),
|
|
|
|
FORMAT_NATIVE | FORMAT_DITHER);
|
2006-02-02 20:42:56 +00:00
|
|
|
|
2006-05-21 11:00:02 +00:00
|
|
|
if ((ret > 0) && (bm.width == LCD_WIDTH) && (bm.height == LCD_HEIGHT))
|
|
|
|
{
|
2006-02-02 20:42:56 +00:00
|
|
|
return true;
|
2006-05-21 11:00:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-02-02 20:42:56 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2006-05-21 11:00:02 +00:00
|
|
|
|
|
|
|
bool load_main_backdrop(char* filename)
|
|
|
|
{
|
|
|
|
main_backdrop_valid = load_backdrop(filename, &main_backdrop[0][0]);
|
|
|
|
/* gui_syncsplash(100, true, "MAIN backdrop load: %s", main_backdrop_valid ? "OK" : "FAIL");*/
|
|
|
|
return main_backdrop_valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool load_wps_backdrop(char* filename)
|
|
|
|
{
|
|
|
|
wps_backdrop_valid = load_backdrop(filename, &wps_backdrop[0][0]);
|
|
|
|
/* gui_syncsplash(100, true, "WPS backdrop load: %s", main_backdrop_valid ? "OK" : "FAIL");*/
|
|
|
|
return wps_backdrop_valid;
|
|
|
|
}
|
|
|
|
|
|
|
|
void unload_main_backdrop(void)
|
|
|
|
{
|
|
|
|
main_backdrop_valid = false;
|
|
|
|
/* gui_syncsplash(100, true, "MAIN backdrop unload");*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void unload_wps_backdrop(void)
|
|
|
|
{
|
|
|
|
wps_backdrop_valid = false;
|
|
|
|
/* gui_syncsplash(100, true, "WPS backdrop unload");*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void show_main_backdrop(void)
|
|
|
|
{
|
|
|
|
lcd_set_backdrop(main_backdrop_valid ? &main_backdrop[0][0] : NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void show_wps_backdrop(void)
|
|
|
|
{
|
|
|
|
/* if no wps backdrop, fall back to main backdrop */
|
|
|
|
if(wps_backdrop_valid)
|
|
|
|
{
|
|
|
|
lcd_set_backdrop(&wps_backdrop[0][0]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* gui_syncsplash(100, true, "WPS backdrop show: fallback to MAIN");*/
|
|
|
|
show_main_backdrop();
|
|
|
|
}
|
|
|
|
}
|