diff --git a/tests/pkg_u8g2/Makefile b/tests/pkg_u8g2/Makefile index 67f7077af843967ea53ea1b6bd818906d071a660..661cbd0446e632f5bb1f6606d6c1403bfc088e76 100644 --- a/tests/pkg_u8g2/Makefile +++ b/tests/pkg_u8g2/Makefile @@ -1,54 +1,59 @@ APPLICATION = pkg_u8g2 include ../Makefile.tests_common -# These boards have not sufficient memory -BOARD_BLACKLIST += chronos msb-430 msb-430h telosb wsn430-v1_3b wsn430-v1_4 z1 - USEMODULE += xtimer USEPKG += u8g2 # set default device parameters in case they are undefined -TEST_U8G2_OUTPUT ?= 1 -TEST_U8G2_DISPLAY ?= u8g2_Setup_ssd1306_128x64_noname_1 +TEST_OUTPUT ?= 1 + +TEST_I2C ?= 0 +TEST_SPI ?= 0 + +TEST_ADDR ?= 0x78 -TEST_U8G2_I2C ?= 0 -TEST_U8G2_SPI ?= 0 +TEST_PIN_CS ?= GPIO_PIN\(0,0\) +TEST_PIN_DC ?= GPIO_PIN\(0,0\) +TEST_PIN_RESET ?= GPIO_PIN\(0,0\) -TEST_U8G2_ADDR ?= 0x78 +ifeq ($(TEST_OUTPUT),3) +TEST_DISPLAY ?= u8g2_Setup_ssd1306_128x64_noname_1 +endif -TEST_U8G2_PIN_CS ?= GPIO_PIN\(0,0\) -TEST_U8G2_PIN_DC ?= GPIO_PIN\(0,0\) -TEST_U8G2_PIN_RESET ?= GPIO_PIN\(0,0\) +ifeq ($(TEST_OUTPUT),4) +TEST_DISPLAY ?= u8g2_Setup_ssd1306_i2c_128x64_noname_1 +endif # features depend on output type -ifeq ($(TEST_U8G2_OUTPUT),1) +ifeq ($(TEST_OUTPUT),1) USEMODULE += u8g2_utf8 endif -ifeq ($(TEST_U8G2_OUTPUT),2) +ifeq ($(TEST_OUTPUT),2) USEMODULE += u8g2_sdl endif -ifeq ($(TEST_U8G2_OUTPUT),3) +ifeq ($(TEST_OUTPUT),3) FEATURES_REQUIRED += periph_gpio periph_spi endif -ifeq ($(TEST_U8G2_OUTPUT),4) +ifeq ($(TEST_OUTPUT),4) FEATURES_REQUIRED += periph_gpio periph_i2c endif # export parameters -CFLAGS += -DTEST_U8G2_OUTPUT=$(TEST_U8G2_OUTPUT) -CFLAGS += -DTEST_U8G2_DISPLAY=$(TEST_U8G2_DISPLAY) +CFLAGS += -DTEST_OUTPUT=$(TEST_OUTPUT) + +CFLAGS += -DTEST_SPI=$(TEST_SPI) +CFLAGS += -DTEST_I2C=$(TEST_I2C) -CFLAGS += -DTEST_U8G2_SPI=$(TEST_U8G2_SPI) -CFLAGS += -DTEST_U8G2_I2C=$(TEST_U8G2_I2C) +CFLAGS += -DTEST_ADDR=$(TEST_ADDR) -CFLAGS += -DTEST_U8G2_ADDR=$(TEST_U8G2_ADDR) +CFLAGS += -DTEST_PIN_CS=$(TEST_PIN_CS) +CFLAGS += -DTEST_PIN_DC=$(TEST_PIN_DC) +CFLAGS += -DTEST_PIN_RESET=$(TEST_PIN_RESET) -CFLAGS += -DTEST_U8G2_PIN_CS=$(TEST_U8G2_PIN_CS) -CFLAGS += -DTEST_U8G2_PIN_DC=$(TEST_U8G2_PIN_DC) -CFLAGS += -DTEST_U8G2_PIN_RESET=$(TEST_U8G2_PIN_RESET) +CFLAGS += -DTEST_DISPLAY=$(TEST_DISPLAY) include $(RIOTBASE)/Makefile.include diff --git a/tests/pkg_u8g2/README.md b/tests/pkg_u8g2/README.md index 5a0aa59abf47262444f8691692b32eebd5b3b902..c03de2ab8c67c2507f571a8f608fccc45671e01b 100644 --- a/tests/pkg_u8g2/README.md +++ b/tests/pkg_u8g2/README.md @@ -14,31 +14,31 @@ This test application will initialize the U8g2 to output on one of the following Note: you may have to run `make clean` between different output modes. ### Output to terminal -To output to this virtual screen, supply `TEST_U8G2_OUTPUT=1` to the `make` command. +To output to this virtual screen, supply `TEST_OUTPUT=1` to the `make` command. ### Output to SDL -To output to this virtual screen, supply `TEST_U8G2_OUTPUT=2` to the `make` command. +To output to this virtual screen, supply `TEST_OUTPUT=2` to the `make` command. This is a native-only option and requires SDL (32-bits) to be installed. ### Output to SPI -To output to screen, supply `TEST_U8G2_OUTPUT=3` to the `make` command. +To output to screen, supply `TEST_OUTPUT=3` to the `make` command. -* `TEST_U8G2_SPI` — The SPI device. -* `TEST_U8G2_PIN_CS` — If applicable, the CS pin. -* `TEST_U8G2_PIN_DC` — If applicable, the Command/Data pin. -* `TEST_U8G2_PIN_RESET` — If applicable, the reset pin. -* `TEST_U8G2_DISPLAY` — The used display driver (see https://github.com/olikraus/u8g2/wiki/u8g2setupc). Make sure you select a SPI compatible display. +* `TEST_SPI` — The SPI device. +* `TEST_PIN_CS` — If applicable, the CS pin. +* `TEST_PIN_DC` — If applicable, the Command/Data pin. +* `TEST_PIN_RESET` — If applicable, the reset pin. +* `TEST_DISPLAY` — The used display driver (see https://github.com/olikraus/u8g2/wiki/u8g2setupc). Make sure you select a SPI compatible display. ### Output to I2C -To output to screen, supply `TEST_U8G2_OUTPUT=4` to the `make` command. +To output to screen, supply `TEST_OUTPUT=4` to the `make` command. Furthermore, you can configure the following: -* `TEST_U8G2_I2C` — The I2C device. -* `TEST_U8G2_ADDR` — The address to write commands to. -* `TEST_U8G2_PIN_RESET` — If applicable, the reset pin. -* `TEST_U8G2_DISPLAY` — The used display driver (see https://github.com/olikraus/u8g2/wiki/u8g2setupc). Make sure you select an I2C compatible display. +* `TEST_I2C` — The I2C device. +* `TEST_ADDR` — The address to write commands to. +* `TEST_PIN_RESET` — If applicable, the reset pin. +* `TEST_DISPLAY` — The used display driver (see https://github.com/olikraus/u8g2/wiki/u8g2setupc). Make sure you select an I2C compatible display. ## Expected result The output of this test depends on the output mode and used hardware. If it works, the application cycles through three screens with the text: 'This is RIOT-OS'. diff --git a/tests/pkg_u8g2/main.c b/tests/pkg_u8g2/main.c index 602a8d428c6addb677daadb66bcb1c255502a72d..4787e441b477af202f9738e6add0b33bd07bfc32 100644 --- a/tests/pkg_u8g2/main.c +++ b/tests/pkg_u8g2/main.c @@ -18,42 +18,45 @@ * @} */ -#define TEST_U8G2_OUTPUT_STDOUT 1 -#define TEST_U8G2_OUTPUT_SDL 2 -#define TEST_U8G2_OUTPUT_SPI 3 -#define TEST_U8G2_OUTPUT_I2C 4 +#define TEST_OUTPUT_STDOUT 1 +#define TEST_OUTPUT_SDL 2 +#define TEST_OUTPUT_SPI 3 +#define TEST_OUTPUT_I2C 4 -#ifndef TEST_U8G2_OUTPUT -#error "TEST_U8G2_OUTPUT not defined" -#endif -#ifndef TEST_U8G2_DISPLAY -#error "TEST_U8G2_DISPLAY not defined" +#ifndef TEST_OUTPUT +#error "TEST_OUTPUT not defined" #endif -#if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_I2C -#ifndef TEST_U8G2_I2C -#error "TEST_U8G2_I2C not defined" +#if TEST_OUTPUT == TEST_OUTPUT_I2C +#ifndef TEST_I2C +#error "TEST_I2C not defined" +#endif +#ifndef TEST_ADDR +#error "TEST_ADDR not defined" #endif -#ifndef TEST_U8G2_ADDR -#error "TEST_U8G2_ADDR not defined" +#ifndef TEST_DISPLAY +#error "TEST_DISPLAY not defined" #endif -#ifndef TEST_U8G2_PIN_RESET -#error "TEST_U8G2_PIN_RESET not defined" +#ifndef TEST_PIN_RESET +#error "TEST_PIN_RESET not defined" #endif #endif -#if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_SPI -#ifndef TEST_U8G2_SPI -#error "TEST_U8G2_SPI not defined" +#if TEST_OUTPUT == TEST_OUTPUT_SPI +#ifndef TEST_SPI +#error "TEST_SPI not defined" +#endif +#ifndef TEST_DISPLAY +#error "TEST_DISPLAY not defined" #endif -#ifndef TEST_U8G2_PIN_CS -#error "TEST_U8G2_PIN_CS not defined" +#ifndef TEST_PIN_CS +#error "TEST_PIN_CS not defined" #endif -#ifndef TEST_U8G2_PIN_DC -#error "TEST_U8G2_PIN_DC not defined" +#ifndef TEST_PIN_DC +#error "TEST_PIN_DC not defined" #endif -#ifndef TEST_U8G2_PIN_RESET -#error "TEST_U8G2_PIN_RESET not defined" +#ifndef TEST_PIN_RESET +#error "TEST_PIN_RESET not defined" #endif #endif @@ -92,16 +95,16 @@ static const uint8_t logo[] = { 0x00, 0x00, 0x00, 0x00 }; -#if (TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_I2C) || (TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_SPI) +#if (TEST_OUTPUT == TEST_OUTPUT_I2C) || (TEST_OUTPUT == TEST_OUTPUT_SPI) /** * @brief RIOT-OS pin maping of U8g2 pin numbers to RIOT-OS GPIO pins. * @note To minimize the overhead, you can implement an alternative for * u8x8_gpio_and_delay_riotos. */ static gpio_t pins[] = { - [U8X8_PIN_CS] = TEST_U8G2_PIN_CS, - [U8X8_PIN_DC] = TEST_U8G2_PIN_DC, - [U8X8_PIN_RESET] = TEST_U8G2_PIN_RESET + [U8X8_PIN_CS] = TEST_PIN_CS, + [U8X8_PIN_DC] = TEST_PIN_DC, + [U8X8_PIN_RESET] = TEST_PIN_RESET }; /** @@ -120,38 +123,38 @@ int main(void) u8g2_t u8g2; /* initialize to stdout */ -#if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_STDOUT - puts("initializing to stdout."); +#if TEST_OUTPUT == TEST_OUTPUT_STDOUT + puts("Initializing to stdout."); u8g2_SetupBuffer_Utf8(&u8g2, U8G2_R0); #endif /* initialize to virtual SDL (native only) */ -#if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_SDL - puts("initializing to SDL."); +#if TEST_OUTPUT == TEST_OUTPUT_SDL + puts("Initializing to SDL."); u8g2_SetupBuffer_SDL_128x64_4(&u8g2, U8G2_R0); #endif /* initialize to SPI */ -#if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_SPI - puts("initializing to SPI."); +#if TEST_OUTPUT == TEST_OUTPUT_SPI + puts("Initializing to SPI."); - TEST_U8G2_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_riotos_hw_spi, u8x8_gpio_and_delay_riotos); + TEST_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_riotos_hw_spi, u8x8_gpio_and_delay_riotos); u8g2_SetPins(&u8g2, pins, pins_enabled); - u8g2_SetDevice(&u8g2, TEST_U8G2_SPI); + u8g2_SetDevice(&u8g2, TEST_SPI); #endif /* initialize to I2C */ -#if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_I2C - puts("initializing to I2C."); +#if TEST_OUTPUT == TEST_OUTPUT_I2C + puts("Initializing to I2C."); - TEST_U8G2_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_riotos_hw_i2c, u8x8_gpio_and_delay_riotos); + TEST_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_riotos_hw_i2c, u8x8_gpio_and_delay_riotos); u8g2_SetPins(&u8g2, pins, pins_enabled); - u8g2_SetDevice(&u8g2, TEST_U8G2_I2C); - u8g2_SetI2CAddress(&u8g2, TEST_U8G2_ADDR); + u8g2_SetDevice(&u8g2, TEST_I2C); + u8g2_SetI2CAddress(&u8g2, TEST_ADDR); #endif /* initialize the display */ @@ -172,14 +175,16 @@ int main(void) if (screen == 0) { u8g2_DrawStr(&u8g2, 12, 22, "THIS"); - } else if (screen == 1) { + } + else if (screen == 1) { u8g2_DrawStr(&u8g2, 24, 22, "IS"); - } else if (screen == 2) { + } + else if (screen == 2) { u8g2_DrawBitmap(&u8g2, 0, 0, 8, 32, logo); } } while (u8g2_NextPage(&u8g2)); -#if TEST_U8G2_OUTPUT == TEST_U8G2_OUTPUT_STDOUT +#if TEST_OUTPUT == TEST_OUTPUT_STDOUT /* transfer screen buffer to stdout */ utf8_show(); #endif