calculate
Dependencies: mbed X_NUCLEO_IKS01A3 Mahony_Algorithm
Diff: CalculateData.cpp
- Revision:
- 0:313fbc3a198a
- Child:
- 1:48e219526d0f
diff -r 000000000000 -r 313fbc3a198a CalculateData.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CalculateData.cpp Wed Apr 01 16:47:06 2020 +0000
@@ -0,0 +1,163 @@
+/**
+|**********************************************************************;
+* Project : Projektarbeit Systemtechnik PES4
+*
+* Program name : Beispiel
+*
+* Author : PES4 Team1
+*
+* Team : **Team 1**
+* Fabio Bernard
+* Lukas Egli
+* Matthias Ott
+* Pascal Novacki
+* Robin Wanner
+* Vincent Vescoli
+* Cyrill Zoller
+*
+* Date created : 20.02.2020
+*
+* Purpose : Beispiel
+*
+|**********************************************************************;
+**/
+
+#include "CalculateData.h"
+#include "mbed.h"
+#include "XNucleoIKS01A3.h"
+
+using namespace std;
+
+const float CalculateData::PERIOD = 0.01f; //Periode von 10 ms
+
+
+static XNucleoIKS01A3 *mems_expansion_board;
+static LIS2MDLSensor *magnetometer;
+static HTS221Sensor *hum_temp;
+static LPS22HHSensor *press_temp;
+static LSM6DSOSensor *acc_gyro;
+static LIS2DW12Sensor *accelerometer;
+static STTS751Sensor *temp;
+float value1, value2;
+int32_t axes[3];
+
+
+
+CalculateData::CalculateData(PinName p0, PinName p1, PinName p2, PinName p3,
+ PinName p4, PinName p5, PinName p6){
+
+ /* Instantiate the expansion board */
+ mems_expansion_board = XNucleoIKS01A3::instance(p0, p1, p2, p3, p4, p5, p6);
+
+ /* Retrieve the composing elements of the expansion board */
+ magnetometer = mems_expansion_board->magnetometer;
+ hum_temp = mems_expansion_board->ht_sensor;
+ press_temp = mems_expansion_board->pt_sensor;
+ acc_gyro = mems_expansion_board->acc_gyro;
+ accelerometer = mems_expansion_board->accelerometer;
+ temp = mems_expansion_board->t_sensor;
+
+ /* Enable all sensors */
+ hum_temp->enable();
+ press_temp->enable();
+ temp->enable();
+ magnetometer->enable();
+ accelerometer->enable_x();
+ acc_gyro->enable_x();
+ acc_gyro->enable_g();
+
+ /*while(1){
+ printf("\r\n");
+
+ hum_temp->get_temperature(&value1);
+ hum_temp->get_humidity(&value2);
+ printf("HTS221: [temp] %4.2f C, [hum] %4.2f%%\r\n", value1, value2);
+
+ press_temp->get_temperature(&value1);
+ press_temp->get_pressure(&value2);
+ printf("LPS22HH: [temp] %4.2f C, [press] %6.2f mbar\r\n", value1, value2);
+
+ temp->get_temperature(&value1);
+ printf("STTS751: [temp] %4.2f C\r\n", value1);
+
+ printf("---\r\n");
+
+ magnetometer->get_m_axes(axes);
+ printf("LIS2MDL [mag/mgauss]: %6d, %6d, %6d\r\n", axes[0], axes[1], axes[2]);
+
+ accelerometer->get_x_axes(axes);
+ printf("LIS2DW12 [acc/mg]: %6d, %6d, %6d\r\n", axes[0], axes[1], axes[2]);
+
+ acc_gyro->get_x_axes(axes);
+ printf("LSM6DSO [acc/mg]: %6d, %6d, %6d\r\n", axes[0], axes[1], axes[2]);
+
+ acc_gyro->get_g_axes(axes);
+ printf("LSM6DSO [gyro/mdps]: %6d, %6d, %6d\r\n", axes[0], axes[1], axes[2]);
+ }*/
+}
+
+
+CalculateData::~CalculateData() {
+
+}
+
+
+void CalculateData::enable(){
+ //Starten des periodischen Task
+ ticker.attach(callback(this, &CalculateData::run), PERIOD);
+
+
+}
+
+void CalculateData::disable(){
+ ticker.detach(); // Stoppt den periodischen Task
+}
+
+void CalculateData::getData(){
+ printf("\r\n");
+
+ hum_temp->get_temperature(&value1);
+ hum_temp->get_humidity(&value2);
+ printf("HTS221: [temp] %4.2f C, [hum] %4.2f%%\r\n", value1, value2);
+
+ press_temp->get_temperature(&value1);
+ press_temp->get_pressure(&value2);
+ printf("LPS22HH: [temp] %4.2f C, [press] %6.2f mbar\r\n", value1, value2);
+
+ temp->get_temperature(&value1);
+ printf("STTS751: [temp] %4.2f C\r\n", value1);
+
+ printf("---\r\n");
+
+ magnetometer->get_m_axes(axes);
+ printf("LIS2MDL [mag/mgauss]: %6d, %6d, %6d\r\n", axes[0], axes[1], axes[2]);
+
+ accelerometer->get_x_axes(axes);
+ printf("LIS2DW12 [acc/mg]: %6d, %6d, %6d\r\n", axes[0], axes[1], axes[2]);
+
+ acc_gyro->get_x_axes(axes);
+ printf("LSM6DSO [acc/mg]: %6d, %6d, %6d\r\n", axes[0], axes[1], axes[2]);
+
+ acc_gyro->get_g_axes(axes);
+ printf("LSM6DSO [gyro/mdps]: %6d, %6d, %6d\r\n", axes[0], axes[1], axes[2]);
+
+}
+
+
+//Periodischer Task
+void CalculateData::run() {
+
+ getData();
+
+}
+
+
+
+
+
+
+
+
+
+
+