Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Adafruit9-DOf by
Revision 1:c3381056a1c6, committed 2015-11-28
- Comitter:
- jatinsha
- Date:
- Sat Nov 28 10:06:40 2015 +0000
- Parent:
- 0:772bf4786416
- Commit message:
- js
Changed in this revision
--- a/Source/Adafruit_9DOF.cpp Sat Mar 21 12:33:05 2015 +0000 +++ b/Source/Adafruit_9DOF.cpp Sat Nov 28 10:06:40 2015 +0000 @@ -15,9 +15,7 @@ ***************************************************************************/ #include <math.h> - #include "Adafruit_9DOF.h" - #define PI (3.14159265F); /*************************************************************************** @@ -47,11 +45,8 @@ @brief Setups the HW */ /**************************************************************************/ -bool Adafruit_9DOF::begin() -{ +bool Adafruit_9DOF::begin(){ // Enable I2C - - return true; }
--- a/Source/Adafruit_LSM303_U.cpp Sat Mar 21 12:33:05 2015 +0000 +++ b/Source/Adafruit_LSM303_U.cpp Sat Nov 28 10:06:40 2015 +0000 @@ -235,8 +235,7 @@ bool Adafruit_LSM303_Mag_Unified::begin() { // Enable I2C - - + // Enable the magnetometer write8(LSM303_ADDRESS_MAG, LSM303_REGISTER_MAG_MR_REG_M, 0x00);
--- a/Source/main.cpp Sat Mar 21 12:33:05 2015 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +0,0 @@ -#include "mbed.h" -#define _MBED_ -#include "Adafruit_9DOF.h" -#include "Serial_base.h" - - - -/* Assign a unique ID to the sensors */ - -Adafruit_9DOF dof = Adafruit_9DOF(); - -Adafruit_LSM303_Accel_Unified accel = Adafruit_LSM303_Accel_Unified(30301); - -Adafruit_LSM303_Mag_Unified mag = Adafruit_LSM303_Mag_Unified(30302); - - -/* Update this with the correct SLP for accurate altitude measurements */ - -float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; - - -/************************************************************************** -/ -/ - @brief Initialises all the sensors used by this example - -/ -**************************************************************************/ - -void initSensors() -{ - - if(!accel.begin()) - { - - /* There was a problem detecting the LSM303 ... check your connections */ - - s_com->println(("Ooops, no LSM303 detected ... Check your wiring!")); - - while(1); - - } - if(!mag.begin()) - { - - /* There was a problem detecting the LSM303 ... check your connections */ - - s_com->println("Ooops, no LSM303 detected ... Check your wiring!"); - - while(1); - - } - -} -/**************************************************************************/ - - - -/**************************************************************************/ - -void setup(void) -{ - - - - s_com->println(("Adafruit 9 DOF Pitch/Roll/Heading Example")); - s_com->println(""); - - - /* Initialise the sensors */ - - initSensors(); - -} - - -/************************************************************************** -/ -/ - @brief Constantly check the roll/pitch/heading/altitude/temperature - -**************************************************************************/ - -void loop(void) -{ - - sensors_event_t accel_event; - - sensors_event_t mag_event; - - sensors_vec_t orientation; - - - /* Calculate pitch and roll from the raw accelerometer data */ - - accel.getEvent(&accel_event); - - if (dof.accelGetOrientation(&accel_event, &orientation)) - { - - /* 'orientation' should have valid .roll and .pitch fields */ - - s_com->print(("Roll: ")); - - s_com->print(orientation.roll); - - s_com->print(("; ")); - - s_com->print(("Pitch: ")); - - - s_com->print(orientation.pitch); - - s_com->print(("; ")); - - } - - - /* Calculate the heading using the magnetometer */ - - mag.getEvent(&mag_event); - - if (dof.magGetOrientation(SENSOR_AXIS_Z, &mag_event, &orientation)) - { - - /* 'orientation' should have valid .heading data now */ - - s_com->print(("Heading: ")); - - s_com->print(orientation.heading); - - s_com->print(("; ")); - - } - - - s_com->println(("")); - - wait(0.1); - -} - -int main() -{ - setup(); - while(1) - loop(); -} \ No newline at end of file