Index: apps/gui/gwps-common.c =================================================================== --- apps/gui/gwps-common.c (revision 19589) +++ apps/gui/gwps-common.c (working copy) @@ -1649,6 +1649,51 @@ } } 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/num->char_count; + int cell = 0, j, chars_drawn = 0; + const char *value = get_token_value(gwps, &data->tokens[i+1], + temp_buf, sizeof(temp_buf), NULL); + if (value) + { + j=strlen(value); + if (j > num->max_chars) + j = num->max_chars; + j--; + while (j>=0) + { + cell = -1; + if (value[j] >= '0' && value[j] <= '9') + cell = value[j] - '0'; + else + { + int k = 0; + while (num->extrachars[k] && k<8 && cell == -1) + { + if (num->extrachars[k] == value[j]) + cell = 10 + k; + k++; + } + } + if (cell >= 0) + { + chars_drawn++; + gwps->display->bitmap_part(bmp->bm.data, 0, char_h*cell, + char_w, num->x+((num->max_chars-chars_drawn)*char_w), + num->y, char_w, char_h); + } + j--; + } + if (num->max_chars-chars_drawn) + screen_clear_area(gwps->display, num->x, num->y, char_w*(num->max_chars-chars_drawn), char_h); + gwps->display->update_viewport_rect(num->x, num->y, char_w*num->max_chars, char_h); + 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 19589) +++ 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/gwps.h =================================================================== --- apps/gui/gwps.h (revision 19589) +++ 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,15 @@ char hidden_flags; char label; }; - +#define MAX_BMP_NUMBERS 5 +struct bmp_number { + int img_id; + short x; + short y; + short char_count; + short max_chars; + char extrachars[8]; +}; /* wps_data this struct holds all necessary data which describes the viewable content of a wps */ @@ -374,6 +383,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 */ Index: apps/gui/wps_parser.c =================================================================== --- apps/gui/wps_parser.c (revision 19589) +++ 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,54 @@ } } +static int parse_image_display_number(const char *wps_bufptr, + struct wps_token *token, + struct wps_data *wps_data) +{ + /* format: %dn|n|m|x|y|abc + where: + n is the bmp strip number/letter to use. + m is the max number of chars to draw (Always drawn right justified + x is the x pixel to start drawing at (viewport relative) + y is the y pixel to start drawing at (viewport relative) + abc is up to 7 extra chars in the order they appear at the end of the bmp strip + 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, *extrachars; + int i, count; + 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("sddds", NULL, '|', ptr, &id, &number->max_chars, &number->x, &number->y, &extrachars))) + 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; + strncpy(number->extrachars, extrachars, 8); + i = 0; count = 10; + while (number->extrachars[i] && i<8) + { + if (number->extrachars[i] == '|') + { + number->extrachars[i] = '\0'; + break; + } + i++; + } + count += i; + number->char_count = count; + 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 +1528,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++)