1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

tests/touch_dev: use auto_init_screen

This commit is contained in:
Alexandre Abadie 2021-05-19 11:29:42 +02:00
parent 967cbcd7e1
commit e7983908f9
No known key found for this signature in database
GPG Key ID: 1C919A403CAE1405
2 changed files with 19 additions and 15 deletions

View File

@ -3,7 +3,7 @@ include ../Makefile.tests_common
DISABLE_MODULE += test_utils_interactive_sync
USEMODULE += stmpe811
USEMODULE += auto_init_screen
USEMODULE += touch_dev
USEMODULE += xtimer

View File

@ -25,13 +25,10 @@
#include "touch_dev.h"
#if IS_USED(MODULE_STMPE811)
#include "stmpe811.h"
#include "stmpe811_params.h"
#include "stmpe811_touch_dev.h"
#include "test_utils/expect.h"
static stmpe811_t stmpe811;
#endif
static void _touch_event_cb(void *arg)
{
@ -41,22 +38,29 @@ static void _touch_event_cb(void *arg)
int main(void)
{
stmpe811_init(&stmpe811, &stmpe811_params[0], _touch_event_cb, NULL);
/* Use the first screen */
touch_dev_reg_t *touch_dev = touch_dev_reg_find_screen(0);
if (!touch_dev) {
puts("No screen found!");
return -1;
}
touch_dev_t *dev = (touch_dev_t *)&stmpe811;
dev->driver = &stmpe811_touch_dev_driver;
touch_dev_set_touch_event_callback(touch_dev->dev, _touch_event_cb, NULL);
uint16_t xmax = touch_dev_width(dev);
uint16_t ymax = touch_dev_height(dev);
#if IS_USED(MODULE_STMPE811)
uint16_t xmax = touch_dev_width(touch_dev->dev);
uint16_t ymax = touch_dev_height(touch_dev->dev);
expect(xmax == stmpe811.params.xmax);
expect(ymax == stmpe811.params.ymax);
stmpe811_t *stmpe811 = (stmpe811_t *)touch_dev->dev;
expect(xmax == stmpe811->params.xmax);
expect(ymax == stmpe811->params.ymax);
#endif
uint8_t last_touches = touch_dev_touches(dev, NULL, 1);
uint8_t last_touches = touch_dev_touches(touch_dev->dev, NULL, 1);
while (1) {
touch_t touches[1];
uint8_t current_touches = touch_dev_touches(dev, touches, 1);
uint8_t current_touches = touch_dev_touches(touch_dev->dev, touches, 1);
if (current_touches != last_touches) {
if (current_touches == 0) {