1
0
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:
Norbert Walter
2026-03-04 09:02:29 +00:00
parent 44e99cda50
commit c5533ab0ef
2 changed files with 61 additions and 29 deletions
+28
View File
@@ -60,10 +60,15 @@ GxEPD2_BW<GxEPD2_420_SE0420NQ04, GxEPD2_420_SE0420NQ04::HEIGHT> & getdisplay(){r
// panel device + offscreen shadow framebuffer // panel device + offscreen shadow framebuffer
static LGFX panelDisplay; static LGFX panelDisplay;
static LGFXCanvas shadowDisplay(&panelDisplay); static LGFXCanvas shadowDisplay(&panelDisplay);
static LGFXCanvas scaleDisplay(&panelDisplay);
static bool shadowDisplayInitialized = false; static bool shadowDisplayInitialized = false;
static bool scaleDisplayInitialized = false;
static uint16_t scaleDisplayWidth = 0;
static uint16_t scaleDisplayHeight = 0;
LGFXCanvas & getdisplay(){return shadowDisplay;} LGFXCanvas & getdisplay(){return shadowDisplay;}
LGFX & getpaneldisplay(){return panelDisplay;} LGFX & getpaneldisplay(){return panelDisplay;}
LGFXCanvas & getscaleddisplay(){return scaleDisplay;}
bool initDisplayShadowBuffer(){ bool initDisplayShadowBuffer(){
if (shadowDisplayInitialized) return true; if (shadowDisplayInitialized) return true;
@@ -81,6 +86,29 @@ bool initDisplayShadowBuffer(){
shadowDisplayInitialized = true; shadowDisplayInitialized = true;
return 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 #endif
// Horter I2C moduls // Horter I2C moduls
+11 -7
View File
@@ -423,7 +423,9 @@ private:
LGFXCanvas & getdisplay(); LGFXCanvas & getdisplay();
LGFX & getpaneldisplay(); LGFX & getpaneldisplay();
LGFXCanvas & getscaleddisplay();
bool initDisplayShadowBuffer(); bool initDisplayShadowBuffer();
bool initDisplayScaleBuffer(uint16_t width, uint16_t height);
#endif #endif
// Page display return values // 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 drawX = static_cast<uint16_t>((dstW - targetW) / 2U);
const uint16_t drawY = static_cast<uint16_t>((dstH - targetH) / 2U); const uint16_t drawY = static_cast<uint16_t>((dstH - targetH) / 2U);
dst.startWrite();
const uint16_t borderColor = src.readPixel(0, 0); const uint16_t borderColor = src.readPixel(0, 0);
if (drawX > 0) { if (initDisplayScaleBuffer(dstW, dstH)) {
dst.fillRect(0, drawY, drawX, targetH, borderColor); LGFXCanvas &scaled = getscaleddisplay();
dst.fillRect(drawX + targetW, drawY, dstW - (drawX + targetW), targetH, borderColor); scaled.fillScreen(borderColor);
}
for (uint16_t y = 0; y < targetH; ++y) { for (uint16_t y = 0; y < targetH; ++y) {
const uint32_t syfp = (targetH > 1) const uint32_t syfp = (targetH > 1)
@@ -597,13 +597,17 @@ inline void displayNextPage() {
const uint16_t color = src.readPixel(sx0, sy0); const uint16_t color = src.readPixel(sx0, sy0);
#endif #endif
dst.drawPixel(drawX + x, drawY + y, color); scaled.drawPixel(drawX + x, drawY + y, color);
} }
if ((y & 0x0F) == 0) { if ((y & 0x0F) == 0) {
yield(); yield();
} }
} }
dst.endWrite();
scaled.pushSprite(0, 0);
} else {
src.pushSprite(drawX, drawY);
}
#endif #endif
} }
#else #else