Index: apps/gui/gwps-common.c =================================================================== --- apps/gui/gwps-common.c (revision 19523) +++ apps/gui/gwps-common.c (working copy) @@ -1649,6 +1649,39 @@ } } break; + case WPS_TOKEN_IMAGE_DISPLAY_NUMBER: + { + struct bmp_number *num = &data->bmp_numbers[data->tokens[i].value.i]; + struct gui_img *bmp = &data->img[num->img_id]; + int char_w = bmp->bm.width, char_h = bmp->bm.height/10; + int intvalue = -1, j, chars_drawn = 0; + const char *value = get_token_value(gwps, &data->tokens[i+1], + temp_buf, sizeof(temp_buf), &intvalue); + if (intvalue >= 0) + { + snprintf(temp_buf, sizeof(temp_buf), "%d", intvalue); + value = temp_buf; + } + if (value) /* get it from the string */ + { + j=0; + while (value[j]) + { + if (value[j] < '0' || value[j] > '9') + break; + intvalue = value[j] - '0'; + gwps->display->bitmap_part(bmp->bm.data, 0, char_h*intvalue, + char_w, num->x+(chars_drawn*char_w), + num->y, char_w, char_h); + chars_drawn++; + j++; + } + gwps->display->update_viewport_rect(num->x, num->y, char_w*chars_drawn, char_h); + // update = true; + i++; /* skip the next token */ + } + } + break; default: { /* get the value of the tag and copy it to the buffer */ Index: apps/gui/wps_debug.c =================================================================== --- apps/gui/wps_debug.c (revision 19523) +++ apps/gui/wps_debug.c (working copy) @@ -119,6 +119,9 @@ case WPS_TOKEN_IMAGE_DISPLAY: snprintf(buf, bufsize, "display image"); break; + case WPS_TOKEN_IMAGE_DISPLAY_NUMBER: + snprintf(buf, bufsize, "display number as image"); + break; #endif #ifdef HAS_BUTTON_HOLD Index: apps/gui/wps_parser.c =================================================================== --- apps/gui/wps_parser.c (revision 19523) +++ apps/gui/wps_parser.c (working copy) @@ -152,6 +152,8 @@ struct wps_token *token, struct wps_data *wps_data); static int parse_image_display(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data); +static int parse_image_display_number(const char *wps_bufptr, + struct wps_token *token, struct wps_data *wps_data); static int parse_image_load(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data); #endif /*HAVE_LCD_BITMAP */ @@ -328,6 +330,8 @@ { WPS_TOKEN_IMAGE_PRELOAD_DISPLAY, "xd", WPS_REFRESH_STATIC, parse_image_display }, + { WPS_TOKEN_IMAGE_DISPLAY_NUMBER, "xn", WPS_REFRESH_DYNAMIC, + parse_image_display_number }, { WPS_TOKEN_IMAGE_DISPLAY, "x", 0, parse_image_load }, #ifdef HAVE_ALBUMART @@ -493,6 +497,38 @@ } } +static int parse_image_display_number(const char *wps_bufptr, + struct wps_token *token, + struct wps_data *wps_data) +{ + /* format: %dn|n|x|y| + where: + n is the bmp strip number/letter to use. + x is the x pixel to start drawing at (viewport relative) + y is the y pixel to start drawing at (viewport relative) + The next tag MUST be one which returns a number + either as a string or in its intval */ + const char *ptr = wps_bufptr; + const char* id; + struct bmp_number *number = &wps_data->bmp_numbers[wps_data->bmp_numbers_count]; + + if (*ptr != '|') + return WPS_ERROR_INVALID_PARAM; + ptr++; + if (!(ptr = parse_list("sdd", NULL, '|', ptr, &id, &number->x, &number->y))) + return WPS_ERROR_INVALID_PARAM; + /* Check there is a terminating | */ + if (*ptr != '|') + return WPS_ERROR_INVALID_PARAM; + /* get the image ID */ + number->img_id = get_image_id(*id); + if (number->img_id < 0) + return WPS_ERROR_INVALID_PARAM; + token->value.i = wps_data->bmp_numbers_count; + wps_data->bmp_numbers_count++; + return ptr-wps_bufptr+1; +} + static int parse_image_load(const char *wps_bufptr, struct wps_token *token, struct wps_data *wps_data) @@ -1476,6 +1512,8 @@ wps_data->peak_meter_enabled = false; /* progress bars */ wps_data->progressbar_count = 0; + + wps_data->bmp_numbers_count = 0; #else /* HAVE_LCD_CHARCELLS */ int i; for (i = 0; i < 8; i++) Index: apps/gui/gwps.h =================================================================== --- apps/gui/gwps.h (revision 19523) +++ apps/gui/gwps.h (working copy) @@ -223,6 +223,7 @@ WPS_TOKEN_IMAGE_PRELOAD, WPS_TOKEN_IMAGE_PRELOAD_DISPLAY, WPS_TOKEN_IMAGE_DISPLAY, + WPS_TOKEN_IMAGE_DISPLAY_NUMBER, #endif #ifdef HAVE_ALBUMART @@ -356,7 +357,12 @@ char hidden_flags; char label; }; - +#define MAX_BMP_NUMBERS 5 +struct bmp_number { + int img_id; + short x; + short y; +}; /* wps_data this struct holds all necessary data which describes the viewable content of a wps */ @@ -374,6 +380,9 @@ short progressbar_count; bool peak_meter_enabled; + + struct bmp_number bmp_numbers[MAX_BMP_NUMBERS]; + int bmp_numbers_count; #ifdef HAVE_ALBUMART /* Album art support */