Alexandre Salconi-Denis / Mbed 2 deprecated Nucleo_i2c_9dof

Dependencies:   L3GD20 LSM303DLH debug_addon_graphique_ASCII mbed

Files at this revision

API Documentation at this revision

Comitter:
salco
Date:
Mon Aug 07 01:26:53 2017 +0000
Child:
1:7d60cdcb1d3c
Commit message:
Programme usable but we need to check L3GD20 lib.;

Changed in this revision

L3GD20.lib Show annotated file Show diff for this revision Revisions of this file
LSM303DLH.lib Show annotated file Show diff for this revision Revisions of this file
debug_addon_graphique_ASCII.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/L3GD20.lib	Mon Aug 07 01:26:53 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/bclaus/code/L3GD20/#17c3c3f59c4d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LSM303DLH.lib	Mon Aug 07 01:26:53 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/salco/code/LSM303DLH/#cc338ded0b2c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debug_addon_graphique_ASCII.lib	Mon Aug 07 01:26:53 2017 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/salco/code/debug_addon_graphique_ASCII/#ad081a718bb3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Aug 07 01:26:53 2017 +0000
@@ -0,0 +1,125 @@
+#include "mbed.h"
+ //#include "debug.h"
+ 
+#include "LSM303DLH.h"
+#include "AnsiGraphicalConsole.h"
+#include "vector.h"
+#include "L3GD20.h"
+ 
+#define LSM303_REG_TEMP (0x00) // Temperature Register
+#define LSM303_REG_CONF (0x01) // Configuration Register
+#define LSM303_ADDR     (0x90) // LSM303 address
+ 
+ 
+#define USE_LM303
+#define USE_L3GD20
+DigitalIn mybutton(USER_BUTTON);
+I2C ptr_i2c(I2C_SDA, I2C_SCL);
+#if defined(USE_L3GD20)
+L3GD20    gyro(&ptr_i2c);//(I2C_SDA, I2C_SCL);   
+#endif
+#if defined(USE_LM303)
+LSM303DLH compass(&ptr_i2c);//(I2C_SDA, I2C_SCL);
+#endif
+
+DigitalOut myled(LED1);
+ 
+Serial pc(SERIAL_TX, SERIAL_RX);
+ 
+//volatile char TempCelsiusDisplay[] = "+abc.d C";
+
+int main()
+{
+ 
+    pc.printf("\n Test Salco \n");
+    clearscreen();
+    
+    /*char data_write[2];
+    char data_read[2];*/
+    
+    /* Configure the Temperature sensor device STLM75:
+    - Thermostat mode Interrupt
+    - Fault tolerance: 0
+    */
+    //data_write[0] = LM75_REG_CONF;
+   // data_write[1] = 0x02;
+   // int status =
+    /*if (status != 0) { // Error
+        while (1) {
+            myled = !myled;
+            wait(0.2);
+        }
+    }*/
+    
+#if defined(USE_LM303)
+  //compass.setOffset(29.50, -0.50, 4.00); // example calibration
+  compass.setScale(1.00,1.00,1.00); //1.03, 1.21);    // example calibration
+  compass.frequency(100000);
+  vector accelerometer,magnetometer;
+  float hdg;
+  #endif
+    
+    #if defined(USE_L3GD20)
+    vector gyroscope;
+    #endif
+    char index=0;
+    
+    while (1) {
+        
+        
+        //hdg = compass.heading();
+        //debug.printf("Heading: %.2f\n", hdg);
+ 
+        // Display result
+        //pc.printf("Heading: %.2f\n", hdg);
+        myled = !myled;
+        if(index>=2)
+        {
+            #if defined(USE_LM303)          
+            if(compass.read(accelerometer,magnetometer))
+            {
+                setText(0,10,"accelerometer: X:%.2f Y:%.2f Z:%.2f\n", accelerometer.x,accelerometer.y,accelerometer.z);
+                setText(0,11,"magnetometer:  X:%.4f Y:%.4f Z:%.4f\n", magnetometer.x,magnetometer.y,magnetometer.z);
+                
+               
+                hdg = compass.heading((vector){0,0,-1});
+                setText(0,12,"Heading: %.2f\n", hdg);
+                //magnetometre {+-20@ 0}== axe nord/sud
+                //si X pos coter NORD et si X neg SUD
+            }
+            else
+            {
+                pc.printf("Error with I2C com\n");
+            }
+            #endif
+            index=0;
+            #if defined(USE_L3GD20)
+            if(gyro.read(&gyroscope.x,&gyroscope.y,&gyroscope.z))
+            {
+                gyro.Convert_to_RadPerSec(&gyroscope.x,&gyroscope.y,&gyroscope.z);
+                setText(0,13,"gyroscope:  X:%.2f Y:%.2f Z:%.2f\n", gyroscope.x,gyroscope.y,gyroscope.z);
+            }
+            else
+            {
+                pc.printf("Error with I2C com\n");
+                
+            }
+            #endif
+        }
+                
+        wait(.5);
+        index++;
+        
+         if (mybutton == 0) 
+         { // Button is pressed
+             do{
+                clearscreen();
+                setText(0,1,"PAUSE\n");
+                wait(2);
+             }while(mybutton != 0);
+             clearscreen();
+         }
+    }
+ 
+}
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Aug 07 01:26:53 2017 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed/builds/a97add6d7e64
\ No newline at end of file