Index: tools/buildzip.pl =================================================================== --- tools/buildzip.pl (revision 24701) +++ tools/buildzip.pl (working copy) @@ -221,6 +221,7 @@ mkdir "$rbdir/rocks/apps", 0777; mkdir "$rbdir/rocks/demos", 0777; mkdir "$rbdir/rocks/viewers", 0777; + mkdir "$rbdir/pebbles", 0777; if ($recording) { mkdir "$rbdir/recpresets", 0777; @@ -275,6 +276,7 @@ } find(find_copyfile(qr/\.(rock|ovl|lua)/, abs_path("$rbdir/rocks/")), 'apps/plugins'); + find(find_copyfile(qr/\.(pebble)/, abs_path("$rbdir/pebbles/")), 'apps/pebbles'); open VIEWERS, "$ROOT/apps/plugins/viewers.config" or die "can't open viewers.config"; Index: tools/root.make =================================================================== --- tools/root.make (revision 24701) +++ tools/root.make (working copy) @@ -82,6 +82,9 @@ include $(APPSDIR)/plugins/plugins.make endif + include $(APPSDIR)/pebbles/pebbles.make + + ifdef SIMVER include $(ROOTDIR)/uisimulator/uisimulator.make endif @@ -92,7 +95,7 @@ OBJ += $(BMP:.bmp=.o) OBJ := $(subst $(ROOTDIR),$(BUILDDIR),$(OBJ)) -build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(ARCHOSROM) $(RBINFO) +build: $(TOOLS) $(BUILDDIR)/$(BINARY) $(CODECS) $(ROCKS) $(PEBBLES) $(ARCHOSROM) $(RBINFO) $(RBINFO): $(BUILDDIR)/$(BINARY) $(SILENT)echo Creating $(@F) Index: apps/pebble.h =================================================================== --- apps/pebble.h (revision 0) +++ apps/pebble.h (revision 0) @@ -0,0 +1,35 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2010 Frank Gevaerts + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "viewport.h" + +struct plugin_api; +#define NUM_PEBBLES 4 + +struct pebble +{ + int (*run)(bool init,bool exit,char *line,struct viewport *vp,char *blob,struct plugin_api *rb); +}; + +int pebble_load(const char* pebble); +void pebble_run(unsigned short index); + +int pebble_do(bool init,bool exit,char *line,struct viewport *vp,char *blob,struct plugin_api *rb); Index: apps/gui/skin_engine/skin_parser.c =================================================================== --- apps/gui/skin_engine/skin_parser.c (revision 24701) +++ apps/gui/skin_engine/skin_parser.c (working copy) @@ -27,6 +27,7 @@ #include "misc.h" #include "plugin.h" #include "viewport.h" +#include "pebble.h" #ifdef __PCTOOL__ #ifdef WPSEDITOR @@ -143,6 +144,8 @@ return 0; } +static int parse_pebble(const char *wps_bufptr, + struct wps_token *token, struct wps_data *wps_data); #ifdef HAVE_LCD_BITMAP static int parse_viewport_display(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data); @@ -379,6 +382,8 @@ { WPS_TOKEN_TRANSLATEDSTRING, "Sx", WPS_REFRESH_STATIC, parse_setting_and_lang }, { WPS_TOKEN_LANG_IS_RTL , "Sr", WPS_REFRESH_STATIC, NULL }, + + { WPS_TOKEN_PEBBLE , "P", WPS_REFRESH_DYNAMIC, parse_pebble }, { WPS_TOKEN_LASTTOUCH, "Tl", WPS_REFRESH_DYNAMIC, parse_timeout }, { WPS_TOKEN_CURRENT_SCREEN, "cs", WPS_REFRESH_DYNAMIC, NULL }, @@ -531,6 +536,17 @@ return true; } +static int parse_pebble(const char *wps_bufptr, + struct wps_token *token, + struct wps_data *wps_data) +{ + (void)token; /* Kill warnings */ + short index=pebble_load("/.rockbox/pebbles/test_pebble.pebble"); + if(index>0) + token->value.i = index; + return skip_end_of_line(wps_bufptr); +} + #ifdef HAVE_LCD_BITMAP static int parse_statusbar_enable(const char *wps_bufptr, Index: apps/gui/skin_engine/skin_display.c =================================================================== --- apps/gui/skin_engine/skin_display.c (revision 24701) +++ apps/gui/skin_engine/skin_display.c (working copy) @@ -37,6 +37,7 @@ #include "screen_access.h" #include "playlist.h" #include "audio.h" +#include "pebble.h" #ifdef HAVE_LCD_BITMAP #include "peakmeter.h" @@ -80,6 +81,11 @@ return retval; } +static void draw_pebble(unsigned short pebble) +{ + pebble_run(pebble); +} + #ifdef HAVE_LCD_BITMAP void skin_statusbar_changed(struct gui_wps *skin) @@ -266,7 +272,6 @@ } } - /* clears the area where the image was shown */ static void clear_image_pos(struct gui_wps *gwps, struct gui_img *img) { @@ -703,6 +708,9 @@ draw_playlist_viewer_list(gwps, data->tokens[i].value.data); break; #endif + case WPS_TOKEN_PEBBLE: + draw_pebble(data->tokens[i].value.i); + break; default: { /* get the value of the tag and copy it to the buffer */ Index: apps/gui/skin_engine/skin_tokens.h =================================================================== --- apps/gui/skin_engine/skin_tokens.h (revision 24701) +++ apps/gui/skin_engine/skin_tokens.h (working copy) @@ -207,6 +207,8 @@ WPS_TOKEN_SETTING, WPS_TOKEN_CURRENT_SCREEN, WPS_TOKEN_LANG_IS_RTL, + + WPS_TOKEN_PEBBLE, /* Recording Tokens */ TOKEN_MARKER_RECORDING, Index: apps/pebbles/SOURCES =================================================================== --- apps/pebbles/SOURCES (revision 0) +++ apps/pebbles/SOURCES (revision 0) @@ -0,0 +1 @@ +test_pebble.c Index: apps/pebbles/pebbles.make =================================================================== --- apps/pebbles/pebbles.make (revision 0) +++ apps/pebbles/pebbles.make (revision 0) @@ -0,0 +1,61 @@ +# __________ __ ___. +# Open \______ \ ____ ____ | | _\_ |__ _______ ___ +# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / +# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < +# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ +# \/ \/ \/ \/ \/ +# $Id: pebbles.make 24322 2010-01-24 15:32:23Z funman $ +# + +# single-file pebbles: +PEBBLES_SRC = $(call preprocess, $(APPSDIR)/pebbles/SOURCES) +OTHER_SRC += $(PEBBLES_SRC) +PEBBLES1 := $(PEBBLES_SRC:.c=.pebble) +PEBBLES1 := $(subst $(ROOTDIR),$(BUILDDIR),$(PEBBLES1)) + +PEBBLES := $(PEBBLES1) + +### build data / rules +ifndef SIMVER +CONFIGFILE := $(FIRMDIR)/export/config/$(MODELNAME).h +PEBBLE_LDS := $(APPSDIR)/pebbles/pebble.lds +PEBBLELINK_LDS := $(BUILDDIR)/apps/pebbles/pebble.link +endif + +OTHER_INC += -I$(APPSDIR)/pebbles + +# special compile flags for pebbles: +PEBBLEFLAGS = -I$(APPSDIR)/pebbles -DPEBBLE -fPIC $(CFLAGS) + +# single-file pebbles depend on their respective .o +$(PEBBLES1): $(BUILDDIR)/%.pebble : $(BUILDDIR)/%.o + +# dependency for all pebbles +$(PEBBLES): $(APPSDIR)/pebble.h $(PEBBLELINK_LDS) + +$(PEBBLELINK_LDS): $(PEBBLE_LDS) $(CONFIGFILE) + $(call PRINTS,PP $(@F)) + $(shell mkdir -p $(dir $@)) + $(call preprocess2file,$<,$@,-DLOADADDRESS=$(LOADADDRESS)) + +# special pattern rule for compiling pebbles with extra flags +$(BUILDDIR)/apps/pebbles/%.o: $(ROOTDIR)/apps/pebbles/%.c + $(SILENT)mkdir -p $(dir $@) + $(call PRINTS,CC $(subst $(ROOTDIR)/,,$<))$(CC) -I$(dir $<) $(PEBBLEFLAGS) -c $< -o $@ + +ifdef SIMVER + PEBBLELDFLAGS = $(SHARED_FLAG) # <-- from Makefile +else + PEBBLELDFLAGS = -T$(PEBBLELINK_LDS) -Wl,--gc-sections -Wl,-Map,$*.map +endif + +$(BUILDDIR)/%.pebble: + $(call PRINTS,LD $(@F))$(CC) $(PEBBLEFLAGS) -o $(BUILDDIR)/$*.elf \ + $(filter %.o, $^) \ + $(filter %.a, $+) \ + -lgcc $(PEBBLELDFLAGS) +ifdef SIMVER + $(SILENT)cp $(BUILDDIR)/$*.elf $@ +else + $(SILENT)$(OC) -O binary $(BUILDDIR)/$*.elf $@ +endif Index: apps/pebbles/test_pebble.c =================================================================== --- apps/pebbles/test_pebble.c (revision 0) +++ apps/pebbles/test_pebble.c (revision 0) @@ -0,0 +1,41 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: $ + * + * Copyright (C) 2010 Frank Gevaerts + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ + +#include "pebble.h" +#include "plugin.h" + +int pebble_do(bool init,bool exit,char *line,struct viewport *vp,char *blob,struct plugin_api *rb) +{ + const signed char sine_table[] = {0, 10, 20, 30, 40, 49, 58, 66, 74, 80, 86, 91, 95, 97, 99, 100, 99, 97, 95, 91, 86, 80, 74, 66, 58, 49, 40, 30, 20, 10, 0, -10, -20, -30, -40, -50, -58, -66, -74, -80, -86, -91, -95, -97, -99, -100, -99, -97, -95, -91, -86, -80, -74, -66, -58, -50, -40, -30, -20, -10}; + + struct tm *t=rb->get_time(); + + rb->lcd_set_foreground(0); + rb->lcd_fillrect(0,10,60,60); + rb->lcd_set_foreground(0xffffffff); + rb->lcd_drawrect(0,10,60,60); + + rb->lcd_drawline(30,40,30+sine_table[t->tm_sec]/4, 40-sine_table[(t->tm_sec+15)%60]/4); + rb->lcd_drawline(30,40,30+sine_table[t->tm_min]/4, 40-sine_table[(t->tm_min+15)%60]/4); + rb->lcd_drawline(30,40,30+sine_table[t->tm_hour*5/2+t->tm_min/12]/5,40-sine_table[(t->tm_hour*5/2+t->tm_min/12+15)%60]/5); + + return 0; +} Index: apps/pebbles/pebble.lds =================================================================== --- apps/pebbles/pebble.lds (revision 0) +++ apps/pebbles/pebble.lds (revision 0) @@ -0,0 +1,56 @@ +#include "config.h" + +/* These output formats should be in the config-files */ + +#ifdef CPU_COLDFIRE +OUTPUT_FORMAT(elf32-m68k) +ENTRY(pebble_do) +#elif defined(CPU_ARM) +OUTPUT_FORMAT(elf32-littlearm) +ENTRY(pebble_do) +#elif defined(CPU_SH) +OUTPUT_FORMAT(elf32-sh) +ENTRY(_pebble_do) +#elif defined(CPU_MIPS) +OUTPUT_FORMAT(elf32-littlemips) +ENTRY(pebble_do) +#else +/* We can have an #error here we don't use this file when build sims! */ +#error Unknown CPU architecture +#endif + +#define THIS_ORIGIN 0xDEAD0000 +#define THIS_LENGTH 1000 + + + +MEMORY +{ + PEBBLE_RAM : ORIGIN = THIS_ORIGIN, LENGTH = THIS_LENGTH +} + +SECTIONS +{ + .text : + { + *(.got) + *(.text*) + . = ALIGN(0x4); + *(.rodata*) + . = ALIGN(0x4); +#ifdef CPU_ARM + *(.glue_7) + *(.glue_7t) +#endif + *(.got.plt) + + } > PEBBLE_RAM + + /DISCARD/ : + { + *(.eh_frame) +#ifdef CPU_MIPS + *(.rel.dyn) +#endif + } +} Index: apps/plugin.c =================================================================== --- apps/plugin.c (revision 24701) +++ apps/plugin.c (working copy) @@ -99,7 +99,7 @@ static int creat_wrapper(const char *pathname); #endif -static const struct plugin_api rockbox_api = { +const struct plugin_api rockbox_api = { /* lcd */ #ifdef HAVE_LCD_CONTRAST Index: apps/SOURCES =================================================================== --- apps/SOURCES (revision 24701) +++ apps/SOURCES (working copy) @@ -39,6 +39,7 @@ playlist_catalog.c playlist_viewer.c plugin.c +pebble.c root_menu.c screens.c settings.c Index: apps/pebble.c =================================================================== --- apps/pebble.c (revision 0) +++ apps/pebble.c (revision 0) @@ -0,0 +1,100 @@ +/*************************************************************************** + * __________ __ ___. + * Open \______ \ ____ ____ | | _\_ |__ _______ ___ + * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / + * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < + * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ + * \/ \/ \/ \/ \/ + * $Id: plugin.c 24644 2010-02-14 06:26:16Z jdgordon $ + * + * Copyright (C) 2002 Björn Stenberg + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ****************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#include "config.h" +#include "pebble.h" +#include "plugin.h" +#include "lang.h" +#include "splash.h" +#include "logf.h" +#include "skin_engine/skin_buffer.h" +#include "settings.h" + + +struct pebble pebbles[NUM_PEBBLES]; +int last_plugin=0; +extern struct plugin_api rockbox_api; + +int pebble_load(const char* pebble) +{ + int fd; + ssize_t readsize; +#if NUM_CORES > 1 + unsigned my_core; +#endif + + splash(0, ID2P(LANG_WAIT)); + + int max_size=1000; + int *buffer=skin_buffer_alloc(max_size); + + fd = open(pebble, O_RDONLY); + if (fd < 0) { + splashf(HZ*2, str(LANG_PLUGIN_CANT_OPEN), pebble); + return fd; + } +#if NUM_CORES > 1 + /* Make sure COP cache is flushed and invalidated before loading */ + my_core = switch_core(CURRENT_CORE ^ 1); + cpucache_invalidate(); + switch_core(my_core); +#endif + + readsize = read(fd, buffer, max_size); + close(fd); + + if (readsize < 0) { + splashf(HZ*2, str(LANG_READ_FAILED), pebble); + return -1; + } + if (readsize == max_size) { + /* Suspicious. FIXME: This should be handled better */ + splashf(HZ*2, str(LANG_READ_FAILED), pebble); + return -1; + } + + /* Fix GOT */ + + buffer[0]-=(0xdead0000-((int)buffer)); + //FIXME: increment last_plugin + pebbles[last_plugin].run=&buffer[1]; + + /* FIXME: put back header and version checks? */ + + cpucache_invalidate(); + return (last_plugin); +} + + +void pebble_run(unsigned short index) +{ + pebbles[index].run(false,false,NULL,NULL,NULL,&rockbox_api); +}