diff --git a/tests/driver_matrix_keypad/Makefile b/tests/driver_matrix_keypad/Makefile new file mode 100644 index 0000000000..38167d91d1 --- /dev/null +++ b/tests/driver_matrix_keypad/Makefile @@ -0,0 +1,7 @@ +include ../Makefile.tests_common + +# required modules +USEMODULE += matrix_keypad +USEMODULE += ztimer_msec + +include $(RIOTBASE)/Makefile.include diff --git a/tests/driver_matrix_keypad/README.md b/tests/driver_matrix_keypad/README.md new file mode 100644 index 0000000000..976b30e8b6 --- /dev/null +++ b/tests/driver_matrix_keypad/README.md @@ -0,0 +1,10 @@ +matrix_keypad +============= + +This is a test application for the matrix_keypad module. + +Usage +===== + +The test application will print the key row and column when it is pressed or +released. diff --git a/tests/driver_matrix_keypad/main.c b/tests/driver_matrix_keypad/main.c new file mode 100644 index 0000000000..fe45af0786 --- /dev/null +++ b/tests/driver_matrix_keypad/main.c @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2022 Koen Zandberg + * + * 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 the matrix_keypad driver + * + * @author Koen Zandberg + * + * @} + */ + +#include + +#include "matrix_keypad.h" +#include "matrix_keypad_params.h" +#include "ztimer.h" + +void _callback(void *arg, size_t col, size_t row, bool state) +{ + (void)arg; + printf("Key switch at column %u and row %u is ", (unsigned)col, (unsigned)row); + if (state) { + puts("pressed!"); + } + else { + puts("released!"); + } +} + +int main(void) +{ + matrix_keypad_t dev; + + puts("Generated RIOT application: 'matrix_keypad'"); + if (matrix_keypad_init(&dev, &matrix_keypad_params[0], _callback, NULL) == 0) { + puts("[OK]\n"); + } + + while (true) { + matrix_keypad_scan(&dev); + ztimer_sleep(ZTIMER_MSEC, 1); + } + return 0; +}