Skip to content

Commit 8ea1385

Browse files
committed
ugfx: add gdispGSetFlushPeriod() function to dynamically set the refresh rate
1 parent 886664f commit 8ea1385

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

components/ugfx/src/gdisp/gdisp.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#if GDISP_NEED_TIMERFLUSH
2828
static GTimer FlushTimer;
29+
static uint16_t FlushPeriod = GDISP_NEED_TIMERFLUSH;
2930
#endif
3031

3132
GDisplay *GDISP;
@@ -549,6 +550,14 @@ static void line_clip(GDisplay *g) {
549550
for(g = (GDisplay *)gdriverGetNext(GDRIVER_TYPE_DISPLAY, 0); g; g = (GDisplay *)gdriverGetNext(GDRIVER_TYPE_DISPLAY, (GDriver *)g))
550551
gdispGFlush(g);
551552
}
553+
void gdispGSetFlushPeriod(GDisplay *g, uint16_t period) {
554+
if (period > GDISP_NEED_TIMERFLUSH) {
555+
FlushPeriod = period;
556+
} else {
557+
FlushPeriod = GDISP_NEED_TIMERFLUSH;
558+
}
559+
gtimerStart(&FlushTimer, FlushTimerFn, 0, TRUE, FlushPeriod);
560+
}
552561
#endif
553562

554563
/*===========================================================================*/
@@ -611,7 +620,7 @@ void _gdispInit(void)
611620
// Start the automatic timer flush (if required)
612621
#if GDISP_NEED_TIMERFLUSH
613622
gtimerInit(&FlushTimer);
614-
gtimerStart(&FlushTimer, FlushTimerFn, 0, TRUE, GDISP_NEED_TIMERFLUSH);
623+
gtimerStart(&FlushTimer, FlushTimerFn, 0, TRUE, FlushPeriod);
615624
#endif
616625
}
617626

components/ugfx/src/gdisp/gdisp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,6 +1153,10 @@ void gdispGDrawBox(GDisplay *g, coord_t x, coord_t y, coord_t cx, coord_t cy, co
11531153
#define gdispFillRoundedBox(x,y,cx,cy,r,c) gdispGFillRoundedBox(GDISP,x,y,cx,cy,r,c)
11541154
#endif
11551155

1156+
#if GDISP_NEED_TIMERFLUSH
1157+
void gdispGSetFlushPeriod(GDisplay *g, uint16_t period);
1158+
#endif
1159+
11561160
/*
11571161
* Macro definitions
11581162
*/

0 commit comments

Comments
 (0)