-
Notifications
You must be signed in to change notification settings - Fork 288
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
One pixel transformation for ILI948x #103
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,28 +111,6 @@ void ili9481_init(void) | |
// Flush function based on mvturnho repo | ||
void ili9481_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map) | ||
{ | ||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area); | ||
|
||
lv_color16_t *buffer_16bit = (lv_color16_t *) color_map; | ||
uint8_t *mybuf; | ||
do { | ||
mybuf = (uint8_t *) heap_caps_malloc(3 * size * sizeof(uint8_t), MALLOC_CAP_DMA); | ||
if (mybuf == NULL) ESP_LOGW(TAG, "Could not allocate enough DMA memory!"); | ||
} while (mybuf == NULL); | ||
|
||
uint32_t LD = 0; | ||
uint32_t j = 0; | ||
|
||
for (uint32_t i = 0; i < size; i++) { | ||
LD = buffer_16bit[i].full; | ||
mybuf[j] = (uint8_t) (((LD & 0xF800) >> 8) | ((LD & 0x8000) >> 13)); | ||
j++; | ||
mybuf[j] = (uint8_t) ((LD & 0x07E0) >> 3); | ||
j++; | ||
mybuf[j] = (uint8_t) (((LD & 0x001F) << 3) | ((LD & 0x0010) >> 2)); | ||
j++; | ||
} | ||
|
||
/* Column addresses */ | ||
uint8_t xb[] = { | ||
(uint8_t) (area->x1 >> 8) & 0xFF, | ||
|
@@ -160,8 +138,17 @@ void ili9481_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col | |
/*Memory write*/ | ||
ili9481_send_cmd(ILI9481_CMD_MEMORY_WRITE); | ||
|
||
ili9481_send_color((void *) mybuf, size * 3); | ||
heap_caps_free(mybuf); | ||
// ILI9488/9481 doesn't support 16bit color data in SPI mode, only 18bit color data | ||
// So here we have to transform every pixel from RGB565 to 6bits for every color, aligned to the left | ||
const uint32_t size = lv_area_get_width(area) * lv_area_get_height(area); | ||
lv_color16_t *color_565 = (lv_color16_t *) color_map; | ||
for (uint32_t i = 0; i < size; i++, color_565++) { | ||
uint8_t spi_buf[3]; | ||
spi_buf[0] = color_565->ch.blue << 3; // Blue is 5bits wide, align to 8 bits | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assuming that on UI there are a lot of adjacent same color (e.g. a large white background, a blue button, etc) calculating only if the current color is different from the previous else coping the previous result might cause significant speed up. |
||
spi_buf[1] = color_565->ch.green << 2; // Green is 6bits wide, align to 8 bits | ||
spi_buf[2] = color_565->ch.red << 3; // Red is 5bits wide, align to 8 bits | ||
ili9481_send_color((void *) spi_buf, sizeof(spi_buf)); | ||
tore-espressif marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
/********************** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way there is no maxima blue. E.g.
0b11111 << 3
is0b11111000
instead of0b11111111
.The original code converted to RGB666 and added the LSB twice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I couldn't get me head around the old conversion function. Will fix