diff options
author | panky-codes <pankaj.sarathy1992@gmail.com> | 2021-03-20 22:45:29 +0100 |
---|---|---|
committer | panky-codes <pankaj.sarathy1992@gmail.com> | 2021-03-20 22:45:29 +0100 |
commit | 534565088033221d29e968acf7267145ff10203b (patch) | |
tree | c93ae7c7aa7995204f56b979ff6524feba83763d /src/displayapp/LittleVgl.cpp | |
parent | 754ac233040af805ffa2e15b24539d5d02a876e5 (diff) | |
parent | a3ff2e46ca9e663af864a2bd04b9afa3efbddfb8 (diff) |
Merged upstream
Diffstat (limited to 'src/displayapp/LittleVgl.cpp')
-rw-r--r-- | src/displayapp/LittleVgl.cpp | 87 |
1 files changed, 30 insertions, 57 deletions
diff --git a/src/displayapp/LittleVgl.cpp b/src/displayapp/LittleVgl.cpp index 44fa5657..238164a8 100644 --- a/src/displayapp/LittleVgl.cpp +++ b/src/displayapp/LittleVgl.cpp @@ -67,65 +67,47 @@ void LittleVgl::SetFullRefresh(FullRefreshDirections direction) { } void LittleVgl::FlushDisplay(const lv_area_t *area, lv_color_t *color_p) { + uint16_t y1, y2, width, height = 0; + ulTaskNotifyTake(pdTRUE, 500); // Notification is still needed (even if there is a mutex on SPI) because of the DataCommand pin // which cannot be set/clear during a transfer. + if( (scrollDirection == LittleVgl::FullRefreshDirections::Down) && (area->y2 == visibleNbLines - 1)) { + writeOffset = ((writeOffset + totalNbLines) - visibleNbLines) % totalNbLines; + } else if( (scrollDirection == FullRefreshDirections::Up) && (area->y1 == 0) ) { + writeOffset = (writeOffset + visibleNbLines) % totalNbLines; + } - // TODO refactore and remove duplicated code - - uint16_t x, y, y1, y2, width, height = 0; - if(scrollDirection == LittleVgl::FullRefreshDirections::Down) { - if(area->y2 == visibleNbLines-1) { - writeOffset = ((writeOffset + totalNbLines) - visibleNbLines) % totalNbLines; - } - x = area->x1; - width = (area->x2 - area->x1) + 1; + y1 = (area->y1 + writeOffset) % totalNbLines; + y2 = (area->y2 + writeOffset) % totalNbLines; - y1 = (area->y1 + writeOffset) % totalNbLines; - y2 = (area->y2 + writeOffset) % totalNbLines; - y = y1; - height = (y2 - y1) + 1; + width = (area->x2 - area->x1) + 1; + height = (area->y2 - area->y1) + 1; + if(scrollDirection == LittleVgl::FullRefreshDirections::Down) { if(area->y2 < visibleNbLines - 1) { uint16_t toScroll = 0; if(area->y1 == 0) { - toScroll = height*2; + toScroll = height * 2; scrollDirection = FullRefreshDirections::None; lv_disp_set_direction(lv_disp_get_default(), 0); } else { toScroll = height; } - if(scrollOffset >= toScroll) scrollOffset -= toScroll; else { toScroll -= scrollOffset; - scrollOffset = (totalNbLines) - toScroll; + scrollOffset = (totalNbLines) - toScroll; } - - lcd.VerticalScrollDefinition(0, 320, 0); lcd.VerticalScrollStartAddress(scrollOffset); } - lcd.BeginDrawBuffer(x, y, width, height); - lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(color_p), width * height*2) ; - } else if(scrollDirection == FullRefreshDirections::Up) { - if(area->y1 == 0) { - writeOffset = (writeOffset + visibleNbLines) % totalNbLines; - } - - x = area->x1; - width = (area->x2 - area->x1) + 1; - - y1 = (area->y1 + writeOffset) % totalNbLines; - y2 = (area->y2 + writeOffset) % totalNbLines; - y = y1; - height = (y2 - y1) + 1; if(area->y1 > 0) { - if(area->y2 == visibleNbLines -1) { + if(area->y2 == visibleNbLines - 1) { scrollOffset += (height * 2); scrollDirection = FullRefreshDirections::None; lv_disp_set_direction(lv_disp_get_default(), 0); @@ -133,36 +115,27 @@ void LittleVgl::FlushDisplay(const lv_area_t *area, lv_color_t *color_p) { scrollOffset += height; } scrollOffset = scrollOffset % totalNbLines; - lcd.VerticalScrollDefinition(0, 320, 0); lcd.VerticalScrollStartAddress(scrollOffset); } + } - lcd.BeginDrawBuffer(x, y, width, height); - lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(color_p), width * height*2); - } else { - x = area->x1; - width = (area->x2 - area->x1) + 1; - y1 = (area->y1 + writeOffset) % totalNbLines; - y2 = (area->y2 + writeOffset) % totalNbLines; - y = y1; - height = (y2 - y1) + 1; - - if (y2 < y1) { - height = (totalNbLines - 1) - y1; - lcd.BeginDrawBuffer(x, y1, width, height); - lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(color_p), width * height * 2); - ulTaskNotifyTake(pdTRUE, 500); - height = y2; - lcd.BeginDrawBuffer(x, 0, width, height); - lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(color_p), width * height * 2); - } else { - lcd.BeginDrawBuffer(x, y, width, height); - lcd.NextDrawBuffer(reinterpret_cast<const uint8_t *>(color_p), width * height * 2); + if (y2 < y1) { + height = totalNbLines - y1; + + if ( height > 0 ) { + lcd.DrawBuffer(area->x1, y1, width, height, reinterpret_cast<const uint8_t *>(color_p), width * height * 2); + ulTaskNotifyTake(pdTRUE, 320); } + uint16_t pixOffset = width * height; + height = y2 + 1; + lcd.DrawBuffer(area->x1, 0, width, height, reinterpret_cast<const uint8_t *>(color_p + pixOffset), width * height * 2); + + } else { + lcd.DrawBuffer(area->x1, y1, width, height, reinterpret_cast<const uint8_t *>(color_p), width * height * 2); } - /* IMPORTANT!!! - * Inform the graphics library that you are ready with the flushing*/ + // IMPORTANT!!! + // Inform the graphics library that you are ready with the flushing lv_disp_flush_ready(&disp_drv); } |