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

matrix_keypad: add test application

This commit is contained in:
Koen Zandberg 2022-10-13 14:39:43 +02:00
parent 7f3cbfdfc7
commit 1d33455116
No known key found for this signature in database
GPG Key ID: BA1718B37D79F51C
3 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,7 @@
include ../Makefile.tests_common
# required modules
USEMODULE += matrix_keypad
USEMODULE += ztimer_msec
include $(RIOTBASE)/Makefile.include

View File

@ -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.

View File

@ -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 <koen@bergzand.net>
*
* @}
*/
#include <stdio.h>
#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;
}