Index: apps/misc.h =================================================================== --- apps/misc.h (revision 14391) +++ apps/misc.h (working copy) @@ -92,6 +92,11 @@ void car_adapter_mode_init(void); extern int show_logo(void); +#ifdef HAVE_LCD_BITMAP +/* custom user spash screen */ +extern int show_splash(void); +#endif + #if CONFIG_CODEC == SWCODEC /* Return current ReplayGain mode a file should have (REPLAYGAIN_TRACK or * REPLAYGAIN_ALBUM) if ReplayGain processing is enabled, or -1 if no Index: apps/plugins/CATEGORIES =================================================================== --- apps/plugins/CATEGORIES (revision 14391) +++ apps/plugins/CATEGORIES (working copy) @@ -1,4 +1,5 @@ alpine_cdc,apps +splash,apps battery_bench,apps blackjack,games bounce,demos Index: apps/plugins/viewers.config =================================================================== --- apps/plugins/viewers.config (revision 14391) +++ apps/plugins/viewers.config (working copy) @@ -1,3 +1,4 @@ +-,apps/splash,11 ch8,viewers/chip8,0 txt,viewers/viewer,1 nfo,viewers/viewer,1 Index: apps/plugins/splash.c =================================================================== --- apps/plugins/splash.c (revision 0) +++ apps/plugins/splash.c (revision 0) @@ -0,0 +1,101 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: Custom user Splash Screen $ + * + * by Gerritt Gonzales + * + * 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 "plugin.h" + +PLUGIN_HEADER + +static struct plugin_api* rb; + +/* this is the plugin entry point */ +enum plugin_status plugin_start(struct plugin_api* api, void* parameter) +{ + rb = api; + +#if LCD_DEPTH >= 8 + static fb_data img_buffer[LCD_HEIGHT*LCD_WIDTH] __attribute__ ((aligned (16))); +#elif LCD_DEPTH == 2 + static fb_data img_buffer[LCD_FBHEIGHT*LCD_FBWIDTH]; +#else + static fb_data img_buffer[LCD_WIDTH*LCD_HEIGHT]; +#endif + struct bitmap bm; + bm.data = (char*)img_buffer; + if(parameter){ + if ((char*)parameter){ + char *suffix = rb->strrchr((char*)parameter, '.'); + if (suffix){ + if (rb->strcasecmp(suffix, ".bmp") == 0){ + int f; + int g; + rb->lcd_clear_display(); + int ret = rb->read_bmp_file( parameter, &bm, sizeof(img_buffer), FORMAT_NATIVE | FORMAT_DITHER); + if(ret <=0||(LCD_WIDTH < bm.width||LCD_HEIGHT < bm.height)){ + rb->splash(HZ*2, "error reading bitmap"); + }else{ + rb->lcd_bitmap(img_buffer, (LCD_WIDTH-bm.width)/2, (LCD_HEIGHT-bm.height)/2, bm.width, bm.height); + rb->lcd_update(); + /* open file and write parameter */ + f = rb->open("/.rockbox/rocks/apps/splash.conf", O_CREAT|O_WRONLY|O_TRUNC); + g = rb->open("/splash.cfg", O_CREAT|O_WRONLY|O_TRUNC); + if((f < 0)||(g<0)){ + rb->splash(HZ*2, "Can't write to cfg file"); + }else{ + rb->fdprintf(f, "%s", (char*)parameter); + rb->fdprintf(g, "splash screen: %s", (char*)parameter); + /* uncomment to reset every time */ + /* rb->fdprintf(g, "splash timeout: 1"); */ + rb->close(f); + rb->close(g); + } + rb->sleep(HZ*1); + } + } + } + } + rb->set_current_file("/splash.cfg"); + }else{ + rb->lcd_clear_display(); + int ret = rb->read_bmp_file( "/splash.bmp", &bm, + sizeof(img_buffer), FORMAT_NATIVE | FORMAT_DITHER); + if(ret < 0){ + /* need to parse the cfg file then only need one file */ + int f2; + f2 = rb->open("/.rockbox/rocks/apps/splash.conf", O_RDONLY); + if(f2 < 0){ + rb->splash(HZ*2, "Can't read config file"); + }else{ + char filename[MAX_PATH]; + rb->read_line(f2, filename, MAX_PATH); + ret = rb->read_bmp_file( filename, &bm, sizeof(img_buffer), + FORMAT_NATIVE | FORMAT_DITHER); + rb->close(f2); + } + if(ret <= 0 || (LCD_WIDTH < bm.width || LCD_HEIGHT < bm.height)){ + rb->splash(HZ*2, "error reading bitmap"); + }else{ + rb->lcd_bitmap(img_buffer, (LCD_WIDTH-bm.width)/2, + (LCD_HEIGHT-bm.height)/2, bm.width, bm.height); + rb->lcd_update(); + rb->sleep(HZ*1); + } + } + } + return PLUGIN_OK; +} + Index: apps/plugins/SOURCES =================================================================== --- apps/plugins/SOURCES (revision 14391) +++ apps/plugins/SOURCES (working copy) @@ -1,4 +1,5 @@ /* plugins common to all models */ +splash.c battery_bench.c chessclock.c credits.c Index: apps/lang/english.lang =================================================================== --- apps/lang/english.lang (revision 14391) +++ apps/lang/english.lang (working copy) @@ -11054,3 +11054,17 @@ *: "units per tick" + + id: LANG_SHOW_SPLASH + desc: in settings_menu + user: + + *: "Configure Splash Screen" + + + *: "Configure Splash Screen" + + + *: "Configure Splash Screen" + + Index: apps/settings.h =================================================================== --- apps/settings.h (revision 14391) +++ apps/settings.h (working copy) @@ -495,6 +495,11 @@ #ifdef HAVE_LCD_BITMAP bool offset_out_of_view; int screen_scroll_step; + /* custom user splash screen */ + int splash_timeout; /* splash screen off timeout: 0-9 0=never, + then according to timeout_values[] */ + unsigned char splash_file[MAX_FILENAME+1]; /* splash screen bitmap file */ +/* custom user splash screen */ #endif /* auto bookmark settings */ Index: apps/menus/display_menu.c =================================================================== --- apps/menus/display_menu.c (revision 14391) +++ apps/menus/display_menu.c (working copy) @@ -571,13 +571,19 @@ #endif MENUITEM_SETTING(show_icons, &global_settings.show_icons, NULL); +#ifdef HAVE_LCD_BITMAP +/* custom user splash screen */ +/* MENUITEM_SETTING(show_splash, &global_settings.show_splash, NULL); */ +MENUITEM_SETTING(splash_timeout, &global_settings.splash_timeout, NULL); +/* custom user splash screen */ +#endif MENUITEM_SETTING(codepage_setting, &global_settings.default_codepage, NULL); MAKE_MENU(display_menu, ID2P(LANG_DISPLAY), NULL, Icon_Display_menu, #ifdef HAVE_LCD_BITMAP - &browse_fonts, + &splash_timeout, &browse_fonts, #endif &browse_wps, #ifdef HAVE_REMOTE_LCD Index: apps/settings_list.c =================================================================== --- apps/settings_list.c (revision 14391) +++ apps/settings_list.c (working copy) @@ -204,6 +204,34 @@ #endif /* HAVE_RECORDING */ +#ifdef HAVE_LCD_BITMAP +/* for custom user splash screen */ +static const char splash_times_conf [] = + "off,1,2,3,4,5,6,7,8,9"; +static const int splash_times[] = + {-1, 1, 2, 3, 4, 5, 6, 7, 8, 9}; +static void splash_formatter(char *buffer, size_t buffer_size, + int val, const char *unit) +{ + (void)unit; + if (val == 0) + strcpy(buffer, str(LANG_OFF)); + else if (val == 1) + strcpy(buffer, str(LANG_ON)); + else + snprintf(buffer, buffer_size, "%d s", splash_times[val]); +} +static long splash_getlang(int value) +{ + if (value == 0) + return LANG_OFF; + else if (value == 1) + return LANG_ON; + return TALK_ID(splash_times[value], UNIT_SEC); +} +/* for custom user splash screen */ +#endif + #ifdef HAVE_BACKLIGHT static const char backlight_times_conf [] = "off,on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90"; @@ -473,6 +501,14 @@ "time format", "24hour,12hour", NULL, 2, ID2P(LANG_24_HOUR_CLOCK), ID2P(LANG_12_HOUR_CLOCK)), #endif + +/* custom user splash screen */ + INT_SETTING_W_CFGVALS(F_FLIPLIST, splash_timeout, LANG_SHOW_SPLASH, 0, + "splash timeout", splash_times_conf, UNIT_SEC, + 0, 9, 1, splash_formatter, splash_getlang, + NULL), +/* custom user splash screen */ + #endif /* HAVE_LCD_BITMAP */ OFFON_SETTING(0,show_icons, LANG_SHOW_ICONS ,true,"show icons", NULL), /* system */ @@ -1176,6 +1212,8 @@ "", BACKDROP_DIR "/", ".bmp", MAX_FILENAME+1), #endif #ifdef HAVE_LCD_BITMAP + FILENAME_SETTING(F_THEMESETTING,splash_file,"splash screen", + "", "", ".bmp", MAX_FILENAME+1), FILENAME_SETTING(0,kbd_file,"kbd","",ROCKBOX_DIR "/",".kbd",MAX_FILENAME+1), #endif #ifdef HAVE_USB_POWER Index: apps/main.c =================================================================== --- apps/main.c (revision 14391) +++ apps/main.c (working copy) @@ -264,7 +264,10 @@ lcd_remote_init(); #endif font_init(); +#ifndef HAVE_LCD_BITMAP +/* like this for the custom splash screen */ show_logo(); +#endif button_init(); backlight_init(); lang_init(); @@ -276,10 +279,20 @@ gui_syncstatusbar_init(&statusbars); settings_reset(); settings_load(SETTINGS_ALL); +#ifdef HAVE_LCD_BITMAP +/* just for the sim. This mimics the behaviour on target */ + if(global_settings.splash_timeout < 1){ + show_logo(); + }else{ + show_splash(); + } +/* custom user splash screen */ +#endif gui_sync_wps_init(); settings_apply(); init_dircache(true); init_dircache(false); + #ifdef HAVE_TAGCACHE init_tagcache(); #endif @@ -352,7 +365,11 @@ #endif font_init(); +#ifndef HAVE_LCD_BITMAP +/* like this for the custom splash screen */ show_logo(); +#endif + lang_init(); #ifdef DEBUG @@ -499,6 +516,15 @@ #endif } +#ifdef HAVE_LCD_BITMAP +/* custom user splash screen */ + if(global_settings.splash_timeout < 1){ + show_logo(); + }else{ + show_splash(); + } +#endif + gui_sync_wps_init(); settings_apply(); init_dircache(false); Index: apps/misc.c =================================================================== --- apps/misc.c (revision 14391) +++ apps/misc.c (working copy) @@ -905,6 +905,40 @@ { return default_event_handler_ex(event, NULL, NULL); } +#ifdef HAVE_LCD_BITMAP +/* custom user splash */ +int show_splash( void ) +{ +#if LCD_DEPTH >= 8 + static fb_data img_buffer[LCD_HEIGHT*LCD_WIDTH] + __attribute__ ((aligned (16))); +#elif LCD_DEPTH == 2 + static fb_data img_buffer[LCD_FBHEIGHT*LCD_FBWIDTH]; +#else + static fb_data img_buffer[LCD_WIDTH*LCD_HEIGHT]; +#endif + struct bitmap bm; + bm.data = (char*)img_buffer; + int ret = read_bmp_file( "/splash.bmp", &bm, sizeof(img_buffer), + FORMAT_NATIVE | FORMAT_DITHER); + if(ret < 0){ + char filename[MAX_PATH]; + snprintf(filename, MAX_PATH, "%s.bmp", global_settings.splash_file); + ret = read_bmp_file(filename, &bm, sizeof(img_buffer), + FORMAT_NATIVE | FORMAT_DITHER); + } + if(ret <= 0 || (LCD_WIDTH < bm.width || LCD_HEIGHT < bm.height)){ + show_logo(); + }else{ + lcd_bitmap(img_buffer, (LCD_WIDTH-bm.width)/2, + (LCD_HEIGHT-bm.height)/2, bm.width, bm.height); + lcd_update(); + sleep(HZ*global_settings.splash_timeout); + } + return 0; +} +/* custom user splash */ +#endif int show_logo( void ) {