diff options
author | Christian Vogel <vogelchr@vogel.cx> | 2012-01-30 14:57:44 +0100 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2012-02-03 23:59:35 +0100 |
commit | 12d7ca237fd7dce4a37497428694d9b6729184e7 (patch) | |
tree | fa73c70a0cd31764cfea0a9e9451bbd17ac312b5 /src/target/firmware/include/fb | |
parent | cf5ba98c10508be4f8c10459b431806686df216c (diff) |
Calypso FB: RGB332 to RGB565 conversion function.
Diffstat (limited to 'src/target/firmware/include/fb')
-rw-r--r-- | src/target/firmware/include/fb/fb_rgb332.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/target/firmware/include/fb/fb_rgb332.h b/src/target/firmware/include/fb/fb_rgb332.h index 8bf8168f..4df44e4e 100644 --- a/src/target/firmware/include/fb/fb_rgb332.h +++ b/src/target/firmware/include/fb/fb_rgb332.h @@ -24,4 +24,24 @@ extern int fb_rgb332_putstr(char *str,int maxwidth); extern struct fb_rgb332 *fb_rgb332; +/* this convenience function can be used if you choose to + * back a RGB565 display with a RGB332 framebuffer to conserve + * ARM memory. It converts a rgb332 value to rgb565 as indicated + * in the comments. */ + +static inline uint16_t +rgb332_to_565(uint8_t rgb332){ + + uint8_t red = (rgb332 & 0xe0) >> 5 ; // rrr. .... -> .... .rrr + uint8_t green = ((rgb332 & 0x1c) >> 2); // ...g gg.. -> .... .ggg + uint8_t blue = rgb332 & 0x03; // .... ..bb -> .... ..bb + + red = (red << 2) | (red >> 1); /* .....210 -> ...21021 */ + green = (green << 3) | (green); /* .....210 -> ..210210 */ + blue = (blue << 3) | (blue << 1) | (blue >> 1); /* ......10 -> ...10101 */ + + /* rrrrrggg gggbbbbb */ + return (red << 11) | (green << 5) | blue; +} + #endif |