Skip to content

Commit

Permalink
[stm32f4-ltdc] this fixes ltdc_get_rgb888_from_rgb565 return value ty…
Browse files Browse the repository at this point in the history
…pe and adds ltdc_get_rgb565_from_rgb888
  • Loading branch information
h2obrain committed Aug 9, 2016
1 parent 0cb1db0 commit c1aaef4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions include/libopencm3/stm32/f4/ltdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,20 @@ static inline bool LTDC_SRCR_IS_RELOADING(void)
* color conversion helper function
* (simulate the ltdc color conversion)
*/
static inline uint32_t ltdc_get_rgb888_from_rgb565(uint16_t rgb565)
{
return (uint32_t)(((rgb565 & 0xF800) >> (11-8))/31)<<16
| (uint32_t)(((rgb565 & 0x07E0) << (8-5))/63)<<8
| (uint32_t)(((rgb565 & 0x001F) << (8-0))/31)<<0;
}

static inline uint16_t ltdc_get_rgb888_from_rgb565(uint16_t rgb888)
static inline uint16_t ltdc_get_rgb565_from_rgb888(uint32_t rgb888)
{
return ((((rgb888) & 0xF800) >> (11-8))/31)<<16
| ((((rgb888) & 0x07E0) << (8-5))/63)<<8
| ((((rgb888) & 0x001F) << (8-0))/31)<<0;
return (uint16_t) (
(((((rgb888 & 0xFF0000) >> 16)*31) << (11-8)) & 0xF800)
| (((((rgb888 & 0x00FF00) >> 8)*63) >> (8-5) ) & 0x07E0)
| (((((rgb888 & 0x0000FF) >> 0)*31) >> (8-0) ) & 0x001F)
);
}


Expand Down

0 comments on commit c1aaef4

Please sign in to comment.