From 3c9b07d776ef93c1cc7c269fe7a85b948d2623a8 Mon Sep 17 00:00:00 2001 From: Oliver Meier Date: Wed, 10 Dec 2014 19:16:36 +0100 Subject: [PATCH] [ltdc-stm32f4] add helper function to convert rgb565 to rgb888 --- include/libopencm3/stm32/f4/ltdc.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/libopencm3/stm32/f4/ltdc.h b/include/libopencm3/stm32/f4/ltdc.h index 5e49e28b..2a1812b6 100644 --- a/include/libopencm3/stm32/f4/ltdc.h +++ b/include/libopencm3/stm32/f4/ltdc.h @@ -168,6 +168,16 @@ void ltdc_setup_windowing( uint16_t active_width, uint16_t active_height ); +/** + * color conversion helper function + * (simulate the ltdc color conversion) + */ + +#define ltdc_get_rgb888_from_rgb565(rgb888) ( \ + ((((rgb888) & 0xF800) >> (11-8))/31)<<16 \ + | ((((rgb888) & 0x07E0) << ( 8-5))/63)<<8 \ + | ((((rgb888) & 0x001F) << ( 8-0))/31)<<0 \ +) #endif /* LIBOPENCM3_STM32_F4_LTDC_H_ */