Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix color inversion inside a buffer #143

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libraries/Sipeed_OV2640/src/Sipeed_OV2640.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ static const uint8_t yuv422_regs[][2] = {
{ BANK_SEL, BANK_SEL_DSP },
{ RESET, RESET_DVP},
{ 0xD7, 0x01 },
{ IMAGE_MODE, IMAGE_MODE_YUV422 },
{ IMAGE_MODE, IMAGE_MODE_YUV422 | 0b00000001 },
{ 0xE1, 0x67 },
{ RESET, 0x00 },
{0, 0},
Expand Down Expand Up @@ -1530,8 +1530,8 @@ int Sipeed_OV2640::reverse_u32pixel(uint32_t* addr,uint32_t length)
for(;addr<pend;addr++)
{
data = *(addr);
*(addr) = ((data & 0x000000FF) << 24) | ((data & 0x0000FF00) << 8) |
((data & 0x00FF0000) >> 8) | ((data & 0xFF000000) >> 24) ;
*(addr) = ((data & 0x0000FFFF) << 16) | ((data & 0xFFFF0000) >> 16);

} //1.7ms


Expand Down
6 changes: 2 additions & 4 deletions libraries/Sipeed_ST7789/src/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,15 @@ void lcd_draw_rectangle(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint
tft_write_word(data_buf, ((y2 - y1 + 1) * width + 1) / 2);
}

#define SWAP_16(x) ((x >> 8 & 0xff) | (x << 8))

void lcd_draw_picture(uint16_t x1, uint16_t y1, uint16_t width, uint16_t height, uint16_t *ptr)
{
uint32_t i;
uint16_t *p = ptr;
lcd_set_area(x1, y1, x1 + width - 1, y1 + height - 1);
for (i = 0; i < LCD_MAX_PIXELS; i += 2)
{
g_lcd_display_buff[i] = SWAP_16(*(p + 1));
g_lcd_display_buff[i + 1] = SWAP_16(*(p));
g_lcd_display_buff[i] = *(p + 1);
g_lcd_display_buff[i + 1] = *(p);
p += 2;
}
tft_write_word((uint32_t*)g_lcd_display_buff, width * height / 2);
Expand Down