diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/misc.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/apps/misc.c b/apps/misc.c index 632b12b9aa..8b6773dd6f 100644 --- a/apps/misc.c +++ b/apps/misc.c | |||
@@ -1099,28 +1099,23 @@ static int hex2dec(int c) | |||
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | int hex_to_rgb(const char* hex, int* color) | 1101 | int hex_to_rgb(const char* hex, int* color) |
1102 | { int ok = 1; | 1102 | { |
1103 | int i; | ||
1104 | int red, green, blue; | 1103 | int red, green, blue; |
1104 | int i = 0; | ||
1105 | 1105 | ||
1106 | if (strlen(hex) == 6) { | 1106 | while ((i < 6) && (isxdigit(hex[i]))) |
1107 | for (i=0; i < 6; i++ ) { | 1107 | i++; |
1108 | if (!isxdigit(hex[i])) { | ||
1109 | ok=0; | ||
1110 | break; | ||
1111 | } | ||
1112 | } | ||
1113 | 1108 | ||
1114 | if (ok) { | 1109 | if (i < 6) |
1115 | red = (hex2dec(hex[0]) << 4) | hex2dec(hex[1]); | 1110 | return -1; |
1116 | green = (hex2dec(hex[2]) << 4) | hex2dec(hex[3]); | 1111 | |
1117 | blue = (hex2dec(hex[4]) << 4) | hex2dec(hex[5]); | 1112 | red = (hex2dec(hex[0]) << 4) | hex2dec(hex[1]); |
1118 | *color = LCD_RGBPACK(red,green,blue); | 1113 | green = (hex2dec(hex[2]) << 4) | hex2dec(hex[3]); |
1119 | return 0; | 1114 | blue = (hex2dec(hex[4]) << 4) | hex2dec(hex[5]); |
1120 | } | ||
1121 | } | ||
1122 | 1115 | ||
1123 | return -1; | 1116 | *color = LCD_RGBPACK(red,green,blue); |
1117 | |||
1118 | return 0; | ||
1124 | } | 1119 | } |
1125 | #endif /* HAVE_LCD_COLOR */ | 1120 | #endif /* HAVE_LCD_COLOR */ |
1126 | 1121 | ||