diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/export/lcd.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h index 87dda891b9..ba0e216990 100644 --- a/firmware/export/lcd.h +++ b/firmware/export/lcd.h | |||
@@ -150,9 +150,11 @@ typedef void lcd_fastpixelfunc_type(fb_data *address); | |||
150 | #define LCD_MAX_RED 31 | 150 | #define LCD_MAX_RED 31 |
151 | #define LCD_MAX_GREEN 63 | 151 | #define LCD_MAX_GREEN 63 |
152 | #define LCD_MAX_BLUE 31 | 152 | #define LCD_MAX_BLUE 31 |
153 | #define _RGBPACK(r, g, b) ( ((((r) * 31 + 127) / 255) << 11) \ | 153 | #define _RGBPACK(r, g, b) ( ((((r) * (31*257) + (127*257)) >> 16) << 11) \ |
154 | |((((g) * 63 + 127) / 255) << 5) \ | 154 | |((((g) * (63*257) + (127*257)) >> 16) << 5) \ |
155 | | (((b) * 31 + 127) / 255)) | 155 | | (((b) * (31*257) + (127*257)) >> 16)) |
156 | /* Note: ((x * 257) >> 16) almost equals (x / 255), but it avoids the division, | ||
157 | * so it's faster when the macro is used for variable r, g, b in the source. */ | ||
156 | #if (LCD_PIXELFORMAT == RGB565SWAPPED) | 158 | #if (LCD_PIXELFORMAT == RGB565SWAPPED) |
157 | #define LCD_RGBPACK(r, g, b) ( ((_RGBPACK((r), (g), (b)) & 0xff00) >> 8) \ | 159 | #define LCD_RGBPACK(r, g, b) ( ((_RGBPACK((r), (g), (b)) & 0xff00) >> 8) \ |
158 | |((_RGBPACK((r), (g), (b)) & 0x00ff) << 8)) | 160 | |((_RGBPACK((r), (g), (b)) & 0x00ff) << 8)) |
@@ -163,9 +165,9 @@ typedef void lcd_fastpixelfunc_type(fb_data *address); | |||
163 | #define LCD_MAX_RED 63 | 165 | #define LCD_MAX_RED 63 |
164 | #define LCD_MAX_GREEN 63 | 166 | #define LCD_MAX_GREEN 63 |
165 | #define LCD_MAX_BLUE 63 | 167 | #define LCD_MAX_BLUE 63 |
166 | #define LCD_RGBPACK(r, g, b) ( ((((r) * 63 + 127) / 255) << 12) \ | 168 | #define LCD_RGBPACK(r, g, b) ( ((((r) * (63*257) + (127*257)) >> 16) << 12) \ |
167 | |((((g) * 63 + 127) / 255) << 6) \ | 169 | |((((g) * (63*257) + (127*257)) >> 16) << 6) \ |
168 | | (((b) * 63 + 127) / 255)) | 170 | | (((b) * (63*257) + (127*257)) >> 16)) |
169 | #else | 171 | #else |
170 | /* other colour depths */ | 172 | /* other colour depths */ |
171 | #endif | 173 | #endif |