PmodNAV test

Dependencies:   mbed LPS25HB_I2C LSM9DS1 UsaPack

Revision:
0:c99eaed54c50
Child:
1:e5d5afc20fe2
Child:
2:20d44bbe80e4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Sep 27 09:02:40 2021 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "LSM9DS1.h"
+#include "LPS.h"
+
+Serial pc(USBTX, USBRX, 57600);
+I2C i2c(PF_0, PF_1);
+LSM9DS1 lsm(i2c);
+LPS lps(i2c);
+
+using namespace std;
+
+int main()
+{
+    uint16_t reg = lsm.begin();
+    //printf("%x\n", reg);
+    if (!lps.init()){
+        printf("Failed to autodetect pressure sensor!\r\n");
+        while (1);
+    }
+    lps.enableDefault();
+    wait_ms(100);
+    while(true)
+    {
+        lsm.readAccel();
+        lsm.readMag();
+        lsm.readGyro();
+        //printf("%f %f %f %f %f %f %f %f %f\n", lsm.ax, lsm.ay, lsm.az, lsm.gx, lsm.gy, lsm.gz, lsm.mx, lsm.my, lsm.mz);
+        //printf("%f %f %f\n", lsm.gx, lsm.gy, lsm.gz);
+        //printf("%f %f %f\n", lsm.mx, lsm.my, lsm.mz);
+        float pressure = lps.readPressureMillibars();
+        float altitude = lps.pressureToAltitudeMeters(pressure);
+        float temperature = lps.readTemperatureC();
+        //printf("p:%.2f\t mbar\ta:%.2f m\tt:%.2f deg C\r\n",pressure,altitude,temperature);
+        printf("%f %f %f %f %f %f %f %f %f %f\n", lsm.ax, lsm.ay, lsm.az, lsm.gx, lsm.gy, lsm.gz, lsm.mx, lsm.my, lsm.mz, pressure);
+        wait(0.1);
+    }
+}
\ No newline at end of file