Finished project.

Dependencies:   X_NUCLEO_COMMON

Fork of ReferredCoursework2016 by Stage-1 Students SoCEM

Committer:
J_Satchell
Date:
Thu Aug 17 02:42:30 2017 +0000
Revision:
90:38dfa3f350aa
Child:
91:cd9fcd45ecf6
Completed project.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
J_Satchell 90:38dfa3f350aa 1 /*sensor.cpp simply reads in the acceleration measurements
J_Satchell 90:38dfa3f350aa 2 using the NUCLEO board and using the function and struct
J_Satchell 90:38dfa3f350aa 3 from buffer.cpp, stores the values in to the circular buffer*/
J_Satchell 90:38dfa3f350aa 4 #include "mbed.h"
J_Satchell 90:38dfa3f350aa 5 #include "x_nucleo_iks01a1.h"
J_Satchell 90:38dfa3f350aa 6 #include "buffer.h"
J_Satchell 90:38dfa3f350aa 7 #include "sensor.h"
J_Satchell 90:38dfa3f350aa 8
J_Satchell 90:38dfa3f350aa 9 /* Instantiate the expansion board */
J_Satchell 90:38dfa3f350aa 10 static X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance(D14, D15);
J_Satchell 90:38dfa3f350aa 11
J_Satchell 90:38dfa3f350aa 12 /* Retrieve the composing elements of the expansion board */
J_Satchell 90:38dfa3f350aa 13 static MotionSensor *accelerometer = mems_expansion_board->GetAccelerometer();
J_Satchell 90:38dfa3f350aa 14
J_Satchell 90:38dfa3f350aa 15 extern char *printDouble(char* str, double v, int decimalDigits = 2);
J_Satchell 90:38dfa3f350aa 16
J_Satchell 90:38dfa3f350aa 17 int32_t axes[3];
J_Satchell 90:38dfa3f350aa 18
J_Satchell 90:38dfa3f350aa 19 void sensor_run(){
J_Satchell 90:38dfa3f350aa 20 while (1) {
J_Satchell 90:38dfa3f350aa 21
J_Satchell 90:38dfa3f350aa 22 accelerometer->Get_X_Axes(axes);
J_Satchell 90:38dfa3f350aa 23
J_Satchell 90:38dfa3f350aa 24 AccelData d;
J_Satchell 90:38dfa3f350aa 25 d.x = axes[0];
J_Satchell 90:38dfa3f350aa 26 d.y = axes[1];
J_Satchell 90:38dfa3f350aa 27 d.z = axes[2];
J_Satchell 90:38dfa3f350aa 28
J_Satchell 90:38dfa3f350aa 29 log_push(d);
J_Satchell 90:38dfa3f350aa 30 }
J_Satchell 90:38dfa3f350aa 31
J_Satchell 90:38dfa3f350aa 32 }