calculate
Dependencies: mbed X_NUCLEO_IKS01A3 Mahony_Algorithm
Revision 0:313fbc3a198a, committed 2020-04-01
- Comitter:
- zollecy1
- Date:
- Wed Apr 01 16:47:06 2020 +0000
- Child:
- 1:48e219526d0f
- Commit message:
- test
Changed in this revision
--- /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();
+
+}
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CalculateData.h Wed Apr 01 16:47:06 2020 +0000
@@ -0,0 +1,56 @@
+/**
+|**********************************************************************;
+* 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
+*
+|**********************************************************************;
+**/
+
+
+#ifndef CALCULATEDATA_H
+#define CALCULATEDATA_H
+
+#include "mbed.h"
+#include "XNucleoIKS01A3.h"
+
+class CalculateData {
+
+public:
+
+ CalculateData(PinName Pin0, PinName Pin1, PinName Pin2,
+ PinName Pin3, PinName Pin4, PinName Pin5, PinName Pin6); //Constructor
+
+ virtual ~CalculateData();
+ void enable();
+ void disable();
+ void getData();
+
+private:
+
+ static const float PERIOD;
+
+ Ticker ticker;
+
+ void run();
+
+};
+
+
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/X_NUCLEO_IKS01A3.lib Wed Apr 01 16:47:06 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/ST/code/X_NUCLEO_IKS01A3/#463962d6f485
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Apr 01 16:47:06 2020 +0000
@@ -0,0 +1,49 @@
+/**
+|**********************************************************************;
+* Project : Projektarbeit Systemtechnik PES4
+*
+* Program name : ................
+*
+* 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 : Main
+*
+|**********************************************************************;
+**/
+
+#include "mbed.h"
+#include "CalculateData.h"
+
+
+//initialise DigitalIO
+DigitalOut myled(LED1);
+DigitalOut enable(PB_15);
+DigitalIn leftsensor(PA_0);
+DigitalIn user_button(USER_BUTTON);
+
+
+//Generate object
+CalculateData calculate(D14, D15, D4, D5, A3, D6, A4);
+
+
+int main(){
+ wait(4);
+ calculate.enable();
+ wait(8);
+ calculate.disable();
+
+
+}
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Wed Apr 01 16:47:06 2020 +0000 @@ -0,0 +1,1 @@ +https://github.com/armmbed/mbed-os/#73f096399b4cda1f780b140c87afad9446047432
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Apr 01 16:47:06 2020 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/e1686b8d5b90
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json Wed Apr 01 16:47:06 2020 +0000
@@ -0,0 +1,3 @@
+{
+ "requires": ["bare-metal"]
+}
\ No newline at end of file