Sensor Data - first assignment CO838

Dependencies:   mbed C12832 FXOS8700Q LM75B eCompass_FPU_Lib

Sensor Data - Project developed by Jean-Paul Saysana (jls44)

First assignment for the Internet of Things and Mobile Devices CO838 module

University of Kent (2016-2017)

Functionalities:

- Temperature Sensor

- Compass

- Music box

- Potentiometer that changes LED colours

Libraries used: C12832, eCompass_FPU_Lib, FXOS8700Q, LM75B

src/Compass.cpp

Committer:
co838_jls44
Date:
2017-02-24
Revision:
1:c54902f21aa8
Parent:
0:4b83b332b327

File content as of revision 1:c54902f21aa8:

/* Developed by Jean-Paul Saysana - jls44 - MSc Student in Computer Security*/
/* Internet of Things and Mobile Devices - CO838 University of Kent*/

#include "Compass.h"

/* I2c bus */
I2C i2c(PTE25, PTE24);

/* To retrieve the axis6 from eCompass libray's header, to get the compass angle */
extern axis6_t axis6;

/* Parameters for the constructor of magnetometer and accelerometer*/
Compass::Compass(uint8_t addr) : mag(i2c, addr), acc(i2c, addr) {
    /* enabling accelerometer and magnetometer*/
    acc.enable();
    mag.enable();
}

/* Return the angle of the compass */
float Compass::GetAngle() const {
    return axis6.yaw;
}

float Compass::GetCompass() {
    /* Get the axis in raw values of the accelerometer and magnetometer. */
    acc.getAxis(acc_raw);
    mag.getAxis(mag_raw);
    /* Run the eCompass */
    run(acc_raw, mag_raw);
    /* After running it, we can return the angle.  */
    return GetAngle();
}