Skip to content

Commit 5f71f18

Browse files
committed
gui: switch to manual flushing
1 parent 65cdf6b commit 5f71f18

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

components/ugfx/gfxconf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
#define GFX_USE_GDISP TRUE
7171

7272
// #define GDISP_NEED_AUTOFLUSH TRUE
73-
#define GDISP_NEED_TIMERFLUSH 16
73+
// #define GDISP_NEED_TIMERFLUSH FALSE
7474
// #define GDISP_NEED_VALIDATION TRUE
7575
// #define GDISP_NEED_CLIP TRUE
7676
// #define GDISP_NEED_CIRCLE TRUE

main/src/user/gui.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,35 @@ GDisplay *gui_gdisp = NULL;
4444
static coord_t gui_disp_width = 0;
4545
static coord_t gui_disp_height = 0;
4646

47+
static GTimer gui_flush_timer;
4748
static uint8_t gui_backlight = 255;
4849

4950
static uint8_t img_file_index = 0;
5051

52+
static void gui_flush_task(void *pvParameter)
53+
{
54+
gdispGFlush(gui_gdisp);
55+
}
56+
5157
static void gui_task(void *pvParameter)
5258
{
53-
portTickType xLastWakeTime;
5459
gdispImage gfx_image;
60+
portTickType xLastWakeTime;
5561

5662
gfxInit();
5763

5864
gui_gdisp = gdispGetDisplay(0);
5965
gui_disp_width = gdispGGetWidth(gui_gdisp);
6066
gui_disp_height = gdispGGetHeight(gui_gdisp);
6167

62-
gdispGFillArea(gui_gdisp, 0, 0, gui_disp_width, gui_disp_height, 0x000000);
63-
64-
gdispGSetBacklight(gui_gdisp, gui_backlight);
68+
gtimerStart(&gui_flush_timer, gui_flush_task, NULL, TRUE, TIME_INFINITE);
6569

6670
ESP_LOGI(TAG, "started.");
6771

72+
#ifdef CONFIG_SCREEN_PANEL_ST7789
73+
gdispGSetOrientation(gui_gdisp, GDISP_ROTATE_270);
74+
#endif
75+
6876
while (1) {
6977
xEventGroupWaitBits(
7078
user_event_group,
@@ -77,6 +85,8 @@ static void gui_task(void *pvParameter)
7785
if (!(gdispImageOpenMemory(&gfx_image, img_file_ptr[img_file_index][0]) & GDISP_IMAGE_ERR_UNRECOVERABLE)) {
7886
gdispImageSetBgColor(&gfx_image, Black);
7987

88+
gdispGSetBacklight(gui_gdisp, gui_backlight);
89+
8090
while (1) {
8191
xLastWakeTime = xTaskGetTickCount();
8292

@@ -85,9 +95,12 @@ static void gui_task(void *pvParameter)
8595
}
8696

8797
if (gdispImageDraw(&gfx_image, 0, 0, gfx_image.width, gfx_image.height, 0, 0) != GDISP_IMAGE_ERR_OK) {
88-
goto err;
98+
ESP_LOGE(TAG, "failed to draw image: %u", img_file_index);
99+
break;
89100
}
90101

102+
gtimerJab(&gui_flush_timer);
103+
91104
delaytime_t delay = gdispImageNext(&gfx_image);
92105
if (delay == TIME_INFINITE) {
93106
break;
@@ -100,19 +113,15 @@ static void gui_task(void *pvParameter)
100113

101114
gdispImageClose(&gfx_image);
102115
} else {
103-
goto err;
116+
ESP_LOGE(TAG, "failed to open image: %u", img_file_index);
104117
}
105118
}
106-
107-
err:
108-
ESP_LOGE(TAG, "unrecoverable error");
109-
esp_restart();
110119
}
111120

112121
void gui_show_image(uint8_t idx)
113122
{
114123
#ifdef CONFIG_ENABLE_GUI
115-
if (idx >= (sizeof(img_file_ptr) / 2)) {
124+
if (idx >= sizeof(img_file_ptr)/2) {
116125
ESP_LOGE(TAG, "invalid filename index");
117126
return;
118127
}

0 commit comments

Comments
 (0)