Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: added test app for the bh1750fvi driver
- Loading branch information
1 parent
3bf85cb
commit 49dd104
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
APPLICATION = driver_pir | ||
include ../Makefile.tests_common | ||
|
||
USEMODULE += xtimer | ||
USEMODULE += bh1750fvi | ||
|
||
include $(RIOTBASE)/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# About | ||
This test application is created for testing/demonstrating the BH1750FVI driver. | ||
It uses the default device parameters as specified in | ||
`drivers/bh1750fvi/include/bh1750fvi_params.h`. To override these setting, you | ||
can simply do this by defining these parameters as compiler flags while uilding, | ||
e.g.: | ||
``` | ||
$ CFLAGS="-DBH1750FVI_PARAM_I2C=I2C_DEV(1)"" make all | ||
``` | ||
|
||
# Usage | ||
Simply flash this example to your board and it will read the sensor value 5 | ||
times per second and print the sampled value to STDIO. You can verify the values | ||
by simply covering the sensor or holding it in front of a bright light and see | ||
the change in the sensor readings accordingly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) 2016 Freie Universität Berlin | ||
* | ||
* 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 BH1750FVI ambient light sensor driver | ||
* | ||
* @author Hauke Petersen <hauke.petersen@fu-berlin.de> | ||
* | ||
* @} | ||
*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "xtimer.h" | ||
#include "bh1750fvi.h" | ||
#include "bh1750fvi_params.h" | ||
|
||
#define RATE (200 * MS_IN_USEC) /* 200ms */ | ||
|
||
int main(void) | ||
{ | ||
bh1750fvi_t dev; | ||
uint32_t last = xtimer_now(); | ||
|
||
puts("BH1750FVI ambient light sensor test\n"); | ||
|
||
/* initialize the device */ | ||
bh1750fvi_init(&dev, (bh1750fvi_params_t *)(&bh1750fvi_params)); | ||
|
||
/* periodically sample the sensor */ | ||
while(1) { | ||
uint16_t val = bh1750fvi_sample(&dev); | ||
printf("value: %5i lux\n", (int)val); | ||
xtimer_usleep_until(&last, RATE); | ||
} | ||
|
||
return 0; | ||
} |