This commit is contained in:
Wolfvak 2019-07-23 15:36:37 -03:00 committed by d0k3
parent d6c6f56526
commit 524a86e9a4
2 changed files with 22 additions and 6 deletions

View File

@ -87,3 +87,19 @@ bool ShowRtcSetterPrompt(void* time, const char *format, ...);
bool ShowProgress(u64 current, u64 total, const char* opstr);
int ShowBrightnessConfig(int set_brightness);
static inline u16 rgb888_to_rgb565(u32 rgb) {
u8 r, g, b;
r = (rgb >> 16) & 0x1F;
g = (rgb >> 8) & 0x3F;
b = (rgb >> 0) & 0x1F;
return (r << 11) | (g << 5) | b;
}
static inline u16 rgb888_buf_to_rgb565(u8 *rgb) {
u8 r, g, b;
r = (rgb[0] >> 3);
g = (rgb[1] >> 2);
b = (rgb[2] >> 3);
return (r << 11) | (g << 5) | b;
}

View File

@ -342,17 +342,17 @@ void set_preview(const char* name, const char* content) {
else if (strncasecmp(content, "full", _VAR_CNT_LEN) == 0) preview_mode = 2;
else preview_mode = 0xFF; // unknown preview mode
} else if (strncmp(name, "PREVIEW_COLOR_ACTIVE", _VAR_NAME_LEN) == 0) {
u8 rgb[4] = { 0 };
u8 rgb[4];
if (strntohex(content, rgb, 3))
script_color_active = getle32(rgb);
script_color_active = rgb888_buf_to_rgb565(rgb);
} else if (strncmp(name, "PREVIEW_COLOR_COMMENT", _VAR_NAME_LEN) == 0) {
u8 rgb[4] = { 0 };
u8 rgb[4];
if (strntohex(content, rgb, 3))
script_color_comment = getle32(rgb);
script_color_comment = rgb888_buf_to_rgb565(rgb);
} else if (strncmp(name, "PREVIEW_COLOR_CODE", _VAR_NAME_LEN) == 0) {
u8 rgb[4] = { 0 };
u8 rgb[4];
if (strntohex(content, rgb, 3))
script_color_code = getle32(rgb);
script_color_code = rgb888_buf_to_rgb565(rgb);
}
}