Skip to content

Commit

Permalink
Add ability to use TFT_eSPI setViewport()
Browse files Browse the repository at this point in the history
- Provides greatly enhanced redraw performance for #274
  • Loading branch information
ImpulseAdventure committed Oct 8, 2020
1 parent b3a5916 commit 9b621ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions configs/esp-shld-adafruit_24_feather_touch-espi.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ extern "C" {
#define DRV_DISP_TFT_ESPI // bodmer/TFT_eSPI
#define DRV_TOUCH_ADA_STMPE610 // Adafruit STMPE610 touch driver

// Recent versions of TFT_eSPI support additional functionality:
// - setViewport() in v2.3.0: enhanced redraw performance
//#define DRV_DISP_TFT_ESPI_HAS_SETVIEWPORT // Uncomment if TFT_eSPI v2.3.0 onwards

// -----------------------------------------------------------------------------
// SECTION 2: Pinout
Expand Down
14 changes: 9 additions & 5 deletions src/GUIslice_drv_tft_espi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,11 +332,15 @@ bool gslc_DrvSetClipRect(gslc_tsGui* pGui,gslc_tsRect* pRect)
pDriver->rClipRect = *pRect;
}

// Rendering within clipping region is only available
// with the inclusion of https://github.com/ImpulseAdventure/TFT_eSPI/tree/add_setClipRect
// which may be integrated into TFT_eSPI in the future
#if defined(DRV_DISP_TFT_ESPI_HAS_CLIPRECT)
m_disp.setClipRect(pDriver->rClipRect.x,pDriver->rClipRect.y,pDriver->rClipRect.w,pDriver->rClipRect.h);
// Rendering within clipping regions is provided by TFT_eSPI's
// setViewport() API. Enabling this functionality provides
// greatly enhanced redraw performance when updating the
// entire page.
//
// NOTE: This function is only present in recent releases
// of TFT_eSPI (>= v2.3.0)
#if defined(DRV_DISP_TFT_ESPI_HAS_SETVIEWPORT)
m_disp.setViewport(pDriver->rClipRect.x,pDriver->rClipRect.y,pDriver->rClipRect.w,pDriver->rClipRect.h,false);
#endif

return true;
Expand Down

0 comments on commit 9b621ab

Please sign in to comment.