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

tests/driver_st7735: add test application

This commit is contained in:
Francisco Molina 2021-03-15 15:13:36 +01:00 committed by Alexandre Abadie
parent c5cc2966ff
commit be5f450a43
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
6 changed files with 1205 additions and 0 deletions

View File

@ -0,0 +1,15 @@
# Copyright (c) 2021 HAW Hamburg
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
#
config NO_RIOT_IMAGE
bool
prompt "Avoid showing the RIOT logo on the test" if !HAS_ARCH_AVR8
# the logo does not usually fit in AVR8
default y if HAS_ARCH_AVR8
help
Say y to avoid loading the RIOT logo on the test application. Useful for architectures
storing it in a limited RAM.

View File

@ -0,0 +1,24 @@
BOARD ?= stm32f429i-disc1
include ../Makefile.tests_common
USEMODULE += st7735
USEMODULE += ztimer
USEMODULE += ztimer_msec
# As there is an 'Kconfig' we want to explicitly disable Kconfig by setting
# the variable to empty
SHOULD_RUN_KCONFIG ?=
include $(RIOTBASE)/Makefile.include
# Check if being configured via Kconfig
ifndef CONFIG_KCONFIG_USEMODULE_LCD
CFLAGS += -DCONFIG_LCD_LE_MODE
# The AVR architecture stores the image in the RAM, this usually doesn't fit.
# This flag excludes the image from the test
ifneq (,$(filter arch_avr8,$(FEATURES_USED)))
CFLAGS += -DCONFIG_NO_RIOT_IMAGE
endif
endif

View File

@ -0,0 +1,6 @@
BOARD_INSUFFICIENT_MEMORY := \
nucleo-l011k4 \
samd10-xmini \
stk3200 \
stm32f030f4-demo \
#

View File

@ -0,0 +1,5 @@
# this file enables modules defined in Kconfig. Do not use this file for
# application configuration. This is only needed during migration.
CONFIG_MODULE_ST7735=y
CONFIG_MODULE_ZTIMER=y
CONFIG_MODULE_ZTIMER_MSEC=y

View File

@ -0,0 +1,94 @@
/*
* Copyright (C) 2018 Koen Zandberg <koen@bergzand.net>
* 2021 Francisco Molina
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Test application for lcd tft displays
*
* @author Koen Zandberg <koen@bergzand.net>
* @author Francisco Molina <francois-xavier.molina@inria.fr>
*
* @}
*/
#include <stdio.h>
#include "timex.h"
#include "ztimer.h"
#include "board.h"
#include "lcd.h"
#include "riot_logo.h"
#include "st7735.h"
#include "st7735_params.h"
int main(void)
{
lcd_t dev;
dev.driver = &lcd_st7735_driver;
puts("lcd TFT display test application");
/* initialize the sensor */
printf("Initializing display...");
/* Enable backlight if macro is defined */
#ifdef BACKLIGHT_ON
BACKLIGHT_ON;
#endif
if (lcd_init(&dev, &st7735_params[0].params) == 0) {
puts("[OK]");
}
else {
puts("[Failed]");
return 1;
}
puts("lcd TFT display filling map");
lcd_fill(&dev, 0, dev.params->lines, 0, dev.params->rgb_channels, 0x0000);
puts("lcd TFT display map filled");
/* Fill square with blue */
puts("Drawing blue rectangle");
lcd_fill(&dev, 0, dev.params->lines / 3, 0, dev.params->rgb_channels, 0x001F);
ztimer_sleep(ZTIMER_MSEC, 1 * MS_PER_SEC);
puts("Drawing green rectangle");
lcd_fill(&dev, dev.params->lines / 3, 2 * (dev.params->lines / 3), 0,
dev.params->rgb_channels, 0x07E0);
ztimer_sleep(ZTIMER_MSEC, 1 * MS_PER_SEC);
puts("Drawing red rectangle");
lcd_fill(&dev, 2 * (dev.params->lines / 3), dev.params->lines, 0,
dev.params->rgb_channels, 0xf800);
ztimer_sleep(ZTIMER_MSEC, 1 * MS_PER_SEC);
lcd_invert_on(&dev);
puts("lcd TFT display inverted");
ztimer_sleep(ZTIMER_MSEC, 1 * MS_PER_SEC);
lcd_invert_off(&dev);
puts("lcd TFT display normal");
puts("lcd TFT display clear screen");
lcd_fill(&dev, 0, dev.params->lines, 0, dev.params->rgb_channels, 0x0000);
#ifndef CONFIG_NO_RIOT_IMAGE
/* Approximate middle of the display */
uint8_t x1 = (dev.params->lines / 2) - (RIOT_LOGO_WIDTH / 2);
uint8_t y1 = (dev.params->rgb_channels / 2) - (RIOT_LOGO_HEIGHT / 2);
lcd_pixmap(&dev, x1, x1 + RIOT_LOGO_WIDTH - 1, y1, y1 + RIOT_LOGO_HEIGHT - 1,
(const uint16_t *)picture);
#endif
while (1) {}
return 0;
}

File diff suppressed because it is too large Load Diff