ajout de l'imu pour nucleo
Dependencies: mbed HC_SR04_Ultrasonic_Library IMU_FIP_nucleo Nucleo_Sensor_Shield VL6180x_lib
Diff: main.cpp
- Revision:
- 11:fce59d46840f
- Parent:
- 4:149c4509b35d
diff -r 3eb49bd62e46 -r fce59d46840f main.cpp --- a/main.cpp Thu May 21 11:05:10 2015 +0000 +++ b/main.cpp Thu May 21 11:17:08 2015 +0000 @@ -1,23 +1,72 @@ #include "mbed.h" #include "ultrasonic.h" +#include "Imu.h" +/* void dist(int distance) { - //code exécuté lorsque la distance change + //put code here to happen when the distance is changed printf("Distance changed to %dmm\r\n", distance); } -ultrasonic mu(D8, D9, .1, 1, &dist); //Trigger: pin D8; Echo: pin D9 - //Updates toutes les 0.1 secondes et timeout après 1 seconde - //Appel de dist lorsque la distance change +ultrasonic mu(D8, D9, .1, 1, &dist); //Set the trigger pin to D8 and the echo pin to D9 + //have updates every .1 seconds and a timeout after 1 + //second, and call dist when the distance changes int main() { - mu.startUpdates();//démarre la mesure + mu.startUpdates();//start mesuring the distance while(1) { //Do something else here mu.checkDistance(); //call checkDistance() as much as possible, as this is where //the class checks if dist needs to be called. } +}*/ + +Imu i; +Serial pc(SERIAL_TX, SERIAL_RX); +DigitalOut myled(LED1); +Data_IMU * foo; +Data_IMU * bar; + +int main() +{ + + i.setOffset(); + foo = i.getOffset(); + bar = i.getData(); + + while(1) { + + myled = 1; // LED is ON + wait(0.2); // 200 ms + myled = 0; // LED is OFF + wait(10); + + i.refresh(1); + + + /*pc.printf("OFFSET : \r\n"); + pc.printf("Temperature:\t\t %f C\r\n", foo->TEMPERATURE_Value_C); + pc.printf("Humidity:\t\t %f%%\r\n", foo->HUMIDITY_Value); + pc.printf("Pressure:\t\t %f hPa\r\n", foo->PRESSURE_Value); + pc.printf("Magnetometer (mGauss):\t X: %d, Y: %d, Z: %d\r\n", foo->MAG_Value->AXIS_X, foo->MAG_Value->AXIS_Y, foo->MAG_Value->AXIS_Z); + pc.printf("Accelerometer (mg):\t X: %d, Y: %d, Z: %d\r\n", foo->ACC_Value->AXIS_X, foo->ACC_Value->AXIS_Y, foo->ACC_Value->AXIS_Z); + pc.printf("Gyroscope (mdps):\t X: %d, Y: %d, Z: %d\r\n", foo->GYR_Value->AXIS_X, foo->GYR_Value->AXIS_Y, foo->GYR_Value->AXIS_Z); + pc.printf("\r\n");*/ + + pc.printf("RAW DATA : \r\n"); + pc.printf("Temperature:\t\t %f C\r\n", bar->TEMPERATURE_Value_C); + pc.printf("Humidity:\t\t %f%%\r\n", bar->HUMIDITY_Value); + pc.printf("Pressure:\t\t %f hPa\r\n", bar->PRESSURE_Value); + pc.printf("Magnetometer (mGauss):\t X: %d, Y: %d, Z: %d\r\n", bar->MAG_Value->AXIS_X, bar->MAG_Value->AXIS_Y, bar->MAG_Value->AXIS_Z); + pc.printf("Accelerometer (mg):\t X: %d, Y: %d, Z: %d\r\n", bar->ACC_Value->AXIS_X, bar->ACC_Value->AXIS_Y, bar->ACC_Value->AXIS_Z); + pc.printf("Gyroscope (mdps):\t X: %d, Y: %d, Z: %d\r\n", bar->GYR_Value->AXIS_X, bar->GYR_Value->AXIS_Y, bar->GYR_Value->AXIS_Z); + pc.printf("\r\n"); + + + } } + +