diff --git a/apps/gui/skin_engine/skin_parser.c b/apps/gui/skin_engine/skin_parser.c index c5acd1fd75..94953f098e 100644 --- a/apps/gui/skin_engine/skin_parser.c +++ b/apps/gui/skin_engine/skin_parser.c @@ -400,7 +400,7 @@ static int parse_viewportcolour(struct skin_element *element, } else { - if (!parse_color(param->data.text, &colour->colour)) + if (!parse_color(curr_screen, param->data.text, &colour->colour)) return -1; } colour->vp = &curr_vp->vp; diff --git a/apps/gui/wps.c b/apps/gui/wps.c index 508446ab98..6ab016f88d 100644 --- a/apps/gui/wps.c +++ b/apps/gui/wps.c @@ -655,10 +655,14 @@ static void gwps_enter_wps(void) #if LCD_DEPTH > 1 if (display->depth > 1) { - struct viewport *vp = &find_viewport(VP_DEFAULT_LABEL, - false, gwps->data)->vp; - vp->fg_pattern = display->get_foreground(); - vp->bg_pattern = display->get_background(); + struct skin_viewport *svp = find_viewport(VP_DEFAULT_LABEL, + false, gwps->data); + if (svp) + { + struct viewport *vp = &svp->vp; + vp->fg_pattern = display->get_foreground(); + vp->bg_pattern = display->get_background(); + } } #endif /* make the backdrop actually take effect */ diff --git a/apps/misc.c b/apps/misc.c index 9fbdd433ef..31f0ac4193 100644 --- a/apps/misc.c +++ b/apps/misc.c @@ -930,20 +930,31 @@ int hex_to_rgb(const char* hex, int* color) /* '0'-'3' are ASCII 0x30 to 0x33 */ #define is0123(x) (((x) & 0xfc) == 0x30) -bool parse_color(char *text, int *value) +bool parse_color(enum screen_type screen, char *text, int *value) { (void)text; (void)value; /* silence warnings on mono bitmap */ + int depth = screens[screen].depth; + #ifdef HAVE_LCD_COLOR - if (hex_to_rgb(text, value) < 0) - return false; + if (depth > 2) + { + if (hex_to_rgb(text, value) < 0) + return false; + else + return true; + } #endif #if LCD_DEPTH == 2 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2) - if (text[1] != '\0' || !is0123(*text)) - return false; - *value = *text - '0'; + if (depth == 2) + { + if (text[1] != '\0' || !is0123(*text)) + return false; + *value = *text - '0'; + return true; + } #endif - return true; + return false; } /* only used in USB HID and set_time screen */ diff --git a/apps/misc.h b/apps/misc.h index 0de68a001c..fa66956800 100644 --- a/apps/misc.h +++ b/apps/misc.h @@ -25,6 +25,7 @@ #include #include "config.h" #include "system.h" +#include "screen_access.h" extern const unsigned char * const byte_units[]; extern const unsigned char * const * const kbyte_units; @@ -92,7 +93,7 @@ char* skip_whitespace(char* const str); char *strip_extension(char* buffer, int buffer_size, const char *filename); #ifdef HAVE_LCD_BITMAP -bool parse_color(char *text, int *value); +bool parse_color(enum screen_type screen, char *text, int *value); /* only used in USB HID and set_time screen */ #if defined(USB_ENABLE_HID) || (CONFIG_RTC != 0)