Skip to content

Commit

Permalink
tests: add VL53L1X ToF ranging sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
gschorcht committed Nov 12, 2018
1 parent b64d549 commit f54431c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/driver_vl53l1x_st/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include ../Makefile.tests_common

USEMODULE += vl53l1x
USEMODULE += periph_i2c
USEMODULE += xtimer

include $(RIOTBASE)/Makefile.include
51 changes: 51 additions & 0 deletions tests/driver_vl53l1x_st/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2018 Gunar Schorcht
*
* 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
* @brief Test application for ST VL53L1X Time-of-Flight distance sensor
* @author Gunar Schorcht <gunar@schorcht.net>
* @file
*
*/

#include <stdio.h>
#include "xtimer.h"

#include "vl53l1x.h"
#include "vl53l1x_params.h"

int main(void)
{
/* Initialize the sensor */
vl53l1x_t dev;

/* initialize the sensor */
puts("VL53L1X Time-of-Flight distance sensor\n");
puts("Initializing VL53L1X sensor");

if (vl53l1x_init(&dev, &vl53l1x_params[0]) == VL53L1X_OK) {
printf("[OK]\n");
}
else {
printf("[Failed]\n");
return 1;
}

while (1) {
xtimer_usleep(50 * US_PER_MS);

int16_t data;
if (vl53l1x_data_ready(&dev) == VL53L1X_OK &&
vl53l1x_read(&dev, &data) == VL53L1X_OK) {
printf("range=%d [mm]\n", data);
}
}

return 0;
}

0 comments on commit f54431c

Please sign in to comment.