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

Committer:
co838_jls44
Date:
Fri Feb 24 14:33:41 2017 +0000
Revision:
1:c54902f21aa8
Parent:
0:4b83b332b327
comment about the playnote method

Who changed what in which revision?

UserRevisionLine numberNew contents of line
co838_jls44 0:4b83b332b327 1 /* Developed by Jean-Paul Saysana - jls44 - MSc Student in Computer Security*/
co838_jls44 0:4b83b332b327 2 /* Internet of Things and Mobile Devices - CO838 University of Kent*/
co838_jls44 0:4b83b332b327 3
co838_jls44 0:4b83b332b327 4 #include "Compass.h"
co838_jls44 0:4b83b332b327 5
co838_jls44 0:4b83b332b327 6 /* I2c bus */
co838_jls44 0:4b83b332b327 7 I2C i2c(PTE25, PTE24);
co838_jls44 0:4b83b332b327 8
co838_jls44 0:4b83b332b327 9 /* To retrieve the axis6 from eCompass libray's header, to get the compass angle */
co838_jls44 0:4b83b332b327 10 extern axis6_t axis6;
co838_jls44 0:4b83b332b327 11
co838_jls44 0:4b83b332b327 12 /* Parameters for the constructor of magnetometer and accelerometer*/
co838_jls44 0:4b83b332b327 13 Compass::Compass(uint8_t addr) : mag(i2c, addr), acc(i2c, addr) {
co838_jls44 0:4b83b332b327 14 /* enabling accelerometer and magnetometer*/
co838_jls44 0:4b83b332b327 15 acc.enable();
co838_jls44 0:4b83b332b327 16 mag.enable();
co838_jls44 0:4b83b332b327 17 }
co838_jls44 0:4b83b332b327 18
co838_jls44 0:4b83b332b327 19 /* Return the angle of the compass */
co838_jls44 0:4b83b332b327 20 float Compass::GetAngle() const {
co838_jls44 0:4b83b332b327 21 return axis6.yaw;
co838_jls44 0:4b83b332b327 22 }
co838_jls44 0:4b83b332b327 23
co838_jls44 0:4b83b332b327 24 float Compass::GetCompass() {
co838_jls44 0:4b83b332b327 25 /* Get the axis in raw values of the accelerometer and magnetometer. */
co838_jls44 0:4b83b332b327 26 acc.getAxis(acc_raw);
co838_jls44 0:4b83b332b327 27 mag.getAxis(mag_raw);
co838_jls44 0:4b83b332b327 28 /* Run the eCompass */
co838_jls44 0:4b83b332b327 29 run(acc_raw, mag_raw);
co838_jls44 0:4b83b332b327 30 /* After running it, we can return the angle. */
co838_jls44 0:4b83b332b327 31 return GetAngle();
co838_jls44 0:4b83b332b327 32 }