--- apps/gui/gwps.patched.h 2007-06-22 14:37:22.039605700 -0400 +++ apps/gui/gwps.h 2007-06-26 12:53:18.620156800 -0400 @@ -172,6 +172,14 @@ WPS_TOKEN_IMAGE_PRELOAD, WPS_TOKEN_IMAGE_PRELOAD_DISPLAY, WPS_TOKEN_IMAGE_DISPLAY, + WPS_TOKEN_IMAGE_ANIMATE, + WPS_TOKEN_IMAGE_ENUM_BATTERY, + WPS_TOKEN_IMAGE_ENUM_CODEC, + WPS_TOKEN_IMAGE_ENUM_HOLD, + WPS_TOKEN_IMAGE_ENUM_PLAYBACK, + WPS_TOKEN_IMAGE_ENUM_REPEAT, + WPS_TOKEN_IMAGE_ENUM_SHUFFLE, + WPS_TOKEN_IMAGE_ENUM_VOLUME, #endif /* Metadata */ --- apps/gui/gwps-common.patched.c 2007-06-22 14:37:22.023980900 -0400 +++ apps/gui/gwps-common.c 2007-06-26 12:53:17.526406800 -0400 @@ -765,6 +765,7 @@ playlist_get_display_index()); return buf; + case WPS_TOKEN_IMAGE_ENUM_SHUFFLE: case WPS_TOKEN_PLAYLIST_SHUFFLE: if ( global_settings.playlist_shuffle ) return "s"; @@ -772,6 +773,7 @@ return NULL; break; + case WPS_TOKEN_IMAGE_ENUM_VOLUME: case WPS_TOKEN_VOLUME: snprintf(buf, buf_size, "%d", global_settings.volume); if (intval) @@ -868,6 +870,7 @@ snprintf(buf, buf_size, "?"); return buf; + case WPS_TOKEN_IMAGE_ENUM_CODEC: case WPS_TOKEN_FILE_CODEC: if (intval) { @@ -921,6 +924,7 @@ case WPS_TOKEN_FILE_DIRECTORY: return get_dir(buf, buf_size, id3->path, token->value.i); + case WPS_TOKEN_IMAGE_ENUM_BATTERY: case WPS_TOKEN_BATTERY_PERCENT: { int l = battery_level(); @@ -991,6 +995,7 @@ } } + case WPS_TOKEN_IMAGE_ENUM_PLAYBACK: case WPS_TOKEN_PLAYBACK_STATUS: { int status = audio_status(); @@ -1014,6 +1019,7 @@ return buf; } + case WPS_TOKEN_IMAGE_ENUM_REPEAT: case WPS_TOKEN_REPEAT_MODE: if (intval) *intval = global_settings.repeat_mode + 1; @@ -1245,6 +1251,20 @@ #endif #ifdef HAS_BUTTON_HOLD + case WPS_TOKEN_IMAGE_ENUM_HOLD: + *intval = 1; + if (button_hold()) + *intval = 2; + +#ifdef HAS_REMOTE_BUTTON_HOLD + if (remote_button_hold()) + if (*intval == 2) + *intval = 3; + else + *intval = 4; +#endif + return NULL; + case WPS_TOKEN_MAIN_HOLD: if (button_hold()) return "h"; @@ -1355,6 +1375,7 @@ char *linebuf_end = linebuf + linebuf_size - 1; int i, last_token_idx; bool update = false; + char *value; /* alignment-related variables */ int cur_align; @@ -1386,11 +1407,65 @@ #ifdef HAVE_LCD_BITMAP case WPS_TOKEN_IMAGE_PRELOAD_DISPLAY: + case WPS_TOKEN_IMAGE_ANIMATE: + case WPS_TOKEN_IMAGE_ENUM_BATTERY: + case WPS_TOKEN_IMAGE_ENUM_CODEC: + case WPS_TOKEN_IMAGE_ENUM_HOLD: + case WPS_TOKEN_IMAGE_ENUM_PLAYBACK: + case WPS_TOKEN_IMAGE_ENUM_REPEAT: + case WPS_TOKEN_IMAGE_ENUM_SHUFFLE: + case WPS_TOKEN_IMAGE_ENUM_VOLUME: { struct gui_img *img = data->img; int n = data->tokens[i].value.i; + int intval = img[n].nb_subimg; + if (n >= 0 && n < MAX_IMAGES && img[n].loaded) + { + /* If there are subimages, get the conditional value */ + if (img[n].nb_subimg > 1) + { + if (data->tokens[i].type == WPS_TOKEN_IMAGE_ANIMATE) + { + if (TIME_AFTER(current_tick, img[n].subimg_expire_time - 1)) + { + img[n].subimg_expire_time = current_tick + + BASE_SUBLINE_TIME*img[n].subimg_timeout; + img[n].subimg_index++; + if (img[n].subimg_index == img[n].nb_subimg) + img[n].subimg_index = 0; + } + } + else + { + value = get_token_value(gwps, &data->tokens[i], + temp_buf, sizeof(temp_buf), &intval); + + if (intval == -1) + { + /* No intval set, these are on/off cases. + Use the first (off) or last (on) image */ + intval = (value && *value) ? img[n].nb_subimg : 1; + } + else if (intval == 0) + { + /* default to first image */ + intval = 1; + } + else if (intval > img[n].nb_subimg) + { + /* default to last image */ + intval = img[n].nb_subimg; + } + + /* intval counts from one, but subimg_index needs + to start at zero */ + img[n].subimg_index = intval - 1; + } + } + img[n].display = true; + } break; } #endif @@ -1435,7 +1510,7 @@ default: { /* get the value of the tag and copy it to the buffer */ - char *value = get_token_value(gwps, &data->tokens[i], + value = get_token_value(gwps, &data->tokens[i], temp_buf, sizeof(temp_buf), NULL); if (value) { --- apps/gui/wps_parser.patched.c 2007-06-22 14:37:22.039605700 -0400 +++ apps/gui/wps_parser.c 2007-06-26 12:53:18.260781800 -0400 @@ -274,8 +274,26 @@ { WPS_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", WPS_REFRESH_STATIC, parse_image_display }, + { WPS_TOKEN_IMAGE_ANIMATE, "xa", WPS_REFRESH_DYNAMIC, + parse_image_display }, + { WPS_TOKEN_IMAGE_ENUM_BATTERY, "xb", WPS_REFRESH_DYNAMIC, + parse_image_display }, + { WPS_TOKEN_IMAGE_ENUM_CODEC, "xc", WPS_REFRESH_DYNAMIC, + parse_image_display }, + { WPS_TOKEN_IMAGE_ENUM_HOLD, "xh", WPS_REFRESH_DYNAMIC, + parse_image_display }, + { WPS_TOKEN_IMAGE_ENUM_PLAYBACK, "xp", WPS_REFRESH_DYNAMIC, + parse_image_display }, + { WPS_TOKEN_IMAGE_ENUM_REPEAT, "xr", WPS_REFRESH_DYNAMIC, + parse_image_display }, + { WPS_TOKEN_IMAGE_ENUM_SHUFFLE, "xs", WPS_REFRESH_DYNAMIC, + parse_image_display }, + { WPS_TOKEN_IMAGE_ENUM_VOLUME, "xv", WPS_REFRESH_DYNAMIC, + parse_image_display }, + { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, { WPS_TOKEN_IMAGE_PROGRESS_BAR, "P", 0, parse_image_special }, + #if (LCD_DEPTH > 1) || (defined(HAVE_LCD_REMOTE) && (LCD_REMOTE_DEPTH > 1)) { WPS_TOKEN_IMAGE_BACKDROP, "X", 0, parse_image_special }, #endif @@ -361,13 +379,14 @@ struct wps_token *token, struct wps_data *wps_data) { + int ret = 0; int n = get_image_id(*wps_bufptr); if (n == -1) { /* invalid picture display tag */ token->type = WPS_TOKEN_UNKNOWN; - return 0; + return ret; } token->value.i = n; @@ -376,7 +395,19 @@ if (level >= 0) wps_data->img[n].cond_index = condindex[level]; - return 1; + if (token->type == WPS_TOKEN_IMAGE_ANIMATE) + { + /* Animated image sets can be followed by a timeout time */ + ret = parse_subline_timeout(wps_bufptr + 1, token, wps_data); + if (ret > 0) + wps_data->img[n].subimg_timeout = token->value.i; + else + wps_data->img[n].subimg_timeout = BASE_SUBLINE_TIME; + + token->value.i = n; + } + + return ret + 1; } static int parse_image_load(const char *wps_bufptr, @@ -388,7 +419,7 @@ char *pos = NULL; /* format: %x|n|filename.bmp|x|y| - or %xl|n|filename.bmp|x|y| */ + or %xl|n|filename.bmp|x|y|nb_subimg| */ ptr = strchr(ptr, '|') + 1; pos = strchr(ptr, '|'); @@ -436,7 +467,17 @@ } if (token->type == WPS_TOKEN_IMAGE_DISPLAY) + { wps_data->img[n].always_display = true; + } + else + { + /* check for number of sub images (optional) */ + ptr = pos + 1; + pos = strchr(ptr, '|'); + if (pos) + wps_data->img[n].nb_subimg = atoi(ptr); + } /* Skip the rest of the line */ return skip_end_of_line(wps_bufptr);