9
0
Fork 0

Fix some RGB color macros

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4081 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2011-11-03 22:27:53 +00:00
parent 44b2dffe12
commit ef30e0aef2
2 changed files with 10 additions and 2 deletions

View File

@ -2192,3 +2192,6 @@
supports using "clusters" of AT24 pages as blocks. This allows bigger
block sizes and more efficient use of EEPROM when the AT24 is used to
support a file system (such as NXFFS). (Contributed by Hal Glenn).
* include/nuttx/rgbcolors.h: More fixes to RGB color conversion
macros.

View File

@ -56,10 +56,15 @@
#define RBG24GREEN(rgb) (((rgb) >> 8) & 0xff)
#define RBG24BLUE(rgb) ( (rgb) & 0xff)
/* This macro creates RGB16 (5:6:5) from 8:8:8 RGB */
/* This macro creates RGB16 (5:6:5) from 8:8:8 RGB:
*
* R[7:3] -> RGB[15:11]
* G[7:2] -> RGB[10:5]
* B[7:3] -> RGB[4:0]
*/
#define RGBTO16(r,g,b) \
((((uint16_t)(r) << 11) & 0xf800) | (((uint16_t)(g) << 5) & 0x07e0) | ((uint16_t)(b) & 0x001f))
((((uint16_t)(r) << 8) & 0xf800) | (((uint16_t)(g) << 3) & 0x07e0) | (((uint16_t)(b) >> 3) & 0x001f))
/* And these macros perform the inverse transformation */