From 12a0adc57cd976b1be807a9b7c70fd91593605b6 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 19 May 2021 09:59:00 +0200 Subject: [PATCH 1/2] tests/disp_dev: use auto_init_screen This removes the explicit dependency to ili9341 driver --- tests/disp_dev/Makefile | 2 +- tests/disp_dev/main.c | 34 +++++++++++++++++++--------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/tests/disp_dev/Makefile b/tests/disp_dev/Makefile index 94579d55a2..8c571927ad 100644 --- a/tests/disp_dev/Makefile +++ b/tests/disp_dev/Makefile @@ -3,7 +3,7 @@ include ../Makefile.tests_common DISABLE_MODULE += test_utils_interactive_sync -USEMODULE += ili9341 +USEMODULE += auto_init_screen USEMODULE += disp_dev include $(RIOTBASE)/Makefile.include diff --git a/tests/disp_dev/main.c b/tests/disp_dev/main.c index e658128905..ab9e49f7cd 100644 --- a/tests/disp_dev/main.c +++ b/tests/disp_dev/main.c @@ -22,40 +22,44 @@ #include "disp_dev.h" -#include "ili9341.h" -#include "ili9341_params.h" -#include "ili9341_disp_dev.h" - #include "riot_logo.h" #include "test_utils/expect.h" -static ili9341_t ili9341; +#if IS_USED(MODULE_ILI9341) +#include "ili9341.h" +#endif int main(void) { - ili9341_init(&ili9341, &ili9341_params[0]); + /* Use the first screen */ + disp_dev_reg_t *disp_dev = disp_dev_reg_find_screen(0); + if (!disp_dev) { + puts("No screen found!"); + return -1; + } - disp_dev_t *dev = (disp_dev_t *)&ili9341; - dev->driver = &ili9341_disp_dev_driver; - - disp_dev_set_invert(dev, true); + disp_dev_set_invert(disp_dev->dev, true); disp_dev_backlight_on(); - uint16_t max_width = disp_dev_width(dev); - uint16_t max_height = disp_dev_height(dev); + uint16_t max_width = disp_dev_width(disp_dev->dev); + uint16_t max_height = disp_dev_height(disp_dev->dev); - expect(max_width == ili9341.params->lines); +#if IS_USED(MODULE_ILI9341) + ili9341_t *ili9341 = (ili9341_t *)disp_dev->dev; + expect(ili9341); + expect(max_width == ili9341->params->lines); expect(max_height == 240); +#endif uint16_t color = 0; for (uint16_t y = 0; y < max_height; ++y) { for (uint16_t x = 0; x < max_width; ++x) { - disp_dev_map(dev, x, x, y, y, &color); + disp_dev_map(disp_dev->dev, x, x, y, y, &color); } } - disp_dev_map(dev, 95, 222, 85, 153, (const uint16_t *)picture); + disp_dev_map(disp_dev->dev, 95, 222, 85, 153, (const uint16_t *)picture); puts("SUCCESS"); From 4b2f9af90ff3294ac2e4073c8356c22fb47f3306 Mon Sep 17 00:00:00 2001 From: Alexandre Abadie Date: Wed, 19 May 2021 10:01:03 +0200 Subject: [PATCH 2/2] tests/disp_dev: improve screen cleanup speed --- tests/disp_dev/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/disp_dev/main.c b/tests/disp_dev/main.c index ab9e49f7cd..de40b10098 100644 --- a/tests/disp_dev/main.c +++ b/tests/disp_dev/main.c @@ -30,6 +30,9 @@ #include "ili9341.h" #endif +#define DISPLAY_BUFFER_MAX_SIZE (320) +static uint16_t display_buffer[DISPLAY_BUFFER_MAX_SIZE] = { 0 }; + int main(void) { /* Use the first screen */ @@ -52,11 +55,8 @@ int main(void) expect(max_height == 240); #endif - uint16_t color = 0; for (uint16_t y = 0; y < max_height; ++y) { - for (uint16_t x = 0; x < max_width; ++x) { - disp_dev_map(disp_dev->dev, x, x, y, y, &color); - } + disp_dev_map(disp_dev->dev, 0, max_width - 1, y, y, display_buffer); } disp_dev_map(disp_dev->dev, 95, 222, 85, 153, (const uint16_t *)picture);