Kenji Arai
/
Check_VL6180XA1_ToF
Check program for 6180XA1_simple lib.
main.cpp
- Committer:
- kenjiArai
- Date:
- 2018-01-28
- Revision:
- 0:91db3c5d99f6
- Child:
- 1:163bbf3bfc20
File content as of revision 0:91db3c5d99f6:
/* * Mbed Application program * Time-of-Flight ranging and gesture detection sensor / STMicro VL6180XA1 * https://os.mbed.com/components/X-NUCLEO-6180XA1-Proximity-and-ambient-l/ * * Strawberry Linux * https://strawberry-linux.com/catalog/items?code=16180 * * -------- TESTED ONLY ON Strawberry board -------- * With Nucleo-F446RE Mbed board * * Copyright (c) 2018 Kenji Arai / JH1PJL * http://www.page.sannet.ne.jp/kenjia/index.html * http://mbed.org/users/kenjiArai/ * Created: January 25th, 2018 * Revised: January 28th, 2018 */ /* If you switch MY_LOG definition zero to 1 in vl6180x_platform.h line 37, you may have a trouble for Serial class due to line order VL6180X.h file and Serial constractor! */ // Include -------------------------------------------------------------------- #include "mbed.h" #include "VL6180X.h" // Definition ----------------------------------------------------------------- // Constructor ---------------------------------------------------------------- DigitalOut myled(LED1); Serial pc(USBTX, USBRX); DevI2C i2c(I2C_SDA, I2C_SCL); // I2C, Chip Enable, Interrut input VL6180X sensor(i2c, D7, NC); Timer t; // RAM ------------------------------------------------------------------------ // ROM / Constant data -------------------------------------------------------- // Function prototypes -------------------------------------------------------- //------------------------------------------------------------------------------ // Control Program //------------------------------------------------------------------------------ int main() { // int status = 0; uint32_t lux; uint32_t dist; uint32_t count = 0; uint32_t tm; while (true) { t.reset(); t.start(); myled = !myled; sensor.get_distance(&dist); sensor.get_lux(&lux); pc.printf("Distance: %4d, Lux: %4d, ", dist, lux); tm = t.read_ms(); wait_ms(200 - tm); pc.printf("Looptime: %4d, Count:%5d\r\n", t.read_ms(), count++); } }