Index: apps/plugins/CATEGORIES =================================================================== --- apps/plugins/CATEGORIES (revision 14391) +++ apps/plugins/CATEGORIES (working copy) @@ -1,3 +1,4 @@ +autostart,apps alpine_cdc,apps battery_bench,apps blackjack,games Index: apps/plugins/viewers.config =================================================================== --- apps/plugins/viewers.config (revision 14391) +++ apps/plugins/viewers.config (working copy) @@ -1,3 +1,4 @@ +bmp,apps/autostart,5 ch8,viewers/chip8,0 txt,viewers/viewer,1 nfo,viewers/viewer,1 Index: apps/plugins/autostart.c =================================================================== --- apps/plugins/autostart.c (revision 0) +++ apps/plugins/autostart.c (revision 0) @@ -0,0 +1,102 @@ +/*************************************************************************** + * __________ __ ___. + * 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; + 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(); + rb->sleep(HZ*2); + /* open file and write parameter */ + f = rb->open("/.rockbox/rocks/apps/splash.conf", O_CREAT|O_WRONLY|O_TRUNC); + if(f < 0){ + rb->splash(HZ*2, "Can't open config file"); + }else{ + rb->fdprintf(f, "%s", (char*)parameter); + rb->close(f); + } + } + } + } + } + }else{ + rb->lcd_clear_display(); + + int ret = rb->read_bmp_file( "/.rockbox/splash.bmp", &bm, + sizeof(img_buffer), FORMAT_NATIVE | FORMAT_DITHER); + if(ret < 0){ + /* open file and read path */ + char filename[MAX_PATH]; + 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{ + 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){ + ret = rb->read_bmp_file("/.rockbox/backdrops/splash.bmp", &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(); + rb->sleep(HZ*2); + } + }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*2); + } + } + 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 */ +autostart.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_AUTOSTART + desc: in settings_menu + user: + + *: "Auto Start" + + + *: "Auto Start" + + + *: "Auto Start" + + Index: apps/settings.h =================================================================== --- apps/settings.h (revision 14391) +++ apps/settings.h (working copy) @@ -495,6 +495,8 @@ #ifdef HAVE_LCD_BITMAP bool offset_out_of_view; int screen_scroll_step; +/* auto start */ + int autostart_onoff; /* autostart off on */ #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,18 @@ #endif MENUITEM_SETTING(show_icons, &global_settings.show_icons, NULL); +#ifdef HAVE_LCD_BITMAP +/* autostart */ +MENUITEM_SETTING(autostart_onoff, &global_settings.autostart_onoff, NULL); +/* autostart */ +#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, + &autostart_onoff, &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,31 @@ #endif /* HAVE_RECORDING */ +#ifdef HAVE_LCD_BITMAP +/* for autostart */ +static const char autostart_onoff_conf [] = + "off,1"; +static const int autostart_onoff[] = + {-1, 1}; +static void autostart_formatter(char *buffer, int 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)); +} +static long autostart_getlang(int value) +{ + if (value == 0) + return LANG_OFF; + else if (value == 1) + return LANG_ON; +} +/* autostart */ +#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 +498,14 @@ "time format", "24hour,12hour", NULL, 2, ID2P(LANG_24_HOUR_CLOCK), ID2P(LANG_12_HOUR_CLOCK)), #endif + +/* autostart */ + INT_SETTING_W_CFGVALS(F_FLIPLIST, autostart_onoff, LANG_AUTOSTART, 0, + "autostart", autostart_onoff_conf, UNIT_SEC, + 0, 1, 1, autostart_formatter, autostart_getlang, + NULL), +/* autostart */ + #endif /* HAVE_LCD_BITMAP */ OFFON_SETTING(0,show_icons, LANG_SHOW_ICONS ,true,"show icons", NULL), /* system */ Index: apps/main.c =================================================================== --- apps/main.c (revision 14391) +++ apps/main.c (working copy) @@ -109,8 +109,6 @@ #include "cuesheet.h" -/*#define AUTOROCK*/ /* define this to check for "autostart.rock" on boot */ - const char appsversion[]=APPSVERSION; static void init(void); @@ -264,7 +262,6 @@ lcd_remote_init(); #endif font_init(); - show_logo(); button_init(); backlight_init(); lang_init(); @@ -279,7 +276,15 @@ gui_sync_wps_init(); settings_apply(); init_dircache(true); +/* just for the sim. autostart this mimics the behaviour on target */ + if(global_settings.autostart_onoff < 1){ + show_logo(); + }else{ + static const char filename[] = PLUGIN_APPS_DIR "/autostart.rock"; + plugin_load((char*)filename, NULL); /* start if it does */ + } init_dircache(false); + #ifdef HAVE_TAGCACHE init_tagcache(); #endif @@ -351,8 +356,6 @@ lcd_remote_init(); #endif font_init(); - - show_logo(); lang_init(); #ifdef DEBUG @@ -491,7 +494,6 @@ else #endif settings_load(SETTINGS_ALL); - if (init_dircache(true) < 0) { #ifdef HAVE_TAGCACHE @@ -501,7 +503,17 @@ gui_sync_wps_init(); settings_apply(); + +/* autostart */ + if(global_settings.autostart_onoff < 1){ + show_logo(); + }else{ + static const char filename[] = PLUGIN_APPS_DIR "/autostart.rock"; + plugin_load((char*)filename, NULL); /* start if it does */ + } + init_dircache(false); + #ifdef HAVE_TAGCACHE init_tagcache(); #endif @@ -552,20 +564,6 @@ /* runtime database has to be initialized after audio_init() */ cpu_boost(false); -#ifdef AUTOROCK - { - int fd; - static const char filename[] = PLUGIN_APPS_DIR "/autostart.rock"; - - fd = open(filename, O_RDONLY); - if(fd >= 0) /* no complaint if it doesn't exist */ - { - close(fd); - plugin_load((char*)filename, NULL); /* start if it does */ - } - } -#endif /* #ifdef AUTOROCK */ - #if CONFIG_CHARGING car_adapter_mode_init(); #endif