mirror of
https://github.com/thooge/esp32-nmea2000-obp60.git
synced 2026-08-18 18:32:30 +02:00
Add frame buffer for scaled picture
This commit is contained in:
@@ -60,10 +60,15 @@ GxEPD2_BW<GxEPD2_420_SE0420NQ04, GxEPD2_420_SE0420NQ04::HEIGHT> & getdisplay(){r
|
||||
// panel device + offscreen shadow framebuffer
|
||||
static LGFX panelDisplay;
|
||||
static LGFXCanvas shadowDisplay(&panelDisplay);
|
||||
static LGFXCanvas scaleDisplay(&panelDisplay);
|
||||
static bool shadowDisplayInitialized = false;
|
||||
static bool scaleDisplayInitialized = false;
|
||||
static uint16_t scaleDisplayWidth = 0;
|
||||
static uint16_t scaleDisplayHeight = 0;
|
||||
|
||||
LGFXCanvas & getdisplay(){return shadowDisplay;}
|
||||
LGFX & getpaneldisplay(){return panelDisplay;}
|
||||
LGFXCanvas & getscaleddisplay(){return scaleDisplay;}
|
||||
|
||||
bool initDisplayShadowBuffer(){
|
||||
if (shadowDisplayInitialized) return true;
|
||||
@@ -81,6 +86,29 @@ bool initDisplayShadowBuffer(){
|
||||
shadowDisplayInitialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initDisplayScaleBuffer(uint16_t width, uint16_t height){
|
||||
if (scaleDisplayInitialized && scaleDisplayWidth == width && scaleDisplayHeight == height) {
|
||||
return true;
|
||||
}
|
||||
|
||||
scaleDisplay.deleteSprite();
|
||||
scaleDisplay.setPsram(true);
|
||||
scaleDisplay.setColorDepth(16);
|
||||
scaleDisplay.setTextDatum(textdatum_t::baseline_left);
|
||||
|
||||
if (scaleDisplay.createSprite(width, height) == nullptr) {
|
||||
scaleDisplayInitialized = false;
|
||||
scaleDisplayWidth = 0;
|
||||
scaleDisplayHeight = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
scaleDisplayWidth = width;
|
||||
scaleDisplayHeight = height;
|
||||
scaleDisplayInitialized = true;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Horter I2C moduls
|
||||
|
||||
@@ -423,7 +423,9 @@ private:
|
||||
|
||||
LGFXCanvas & getdisplay();
|
||||
LGFX & getpaneldisplay();
|
||||
LGFXCanvas & getscaleddisplay();
|
||||
bool initDisplayShadowBuffer();
|
||||
bool initDisplayScaleBuffer(uint16_t width, uint16_t height);
|
||||
#endif
|
||||
|
||||
// Page display return values
|
||||
@@ -568,12 +570,10 @@ inline void displayNextPage() {
|
||||
const uint16_t drawX = static_cast<uint16_t>((dstW - targetW) / 2U);
|
||||
const uint16_t drawY = static_cast<uint16_t>((dstH - targetH) / 2U);
|
||||
|
||||
dst.startWrite();
|
||||
const uint16_t borderColor = src.readPixel(0, 0);
|
||||
if (drawX > 0) {
|
||||
dst.fillRect(0, drawY, drawX, targetH, borderColor);
|
||||
dst.fillRect(drawX + targetW, drawY, dstW - (drawX + targetW), targetH, borderColor);
|
||||
}
|
||||
if (initDisplayScaleBuffer(dstW, dstH)) {
|
||||
LGFXCanvas &scaled = getscaleddisplay();
|
||||
scaled.fillScreen(borderColor);
|
||||
|
||||
for (uint16_t y = 0; y < targetH; ++y) {
|
||||
const uint32_t syfp = (targetH > 1)
|
||||
@@ -597,13 +597,17 @@ inline void displayNextPage() {
|
||||
const uint16_t color = src.readPixel(sx0, sy0);
|
||||
#endif
|
||||
|
||||
dst.drawPixel(drawX + x, drawY + y, color);
|
||||
scaled.drawPixel(drawX + x, drawY + y, color);
|
||||
}
|
||||
if ((y & 0x0F) == 0) {
|
||||
yield();
|
||||
}
|
||||
}
|
||||
dst.endWrite();
|
||||
|
||||
scaled.pushSprite(0, 0);
|
||||
} else {
|
||||
src.pushSprite(drawX, drawY);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user