diff --git a/lib/obp60task/OBP60Extensions.h b/lib/obp60task/OBP60Extensions.h index d93b607..662b2c0 100644 --- a/lib/obp60task/OBP60Extensions.h +++ b/lib/obp60task/OBP60Extensions.h @@ -432,10 +432,15 @@ bool initDisplayShadowBuffer(); #define PAGE_HIBERNATE 2 // page wants displey to hibernate #ifdef DISPLAY_ST7796 +#ifndef OBP_TFT_ENABLE_SCALING +#define OBP_TFT_ENABLE_SCALING 1 +#endif + #ifndef OBP_TFT_SCALE_ANTIALIAS #define OBP_TFT_SCALE_ANTIALIAS 1 #endif +#if OBP_TFT_SCALE_ANTIALIAS inline uint16_t lerpRgb565(uint16_t c0, uint16_t c1, uint16_t w8) { const uint16_t r0 = (c0 >> 11) & 0x1F; const uint16_t g0 = (c0 >> 5) & 0x3F; @@ -463,6 +468,7 @@ inline uint16_t sampleBilinearRgb565(LGFXCanvas& src, uint16_t x0, uint16_t y0, return lerpRgb565(top, bot, wy); } #endif +#endif // Draw monochrome bitmap on both E-Ink and TFT displays // supports various packing and bit orders; optional runtime conversion for TFT @@ -549,6 +555,12 @@ inline void displayNextPage() { const uint16_t dstW = static_cast(dst.width()); const uint16_t dstH = static_cast(dst.height()); + #if !OBP_TFT_ENABLE_SCALING + const uint16_t drawX = static_cast((dstW > srcW) ? ((dstW - srcW) / 2U) : 0U); + const uint16_t drawY = static_cast((dstH > srcH) ? ((dstH - srcH) / 2U) : 0U); + src.pushSprite(drawX, drawY); + #else + const uint16_t targetH = (dstH < 320U) ? dstH : 320U; const uint32_t scaledW32 = (static_cast(srcW) * targetH + (srcH / 2U)) / srcH; const uint16_t targetW = static_cast((scaledW32 < dstW) ? scaledW32 : dstW); @@ -592,6 +604,7 @@ inline void displayNextPage() { } } dst.endWrite(); + #endif } #else getdisplay().nextPage(); diff --git a/lib/obp60task/platformio.ini b/lib/obp60task/platformio.ini index 71fbcbc..dd70278 100644 --- a/lib/obp60task/platformio.ini +++ b/lib/obp60task/platformio.ini @@ -59,6 +59,8 @@ build_flags= # -D DISPLAY_GYE042A87 #alternativ E-Ink display from Genyo Optical, R10 2.2 ohm - medium # -D DISPLAY_SE0420NQ04 #alternativ E-Ink display from SID Technology, R10 2.2 ohm - bad (burn in effects) -D DISPLAY_ST7796 #ST7796 TFT LCD display (480x320 color display) + -D OBP_TFT_ENABLE_SCALING=1 #TFT scaling on/off (1=scale to max Y=320, 0=no scaling) + -D OBP_TFT_SCALE_ANTIALIAS=1 #Antialiasing for TFT scaling (1=on, 0=off) # -D DISPLAY_ZJY400300-042CAAMFGN #alternativ E-Ink display from ZZE Technology, R10 2.2 ohm - very good # -D ENABLE_PATCHES #enable patching of gateway code ${env.build_flags}