diff --git a/Makefile b/Makefile index b6a39c1d0..eca0f18c2 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ ########################################################### TARGET=Telmi Story Teller -VERSION=0.2.1 +VERSION=0.2.2 ########################################################### diff --git a/README.md b/README.md index b8826baa4..639ee757c 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,9 @@ The story teller is compatible with stories exported from STUdio (v1 format). ### Download the installation files -You need to install Telmi v0.2.1. +You need to install Telmi v0.2.2. -- [Download the latest version of Telmi](https://github.com/DantSu/Telmi-story-teller/releases/download/0.2.1/TelmiOS_v0.2.1.zip) +- [Download the latest version of Telmi](https://github.com/DantSu/Telmi-story-teller/releases/download/0.2.2/TelmiOS_v0.2.2.zip) ### Install or upgrade diff --git a/src/bootScreen/bootScreen.c b/src/bootScreen/bootScreen.c index 2cd438e45..d7304a728 100644 --- a/src/bootScreen/bootScreen.c +++ b/src/bootScreen/bootScreen.c @@ -96,8 +96,6 @@ int main(int argc, char *argv[]) sleep(4); // for debugging purposes #endif - sleep(1); - SDL_FreeSurface(screen); SDL_FreeSurface(video); SDL_Quit(); diff --git a/src/storyTeller/app_selector.h b/src/storyTeller/app_selector.h index f0225ea09..dd918a2d2 100644 --- a/src/storyTeller/app_selector.h +++ b/src/storyTeller/app_selector.h @@ -14,7 +14,7 @@ #define SYSTEM_RESOURCES "/mnt/SDCARD/.tmp_update/res/" -static const char appImages[2][32] = {"selectStories.png", "selectMusic.png"}; +static char appImages[2][32] = {"selectStories.png", "selectMusic.png"}; static int appIndex = 0; static bool appOpened = false; diff --git a/src/storyTeller/music_player.h b/src/storyTeller/music_player.h index f0195c8b8..aedd65d07 100644 --- a/src/storyTeller/music_player.h +++ b/src/storyTeller/music_player.h @@ -87,7 +87,7 @@ bool musicplayer_home(void) bool musicplayer_isMp3File(const char *fileName) { - return strcmp((char *)fileName + strlen(fileName) - 4, ".mp3") == 0; + return strcmp((char *)fileName + strlen(fileName) - 4, ".mp3") == 0 || strcmp((char *)fileName + strlen(fileName) - 4, ".MP3") == 0; } void musicplayer_init(void) diff --git a/src/storyTeller/sdl_helper.h b/src/storyTeller/sdl_helper.h index 631f57dee..6eba16f1a 100644 --- a/src/storyTeller/sdl_helper.h +++ b/src/storyTeller/sdl_helper.h @@ -18,9 +18,24 @@ static TTF_Font *font; static SDL_Color color = {255, 255, 255}; static int fontPosition = 0; + +void font_write(const char *text) +{ + SDL_Surface *sdlText = TTF_RenderUTF8_Blended(font, text, color); + if (sdlText) { + fontPosition += 16; + SDL_BlitSurface(sdlText, NULL, screen, &(SDL_Rect){20, fontPosition}); + SDL_FreeSurface(sdlText); + SDL_BlitSurface(screen, NULL, video, NULL); + SDL_Flip(video); + } +} + + void video_audio_init(void) { SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); + IMG_Init(IMG_INIT_PNG); TTF_Init(); if(Mix_OpenAudio(44000, 32784, 2, 2048) < 0) { Mix_Volume(-1, MIX_MAX_VOLUME); @@ -28,7 +43,7 @@ void video_audio_init(void) } video = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); screen = SDL_CreateRGBSurface(SDL_HWSURFACE, 640, 480, 32, 0, 0, 0, 0); - font = TTF_OpenFont(FALLBACK_FONT, 18); + font = TTF_OpenFont(FALLBACK_FONT, 14); } @@ -47,8 +62,25 @@ void video_audio_quit(void) SDL_Quit(); } -void video_displayImage(const char *dir, const char *name) +void video_checkFilename(char *filename) { + int length = strlen(filename); + if(strcmp((char *)filename + length - 4, ".jpg") == 0 || strcmp((char *)filename + length - 4, ".JPG") == 0) { + filename[length - 3] = 'p'; + filename[length - 2] = 'n'; + filename[length - 1] = 'g'; + } else if (strcmp((char *)filename + length - 5, ".jpeg") == 0 || strcmp((char *)filename + length - 5, ".JPEG") == 0) { + filename[length - 4] = 'p'; + filename[length - 3] = 'n'; + filename[length - 2] = 'g'; + filename[length - 1] = '\0'; + } +} + +void video_displayImage(const char *dir, char *name) +{ + video_checkFilename(name); + char image_path[STR_MAX * 2]; sprintf(image_path, "%s%s", dir, name); SDL_Surface *image = IMG_Load(image_path); @@ -79,17 +111,4 @@ void audio_play(const char *dir, const char *name) { } -void font_write(const char *text) -{ - SDL_Surface *sdlText = TTF_RenderUTF8_Blended(font, text, color); - if (sdlText) { - fontPosition += 20; - SDL_BlitSurface(sdlText, NULL, screen, &(SDL_Rect){20, fontPosition}); - SDL_FreeSurface(sdlText); - SDL_BlitSurface(screen, NULL, video, NULL); - SDL_Flip(video); - } -} - - #endif // STORYTELLER_SDL_HELPER__ \ No newline at end of file diff --git a/src/storyTeller/stories_reader.h b/src/storyTeller/stories_reader.h index 8a8f16aa6..337539477 100644 --- a/src/storyTeller/stories_reader.h +++ b/src/storyTeller/stories_reader.h @@ -146,7 +146,7 @@ void stories_load(void) } else if (storyIndex >= storiesCount) { storyIndex = 0; } - + char story_path[STR_MAX]; sprintf(story_path, "%s%s/story.json", STORIES_RESOURCES, storiesList[storyIndex]); @@ -154,7 +154,7 @@ void stories_load(void) if(storyJson == NULL) { return; } - + stories_readStage(); } diff --git a/static/build/.tmp_update/runtime.sh b/static/build/.tmp_update/runtime.sh index bb5d7b1b5..f5143a57e 100644 --- a/static/build/.tmp_update/runtime.sh +++ b/static/build/.tmp_update/runtime.sh @@ -47,22 +47,14 @@ main() { cd $sysdir bootScreen "Boot" - # Start the key monitor - # keymon & - # Init rm /tmp/.offOrder 2> /dev/null HOME=/mnt/SDCARD/StoryTeller/ - - # Detect if MENU button is held - # detectKey 1 - # menu_pressed=$? - - # if [ $menu_pressed -eq 0 ]; then - # rm -f "$sysdir/cmd_to_run.sh" 2> /dev/null - # fi + + storyteller_jpg2png # start_networking + sleep 1 rm -rf /tmp/is_booting launch_storyteller @@ -71,6 +63,22 @@ main() { done } +storyteller_jpg2png() { + for directory in /mnt/SDCARD/Stories/*; do + if [ ! -d "$directory" ]; then + continue + fi + + for file in "$directory"/assets/*.jpg "$directory"/assets/*.jpeg "$directory"/assets/*.JPG "$directory"/assets/*.JPEG; do + if [ ! -f "$file" ]; then + continue + fi + jpg2png "$file" + rm -f "$file" 2> /dev/null + done + done +} + set_prev_state() { echo "$1" > /tmp/prev_state }