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

tests: add driver_grove_ledbar test application

This commit is contained in:
smlng 2017-06-12 22:31:49 +02:00
parent e5e933e332
commit 4fc150dfb9
4 changed files with 127 additions and 0 deletions

View File

@ -0,0 +1,20 @@
APPLICATION = driver_grove_ledbar
include ../Makefile.tests_common
USEMODULE += grove_ledbar
# set default device parameters in case they are undefined
# the following params are for board pba-d-01-kw2x and pins PA01 and PA02
TEST_GROVE_LEDBAR_CLK ?= GPIO_PIN\(0,1\)
TEST_GROVE_LEDBAR_DAT ?= GPIO_PIN\(0,2\)
TEST_GROVE_LEDBAR_DIR ?= GROVE_LEDBAR_G2R
# export parameters
CFLAGS += -DGROVE_LEDBAR_CLK=$(TEST_GROVE_LEDBAR_CLK)
CFLAGS += -DGROVE_LEDBAR_DAT=$(TEST_GROVE_LEDBAR_DAT)
CFLAGS += -DGROVE_LEDBAR_DIR=$(TEST_GROVE_LEDBAR_DIR)
test:
tests/01-run.py
include $(RIOTBASE)/Makefile.include

View File

@ -0,0 +1,22 @@
# About
This is a test application for the Seeed Studio Grove LED bar module [1].
# Details
This test application will initialize a Groove LED bar with the configuration
as specified in the `grove_ledbar_params.h` file. To connect the LED bar with
your board use the following pinout:
- Pin GND is connected directly to GND.
- Pin VCC is connected directly to VCC +3.3V, or 5V if your board allows that.
- Pin DCKI is the clock pin and is connected to a free GPIO
- Pin DI is the data pin and is connected to a free GPIO, too
for the 2 latter pins note the port and pin number and adapt the Makefile
accordingly.
The test application will light up the LED bar several times, running from 0%
up to 100% and down to 0% again.
[1]: https://www.seeedstudio.com/Grove-LED-Bar-v2.0-p-2474.html

View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2017 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.
*/
/**
* @ingroup tests
* @{
*
* @file
* @brief Test application for the Grove ledbar
*
* @author Sebastian Meiling <s@mlng.net>
*
* @}
*/
#include <stdio.h>
#include "log.h"
#include "xtimer.h"
#include "grove_ledbar.h"
#include "grove_ledbar_params.h"
#define TEST_RUNS (5U)
#define TEST_STEP (5U)
#define TEST_WAIT (42*US_PER_MS)
int main(void)
{
grove_ledbar_t dev;
/* init display */
puts("[START]");
if (grove_ledbar_init(&dev, &grove_ledbar_params[0]) != 0) {
puts("[FAILED]");
return 1;
}
LOG_INFO(" stepwise increase LED bar to 100%% and then decrease to 0%%.\n\n");
for (unsigned r = 0; r < TEST_RUNS; ++r) {
LOG_INFO(" >>> round %u\n", (r+1));
uint8_t lvl = 0;
while (lvl < GROVE_LEDBAR_MAX - TEST_STEP) {
grove_ledbar_set(&dev, lvl);
lvl += TEST_STEP;
xtimer_usleep(TEST_WAIT);
}
grove_ledbar_set(&dev, GROVE_LEDBAR_MAX);
/* turn all off */
xtimer_usleep(TEST_WAIT);
lvl = GROVE_LEDBAR_MAX;
while (lvl > TEST_STEP) {
grove_ledbar_set(&dev, lvl);
lvl -= TEST_STEP;
xtimer_usleep(TEST_WAIT);
}
/* turn all off */
grove_ledbar_clear(&dev);
}
puts("[SUCCESS]");
return 0;
}

View File

@ -0,0 +1,20 @@
#!/usr/bin/env python3
# Copyright (C) 2016 Kaspar Schleiser <kaspar@schleiser.de>
# 2017 Sebastian Meiling <s@mlng.net>
#
# 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.
import os
import sys
sys.path.append(os.path.join(os.environ['RIOTBASE'], 'dist/tools/testrunner'))
import testrunner
def testfunc(child):
child.expect_exact(u"[SUCCESS]", timeout=60)
if __name__ == "__main__":
sys.exit(testrunner.run(testfunc))