1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

tests/pkg_u8g2: update tests

This commit is contained in:
petr 2019-01-03 00:39:56 +01:00 committed by Bas Stottelaar
parent b253f61a7f
commit 8fee219dc0
3 changed files with 33 additions and 39 deletions

View File

@ -12,33 +12,33 @@ TEST_SPI ?= 0
TEST_ADDR ?= 0x3c
TEST_PIN_CS ?= GPIO_PIN\(0,0\)
TEST_PIN_DC ?= GPIO_PIN\(0,0\)
TEST_PIN_RESET ?= GPIO_PIN\(0,0\)
TEST_PIN_CS ?= GPIO_UNDEF
TEST_PIN_DC ?= GPIO_UNDEF
TEST_PIN_RESET ?= GPIO_UNDEF
ifeq ($(TEST_OUTPUT),3)
TEST_DISPLAY ?= u8g2_Setup_ssd1306_128x64_noname_1
TEST_DISPLAY ?= u8g2_Setup_ssd1306_128x64_noname_1
endif
ifeq ($(TEST_OUTPUT),4)
TEST_DISPLAY ?= u8g2_Setup_ssd1306_i2c_128x64_noname_1
TEST_DISPLAY ?= u8g2_Setup_ssd1306_i2c_128x64_noname_1
endif
# features depend on output type
ifeq ($(TEST_OUTPUT),1)
USEMODULE += u8g2_utf8
USEMODULE += u8g2_utf8
endif
ifeq ($(TEST_OUTPUT),2)
USEMODULE += u8g2_sdl
USEMODULE += u8g2_sdl
endif
ifeq ($(TEST_OUTPUT),3)
FEATURES_REQUIRED += periph_gpio periph_spi
FEATURES_REQUIRED += periph_gpio periph_spi
endif
ifeq ($(TEST_OUTPUT),4)
FEATURES_REQUIRED += periph_gpio periph_i2c
FEATURES_REQUIRED += periph_gpio periph_i2c
endif
# export parameters

View File

@ -11,7 +11,7 @@ This test application will initialize the U8g2 to output on one of the following
* output to I2C graphics screen.
* output to SPI graphics screen.
Note: you may have to run `make clean` between different output modes.
Note: you may have to run `make clean` after you changed to a different output mode.
### Output to terminal
To output to this virtual screen, supply `TEST_OUTPUT=1` to the `make` command.
@ -26,7 +26,7 @@ To output to screen, supply `TEST_OUTPUT=3` to the `make` command.
* `TEST_SPI` — The SPI device.
* `TEST_PIN_CS` — If applicable, the CS pin.
* `TEST_PIN_DC` — If applicable, the Command/Data pin.
* `TEST_PIN_DC` — If applicable, the Data/Command 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.

View File

@ -71,7 +71,9 @@
#endif
#include "xtimer.h"
#include "u8g2.h"
#include "u8x8_riotos.h"
/**
* @brief RIOT-OS logo, 64x32 pixels at 8 pixels per byte.
@ -101,28 +103,6 @@ static const uint8_t logo[] = {
0x00, 0x00, 0x00, 0x00
};
#if (TEST_OUTPUT == TEST_OUTPUT_I2C) || (TEST_OUTPUT == TEST_OUTPUT_SPI)
/**
* @brief RIOT-OS pin mapping 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_PIN_CS,
[U8X8_PIN_DC] = TEST_PIN_DC,
[U8X8_PIN_RESET] = TEST_PIN_RESET
};
/**
* @brief Bit mapping to indicate which pins are set.
*/
static uint32_t pins_enabled = (
(1 << U8X8_PIN_CS) +
(1 << U8X8_PIN_DC) +
(1 << U8X8_PIN_RESET)
);
#endif
int main(void)
{
uint32_t screen = 0;
@ -146,20 +126,34 @@ int main(void)
#if TEST_OUTPUT == TEST_OUTPUT_SPI
puts("Initializing to SPI.");
TEST_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_riotos_hw_spi, u8x8_gpio_and_delay_riotos);
TEST_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_hw_spi_riotos, u8x8_gpio_and_delay_riotos);
u8g2_SetPins(&u8g2, pins, pins_enabled);
u8g2_SetDevice(&u8g2, SPI_DEV(TEST_SPI));
u8x8_riotos_t user_data =
{
.device_index = TEST_SPI,
.pin_cs = TEST_PIN_CS,
.pin_dc = TEST_PIN_DC,
.pin_reset = TEST_PIN_RESET,
};
u8g2_SetUserPtr(&u8g2, &user_data);
#endif
/* initialize to I2C */
#if TEST_OUTPUT == TEST_OUTPUT_I2C
puts("Initializing to I2C.");
TEST_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_riotos_hw_i2c, u8x8_gpio_and_delay_riotos);
TEST_DISPLAY(&u8g2, U8G2_R0, u8x8_byte_hw_i2c_riotos, u8x8_gpio_and_delay_riotos);
u8g2_SetPins(&u8g2, pins, pins_enabled);
u8g2_SetDevice(&u8g2, I2C_DEV(TEST_I2C));
u8x8_riotos_t user_data =
{
.device_index = TEST_I2C,
.pin_cs = TEST_PIN_CS,
.pin_dc = TEST_PIN_DC,
.pin_reset = TEST_PIN_RESET,
};
u8g2_SetUserPtr(&u8g2, &user_data);
u8g2_SetI2CAddress(&u8g2, TEST_ADDR);
#endif