
trabalho
Dependencies: X_NUCLEO_IKS01A1 mbed-rtos mbed
Fork of HelloWorld_IKS01A1 by
Revision 27:0bbc1d575986, committed 2016-05-08
- Comitter:
- stwykd
- Date:
- Sun May 08 09:18:37 2016 +0000
- Parent:
- 26:71c54c8ae536
- Child:
- 28:840000670c88
- Commit message:
- Reading data now creates logs and saves them to the buffer
Changed in this revision
--- a/buffer.cpp Sun May 08 08:37:33 2016 +0000 +++ b/buffer.cpp Sun May 08 09:18:37 2016 +0000 @@ -11,13 +11,13 @@ typedef struct { uint8_t id; - float tempCelcius; + float tempCelsius; float tempFarenheit; float humidity; float pressure; - int accelerometer; - int gyroscope; - int magnetometer; + int32_t accelerometer[3]; + int32_t gyroscope[3]; + int32_t magnetometer[3]; char* date; } log_data;
--- a/expansionBoard.cpp Sun May 08 08:37:33 2016 +0000 +++ b/expansionBoard.cpp Sun May 08 09:18:37 2016 +0000 @@ -2,6 +2,8 @@ #include "x_nucleo_iks01a1.h" #include "buffer.cpp" +using namespace std; + /* Instantiate the expansion board */ static X_NUCLEO_IKS01A1 *mems_expansion_board = X_NUCLEO_IKS01A1::Instance(D14, D15); @@ -48,21 +50,35 @@ float value1, value2; char buffer1[32], buffer2[32]; int32_t axes[3]; + log_data log_d; temp_sensor1->GetTemperature(&value1); humidity_sensor->GetHumidity(&value2); printf("HTS221: [temp] %7s°C, [hum] %s%%\r\n", printDouble(buffer1, value1), printDouble(buffer2, value2)); + log_d.tempCelsius = value1; + log_d.humidity = value2; + temp_sensor2->GetFahrenheit(&value1); pressure_sensor->GetPressure(&value2); printf("LPS25H: [temp] %7s°F, [press] %smbar\r\n", printDouble(buffer1, value1), printDouble(buffer2, value2)); + log_d.tempFarenheit = value1; + log_d.pressure = value2; printf("---\r\n"); magnetometer->Get_M_Axes(axes); printf("LIS3MDL [mag/mgauss]: %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]); + memcpy(&log_d.magnetometer, &axes, sizeof(axes)); + accelerometer->Get_X_Axes(axes); printf("LSM6DS0 [acc/mg]: %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]); + memcpy(&log_d.accelerometer, &axes, sizeof(axes)); + gyroscope->Get_G_Axes(axes); printf("LSM6DS0 [gyro/mdps]: %6ld, %6ld, %6ld\r\n", axes[0], axes[1], axes[2]); + memcpy (&log_d.accelerometer, &axes, sizeof(axes)); + + //TODO Not sure about this one, maybe use time() + //log_d.date = asctime(localtime()); } public:
--- a/main.cpp Sun May 08 08:37:33 2016 +0000 +++ b/main.cpp Sun May 08 09:18:37 2016 +0000 @@ -16,7 +16,6 @@ #include <ctime> #include <stdexcept> -struct tm t; ExpansionBoard e; int main() {