Open JoachimF opened 1 month ago
Hello,
Here is my code modification to use "Swap the 2 bytes of RGB565 color" or not, it is working for me :
` uint32_t j = 0;
/* uint16_t blue : 5; uint16_t green : 6; uint16_t red : 5;
BBBB BGGG GGGR RRRR
*/
uint32_t LD = 0; for (uint32_t i = 0; i < size; i++) { LD = buffer_16bit[i].full; mybuf[j] = (uint8_t) (((LD & 0xF800) >> 8) | ((LD & 0x8000) >> 13)); // B j++; mybuf[j] = (uint8_t) ((LD & 0x07E0) >> 3); // G j++; mybuf[j] = (uint8_t) (((LD & 0x001F) << 3) | ((LD & 0x0010) >> 2)); //R 0001 0000 -> 0000 0100 j++; }
/ B = 0000 0000 BBBB B100 G = 0000 0000 GGGG GG00 R = 0000 0000 RRRR R100 /
/* uint16_t green_h : 3; 0000 0000 0000 0111 uint16_t red : 5; 0000 0000 0001 1111 uint16_t blue : 5; 0000 0000 0001 1111 uint16_t green_l : 3; 0000 0000 0000 0111
GGGR RRRR BBBB BGGG 0000 0000 000G GG00 */
for (uint32_t i = 0; i < size; i++) { mybuf[j] = (uint8_t)((buffer_16bit[i].ch.red << 3) | ((buffer_16bit[i].ch.red & 0x0010) >> 2)); j++; mybuf[j] = (uint8_t)((buffer_16bit[i].ch.green_h << 5) | ((buffer_16bit[i].ch.green_l) << 2)); j++; mybuf[j] = (uint8_t)((buffer_16bit[i].ch.blue << 3) | ((buffer_16bit[i].ch.blue & 0x0010) >> 2));; j++; }
/* Column addresses */
`
I leave my comment for those wants to understand how bits are shifted.
I didn't understand while des MSB bits of red and blue are copied to LSB, if someone can explain to me.
Regards,
Hello,
Here is my code modification to use "Swap the 2 bytes of RGB565 color" or not, it is working for me :
` uint32_t j = 0;
/* uint16_t blue : 5; uint16_t green : 6; uint16_t red : 5;
*/
if LV_COLOR_16_SWAP != 1
endif
/ B = 0000 0000 BBBB B100 G = 0000 0000 GGGG GG00 R = 0000 0000 RRRR R100 /
/* uint16_t green_h : 3; 0000 0000 0000 0111 uint16_t red : 5; 0000 0000 0001 1111 uint16_t blue : 5; 0000 0000 0001 1111 uint16_t green_l : 3; 0000 0000 0000 0111
if LV_COLOR_16_SWAP == 1
endif
`
I leave my comment for those wants to understand how bits are shifted.
I didn't understand while des MSB bits of red and blue are copied to LSB, if someone can explain to me.
Regards,