mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/driver_isl2920: update with new API
This commit is contained in:
parent
e006165b50
commit
94aa6d9cc0
@ -5,12 +5,4 @@ FEATURES_REQUIRED = periph_i2c
|
||||
USEMODULE += isl29020
|
||||
USEMODULE += xtimer
|
||||
|
||||
# set default device parameters in case they are undefined
|
||||
TEST_ISL29020_I2C ?= I2C_DEV\(0\)
|
||||
TEST_ISL29020_ADDR ?= 68
|
||||
|
||||
# export parameters
|
||||
CFLAGS += -DTEST_ISL29020_I2C=$(TEST_ISL29020_I2C)
|
||||
CFLAGS += -DTEST_ISL29020_ADDR=$(TEST_ISL29020_ADDR)
|
||||
|
||||
include $(RIOTBASE)/Makefile.include
|
||||
|
@ -18,30 +18,21 @@
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifndef TEST_ISL29020_I2C
|
||||
#error "TEST_ISL29020_I2C not defined"
|
||||
#endif
|
||||
#ifndef TEST_ISL29020_ADDR
|
||||
#error "TEST_ISL29020_ADDR not defined"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "xtimer.h"
|
||||
#include "isl29020.h"
|
||||
#include "isl29020_params.h"
|
||||
|
||||
#define MODE ISL29020_MODE_AMBIENT
|
||||
#define RANGE ISL29020_RANGE_16K
|
||||
#define SLEEP (250 * 1000U)
|
||||
|
||||
int main(void)
|
||||
{
|
||||
isl29020_t dev;
|
||||
int value;
|
||||
|
||||
puts("ISL29020 light sensor test application\n");
|
||||
printf("Initializing ISL29020 sensor at I2C_%i... ", TEST_ISL29020_I2C);
|
||||
if (isl29020_init(&dev, TEST_ISL29020_I2C, TEST_ISL29020_ADDR, RANGE, MODE) == 0) {
|
||||
puts("Initializing ISL29020 sensor");
|
||||
if (isl29020_init(&dev, &isl29020_params[0]) == 0) {
|
||||
puts("[OK]\n");
|
||||
}
|
||||
else {
|
||||
@ -50,8 +41,7 @@ int main(void)
|
||||
}
|
||||
|
||||
while (1) {
|
||||
value = isl29020_read(&dev);
|
||||
printf("Light value: %5i LUX\n", value);
|
||||
printf("Light value: %5i LUX\n", isl29020_read(&dev));
|
||||
xtimer_usleep(SLEEP);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user