fealkn
Dependencies: mbed LSM9DS1_Library VL53L0X
Diff: main.cpp
- Revision:
- 1:15e0c8f3d4a0
- Parent:
- 0:ea1c50666fc2
--- a/main.cpp Wed Apr 28 17:44:45 2021 +0000
+++ b/main.cpp Wed Apr 28 19:28:16 2021 +0000
@@ -1,60 +1,33 @@
#include "mbed.h"
-#include "XNucleo53L0A1.h"
#include <stdio.h>
-#include "rtos.h"
#include "LSM9DS1.h"
-
-#define VL53L0_I2C_SDA p28
-#define VL53L0_I2C_SCL p27
-
+#include "VL53L0X.h"
DigitalOut myled(LED1);
Serial pc(USBTX,USBRX);
DigitalOut shdn(p26);
-static XNucleo53L0A1 *board=NULL;
-
+LSM9DS1 lol(p9, p10, 0xD6, 0x3C);
+I2C i2c(p28, p27);
+VL53L0X lidar(&i2c);
int main()
{
float tempC;
- int status;
- uint32_t distance;
- uint32_t last_distance;
- DevI2C *device_i2c = new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL);
- /* creates the 53L0A1 expansion board singleton obj */
- board = XNucleo53L0A1::instance(device_i2c, A2, D8, D2);
shdn = 0; //must reset sensor for an mbed reset to work
wait(0.1);
shdn = 1;
wait(0.1);
- LSM9DS1 lol(p9, p10, 0xD6, 0x3C);
lol.begin();
if (!lol.begin()) {
pc.printf("Failed to communicate with LSM9DS1.\n");
}
lol.calibrate();
- /* init the 53L0A1 board with default values */
- status = board->init_board();
-
- while (status)
- {
- pc.printf("Failed to init board! \r\n");
- status = board->init_board();
- }
+
//loop taking and printing distance
while (1)
{
-
- if (board->sensor_centre->get_distance(&distance) == VL53L0X_ERROR_NONE)
- {
- if(distance != last_distance)
- {
- pc.printf("D=%ld mm\r\n", distance);
- }
- board->sensor_centre->get_distance(&last_distance);
- }
lol.readTemp();
lol.readMag();
lol.readGyro();